input: Write a python function to print Sierpinski's triangle and assert the output.
  assert sierpinski_triangle(1) == ' 1 \n'
  assert sierpinski_triangle(2) == '   1 \n 1 0 1 \n'
  assert sierpinski_triangle(3) == '       1 \n     1 0 1 \n   1 0 0 0 1 \n 1 0 0 0 0 0 0 1 \n'
output: def sierpinski_triangle(n):
      def generate_line(level, width):
          if level == 0:
              return '1'.center(width * 2 - 1)
          else:
              prev_line = generate_line(level - 1, width)
              spaces = ' ' * (2**(n - level) - 1)
              line = prev_line.replace('0', ' 0 ').replace('1', ' 1 ')
              line = line.replace(' ', '', 1).rstrip()
              return spaces + line + spaces
      
      lines = [generate_line(level, 2**n) for level in range(n)]
      return '\n'.join(lines) + '\n'