
from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
_SCREAMING_SNAKE_CASE     :   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 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    int							)			->							Any:

				"""simple docstring"""







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

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    Union[str, Any]				,    __UpperCamelCase			:    List[str]				,    __UpperCamelCase			:    Optional[int]							)			->							List[str]:

				"""simple docstring"""







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

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    Optional[Any]							)			->							int:

				"""simple docstring"""







				A__	:						Tuple								=				Image.new('''RGB'''				,    (len(cells[0]							), len(__UpperCamelCase							))							)
				A__	:						Optional[Any]								=				img.load()
				# Generates image
				for w in range(img.width							):
								for h in range(img.height							):
												A__	:						Union[str, Any]								=				2_55 - int(2_55 * cells[h][w]							)
												A__	:						int								=				(color, color, color)
				return img


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







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    a__    (	A       ):
   return [int(A       ) for c in F'''{ruleset:08}'''[:8]]
def    a__    (	A		,					A		,					A       ):
   lowercase__    :						List[Any]       =			len(cells[0]       )  # 31
   lowercase__    :						int       =			[]
   for i in range(A       ):
      # Get the neighbors of each cell
      # Handle neighbours outside bounds by using 0 as their value
      lowercase__    :						Optional[Any]       =			0 if i == 0 else cells[time][i - 1]
      lowercase__    :						Dict       =			0 if i == population - 1 else cells[time][i + 1]
      # Define a new cell and add it to the new generation
      lowercase__    :						str       =			7 - int(F'''{left_neighbor}{cells[time][i]}{right_neighbor}'''		,					2       )
      next_generation.append(rule[situation]       )
   return next_generation
def    a__    (	A       ):
   lowercase__    :						Tuple       =			Image.new("""RGB"""		,					(len(cells[0]       ), len(A       ))       )
   lowercase__    :						Optional[Any]       =			img.load()
   # Generates image
   for w in range(img.width       ):
      for h in range(img.height       ):
         lowercase__    :						Union[str, Any]       =			255 - int(255 * cells[h][w]       )
         lowercase__    :						int       =			(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()


