



from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
UpperCAmelCase							=       [[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_   (						__a  :					int		):

				"""simple docstring"""
				return [int(__a		) for c in F'''{ruleset:08}'''[:8]]

def       A_   (						__a  :					list[list[int]]			,		__a  :					list[int]			,		__a  :					int		):

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

def       A_   (						__a  :					list[list[int]]		):

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


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



import math




def 		lowerCAmelCase_     (     _SCREAMING_SNAKE_CASE  )   ->      list[int]:

							"""simple docstring"""






							if not isinstance(_SCREAMING_SNAKE_CASE      ,	_SCREAMING_SNAKE_CASE  ):
														_UpperCAmelCase  :			Optional[Any]	       =		F"""Input value of [number={number}] must be an integer"""
														raise TypeError(_SCREAMING_SNAKE_CASE  )
							if number < 1:
														_UpperCAmelCase  :			Dict	       =		F"""Input value of [number={number}] must be a positive integer"""
														raise ValueError(_SCREAMING_SNAKE_CASE  )
							_UpperCAmelCase  :			List[Any]	       =		[number]
							while number != 1:
														if number % 2 == 0:
																					_UpperCAmelCase  :			List[str]	       =		math.floor(math.sqrt(_SCREAMING_SNAKE_CASE  )  )
														else:
																					_UpperCAmelCase  :			Dict	       =		math.floor(
																					    math.sqrt(_SCREAMING_SNAKE_CASE  ) * math.sqrt(_SCREAMING_SNAKE_CASE  ) * math.sqrt(_SCREAMING_SNAKE_CASE  )  )
														sequence.append(_SCREAMING_SNAKE_CASE  )
							return sequence


if __name__ == "__main__":
				import doctest

				doctest.testmod()




