input: def sierpinski_triangle(n: int) -> None:
      """Generate the first n elements of the Sierpinski triangle.
      >>> sierpinski_triangle(1)
        1  
      >>> sierpinski_triangle(2)
        1  
        1  0  
      >>> sierpinski_triangle(3)
        1  
        1  0  
        1  1  0  
      >>> sierpinski_triangle(4)
        1  
        1  0  
        1  1  0  
        1  0  0  0  
      """
      for i in range(1, n+1):
          # bit pattern for first and last line of each row
          for j in range(2**(i-1), 2**i):
              print('1' if j % 2 == (i+1) % 2 else '0', end=" ")
          print()
output:     for i in range(1, n+1):
          row = []
          for j in range(i):
              if j == 0 or j == i-1:
                  row.append('1')
              else:
                  row.append('0' if row[j-1] == row[j] else '1')
          print(' '.join(row))