
from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
lowercase__				:				List[Any]						=      [[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 						A_			(				snake_case				: int			)   ->     list[int]:



						'''simple docstring'''

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




def 						A_			(				snake_case				: list[list[int]]			,   snake_case				: list[int]			,   snake_case				: int			)   ->     list[int]:



						'''simple docstring'''

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




def 						A_			(				snake_case				: list[list[int]]			)   ->     Image.Image:



						'''simple docstring'''

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


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






def 			UpperCamelCase       (				lowerCAmelCase__ = 30						):
					'''simple docstring'''
					lowercase		      =		exponent + 2
					lowercase		      =		(1 + 5**0.5) / 2
					lowercase		      =		(phi**fibonacci_index - (phi - 1) ** fibonacci_index) / 5**0.5

					return int(lowerCAmelCase__						)


if __name__ == "__main__":
							print(F'{solution() = }')




