

from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
__a						:Union[str, 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 			__snake_case	(   __UpperCamelCase  :   int						):



      """simple docstring"""

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

def 			__snake_case	(   __UpperCamelCase  :   list[list[int]]							,__UpperCamelCase  :   list[int]							,__UpperCamelCase  :   int						):



      """simple docstring"""

      A_	     =							len(cells[0]						)  # 31
      A_	     =							[]
      for i in range(__UpperCamelCase						):
            # 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 			__snake_case	(   __UpperCamelCase  :   list[list[int]]						):



      """simple docstring"""

      A_	     =							Image.new("RGB"							,(len(cells[0]						), len(__UpperCamelCase						))						)
      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__":
      __a						:str            = bin(int(input('Rule:\n').strip()))[2:]
      __a						:List[Any]            = format_ruleset(int(rule_num))
      for time in range(16):
            CELLS.append(new_generation(CELLS, rule, time))
      __a						:str            = generate_image(CELLS)
      # Uncomment to save the image
      # img.save(f"rule_{rule_num}.png")
      img.show()


import pytest

from datasets.utils.version import Version

@pytest.mark.parametrize(
    "other, expected_equality"							,[
        (Version("1.0.0"						), True),
        ("1.0.0", True),
        (Version("2.0.0"						), False),
        ("2.0.0", False),
        ("1", False),
        ("a", False),
        (1, False),
        (None, False),
    ]							,)
def 			__snake_case	(   __UpperCamelCase  :   Any							,__UpperCamelCase  :   List[Any]						):



      """simple docstring"""

      A_	     =							Version("1.0.0"						)
      assert (version == other) is expected_equality
      assert (version != other) is not expected_equality
      assert (hash(__UpperCamelCase						) == hash(__UpperCamelCase						)) is expected_equality