
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        lowerCamelCase__    (    __lowerCAmelCase  :  int    ):




			"""simple docstring"""


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






def        lowerCamelCase__    (    __lowerCAmelCase  :  list[list[int]]   ,							__lowerCAmelCase  :  list[int]   ,							__lowerCAmelCase  :  int    ):




			"""simple docstring"""


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






def        lowerCamelCase__    (    __lowerCAmelCase  :  list[list[int]]    ):




			"""simple docstring"""


			lowerCAmelCase_      =     Image.new("RGB"   ,							(len(cells[0]    ), len(__lowerCAmelCase    ))    )
			lowerCAmelCase_      =     img.load()
			# Generates image
			for w in range(img.width    ):
						for h in range(img.height    ):
									lowerCAmelCase_      =     255 - int(255 * cells[h][w]    )
									lowerCAmelCase_      =     (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()





import math






def        lowerCamelCase__    (    __lowerCAmelCase  :  int    ):




			"""simple docstring"""


			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5   ,							int(math.sqrt(__lowerCAmelCase    ) + 1    )   ,							6    ):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True






def        lowerCamelCase__    (    __lowerCAmelCase  :  int = 600851475143    ):




			"""simple docstring"""


			try:
						lowerCAmelCase_      =     int(__lowerCAmelCase    )
			except (TypeError, ValueError):
						raise TypeError("Parameter n must be int or castable to int."    )
			if n <= 0:
						raise ValueError("Parameter n must be greater than or equal to one."    )
			lowerCAmelCase_      =     0
			if is_prime(__lowerCAmelCase    ):
						return n
			while n % 2 == 0:
						n //= 2
			if is_prime(__lowerCAmelCase    ):
						return n
			for i in range(3   ,							int(math.sqrt(__lowerCAmelCase    )    ) + 1   ,							2    ):
						if n % i == 0:
									if is_prime(n // i    ):
												lowerCAmelCase_      =     n // i
												break
									elif is_prime(__lowerCAmelCase    ):
												lowerCAmelCase_      =     i
			return max_number


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



