input: 
  Below is an instruction that describes a task. Write a response that appropriately completes the request.
  
  ### Instruction:
  Create an algorithm in Python to generate the first n elements of the Sierpinski triangle.
  
  ### Input:
  n = 6
  
  ### Output:
  Write a function to generate the first n elements of the Sierpinski triangle in Python. The function should print the elements row by row.
  def sierpinski_triangle(n):
      for i in range(1, n + 1):
          print(' ' * (n - i), end="")
          for j in range(i):
              print('1', end=" ")
          print()
  
  sierpinski_triangle(6)
  
  assert sierpinski_triangle(1) == "1"
  assert sierpinski_triangle(2) == " 1\n1 1"
  assert sierpinski_triangle(3) == "  1\n 1 1\n1 1 1"
  assert sierpinski_triangle(4) == "   1\n  1 1\n 1 1 1\n1 1 1 1"
  assert sierpinski_triangle(5) == "    1\n   1 1\n  1 1 1\n 1 1 1 1\n1 1 1 1 1"
  assert sierpinski_triangle(6) == "     1\n    1 1\n   1 1 1\n  1 1 1 1\n 1 1 1 1 1\n1 1 1 1 1 1"
  
output:     
      for i in range(1, n + 1):
          print(' ' * (n - i), end="")
          for j in range(i):
              if j == 0 or j == i - 1:
                  print('1', end=" ")
              else:
                  print('0', end=" ")
          print()
  