



'''simple docstring'''






from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
UpperCamelCase__:       int							     =      [[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_					( _lowerCAmelCase  :						int  )				->       list[int]:
							return [int(_lowerCAmelCase  ) for c in f"""{ruleset:08}"""[:8]]


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


def 			snake_case_					( _lowerCAmelCase  :						list[list[int]]  )				->       Image.Image:
							UpperCAmelCase			:	Any										=		Image.new('''RGB'''       ,				(len(cells[0]  ), len(_lowerCAmelCase  ))  )
							UpperCAmelCase			:	Dict										=		img.load()
							# Generates image
							for w in range(img.width  ):
														for h in range(img.height  ):
																					UpperCAmelCase			:	List[Any]										=		255 - int(255 * cells[h][w]  )
																					UpperCAmelCase			:	Optional[int]										=		(color, color, color)
							return img


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










'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


UpperCamelCase__:       Tuple							     =      {
    "configuration_splinter": ["SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SplinterConfig"],
    "tokenization_splinter": ["SplinterTokenizer"],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Optional[Any]							     =      ["SplinterTokenizerFast"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase__:       Any							     =      [
						    "SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "SplinterForQuestionAnswering",
						    "SplinterForPreTraining",
						    "SplinterLayer",
						    "SplinterModel",
						    "SplinterPreTrainedModel",
						]


if TYPE_CHECKING:
						from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
						from .tokenization_splinter import SplinterTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_splinter_fast import SplinterTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_splinter import (
												    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
												    SplinterForPreTraining,
												    SplinterForQuestionAnswering,
												    SplinterLayer,
												    SplinterModel,
												    SplinterPreTrainedModel,
												)


else:
						import sys

						UpperCamelCase__:       Dict							     =      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





