
'''simple docstring'''







from __future__ import annotations

from PIL import Image

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







       '''simple docstring'''






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







def   lowerCAmelCase(  a__    :  list[list[int]]      , a__    :  list[int]      , a__    :  int      ):







       '''simple docstring'''






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







       '''simple docstring'''






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



'''simple docstring'''







from ..utils import DummyObject, requires_backends







class 		snake_case_       (						metaclass=A__						):



   """simple docstring"""





   __lowerCAmelCase	:							List[str]								=['''torch''', '''librosa''']







   def __init__( self			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(self			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







class 		snake_case_       (						metaclass=A__						):



   """simple docstring"""





   __lowerCAmelCase	:							Union[str, Any]								=['''torch''', '''librosa''']







   def __init__( self			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(self			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])

