



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 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case      ,		snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       len(cells[0]     )  # 31
					_lowerCAmelCase         =       []
					for i in range(snake_case     ):
										# 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 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

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





'''simple docstring'''





import os
import unittest

import pytest
from parameterized import parameterized

from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device


# skipping in unittest tests

a__		: Tuple  							=							[(1,)]





def 							snake_case				(		)->      Union[str, Any]:







      """simple docstring"""
      __A													=      bool(os.getenv('RUN_SLOW'   ,	0						)						)
      if run_slow:
            assert True
      else:
            assert False, "should have been skipped"





def 							snake_case				(		)->      Tuple:







      """simple docstring"""
      __A													=      bool(os.getenv('RUN_SLOW'   ,	0						)						)
      if run_slow and torch_device == "cuda":
            assert True
      else:
            assert False, "should have been skipped"


@require_torch
class 			UpperCamelCase__	(     unittest.TestCase):






 @slow
 @require_torch_gpu
 def 						lowercase_    (      self	:Dict      )					->      List[Any]:







       '''simple docstring'''



       check_slow_torch_cuda()






 @require_torch_gpu
 @slow
 def 						lowercase_    (      self	:int      )					->      int:







       '''simple docstring'''



       check_slow_torch_cuda()






 @parameterized.expand(_A      )
 @slow
 def 						lowercase_    (      self	:Dict						,					_A	:Union[str, Any]=None      )					->      Dict:







       '''simple docstring'''



       check_slow()





@slow
@require_torch_gpu
def 							snake_case				(		)->      Optional[int]:







      """simple docstring"""
      check_slow_torch_cuda()





@require_torch_gpu
@slow
def 							snake_case				(		)->      List[str]:







      """simple docstring"""
      check_slow_torch_cuda()





@slow
@pytest.mark.parametrize('param'   ,	[1]						)
def 							snake_case				(		UpperCAmelCase						)->      int:







      """simple docstring"""
      check_slow()





@pytest.mark.parametrize('param'   ,	[1]						)
@slow
def 							snake_case				(		UpperCAmelCase						)->      Any:







      """simple docstring"""
      check_slow()






