

from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
__A    	=			[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]



def    snake_case_(_UpperCamelCase  )							->			list[int]:



  """simple docstring"""






  return [int(_UpperCamelCase  ) for c in F"""{ruleset:08}"""[:8]]



def    snake_case_(_UpperCamelCase				, _UpperCamelCase				, _UpperCamelCase  )							->			list[int]:



  """simple docstring"""






  _snake_case		=      len(cells[0]  )  # 31
  _snake_case		=      []
  for i in range(_UpperCamelCase  ):
    # Get the neighbors of each cell
    # Handle neighbours outside bounds by using 0 as their value
    _snake_case		=      0 if i == 0 else cells[time][i - 1]
    _snake_case		=      0 if i == population - 1 else cells[time][i + 1]
    # Define a new cell and add it to the new generation
    _snake_case		=      7 - int(F"""{left_neighbor}{cells[time][i]}{right_neighbor}"""				, 2  )
    next_generation.append(rule[situation]  )
  return next_generation



def    snake_case_(_UpperCamelCase  )							->			Image.Image:



  """simple docstring"""






  _snake_case		=      Image.new('''RGB'''				, (len(cells[0]  ), len(_UpperCamelCase  ))  )
  _snake_case		=      img.load()
  # Generates image
  for w in range(img.width  ):
    for h in range(img.height  ):
      _snake_case		=      255 - int(255 * cells[h][w]  )
      _snake_case		=      (color, color, color)
  return img


if __name__ == "__main__":
 __A    	=			bin(int(input('''Rule:\n''').strip()))[2:]
 __A    	=			format_ruleset(int(rule_num))
 for time in range(16):
  CELLS.append(new_generation(CELLS, rule, time))
 __A    	=			generate_image(CELLS)
 # Uncomment to save the image
 # img.save(f"rule_{rule_num}.png")
 img.show()




__A    	=			{
    '''+''': lambda x, y: x + y,
    '''-''': lambda x, y: x - y,
    '''*''': lambda x, y: x * y,
    '''/''': lambda x, y: x / y,
}



def    snake_case_(_UpperCamelCase  )							->			str:



  """simple docstring"""






  return c.isdigit()



def    snake_case_(_UpperCamelCase  )							->			str:



  """simple docstring"""






  _snake_case		=							[]

  # iterate over the string in reverse order
  for c in expression.split()[::-1]:
    # push operand to stack
    if is_operand(_UpperCamelCase  ):
      stack.append(int(_UpperCamelCase  )  )

    else:
      # pop values from stack can calculate the result
      # push the result onto the stack again
      _snake_case		=							stack.pop()
      _snake_case		=							stack.pop()
      stack.append(calc[c](_UpperCamelCase				, _UpperCamelCase  )  )

  return stack.pop()


# Driver code
if __name__ == "__main__":
 __A    	=			'''+ 9 * 2 6'''
 print(evaluate(test_expression))

 __A    	=			'''/ * 10 2 + 4 1 '''
 print(evaluate(test_expression))

