
'''simple docstring'''

from __future__ import annotations

from collections.abc import Callable







def __A  (    lowerCAmelCase_ ,       lowerCAmelCase_ ,       lowerCAmelCase_ ,       lowerCAmelCase_ = 100 ,       ):
     _UpperCAmelCase					:  Dict         =    x_start
     _UpperCAmelCase					:  Dict         =    fnc(lowerCAmelCase_       )
     _UpperCAmelCase					:  Optional[Any]         =    0.0

     for _ in range(lowerCAmelCase_       ):
          # Approximates small segments of curve as linear and solve
          # for trapezoidal area
          _UpperCAmelCase					:  List[Any]         =    (x_end - x_start) / steps + xa
          _UpperCAmelCase					:  List[Any]         =    fnc(lowerCAmelCase_       )
          area += abs(fxa + fxa       ) * (xa - xa) / 2

          # Increment step
          _UpperCAmelCase					:  Optional[Any]         =    xa
          _UpperCAmelCase					:  Optional[int]         =    fxa
     return area


if __name__ == "__main__":







   def __A  (    lowerCAmelCase_       ):
        return x**3

   print('''f(x) = x^3''')
   print('''The area between the curve, x = -10, x = 10 and the x axis is:''')
   lowerCAmelCase_			:			Tuple			   =     10
   while i <= 100000:
      lowerCAmelCase_			:			List[str]			   =     trapezoidal_area(f, -5, 5, i)
      print(F"with {i} steps: {area}")
      i *= 10




'''simple docstring'''
from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
lowerCAmelCase :  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 						A_(			A		:						int):
							return [int(A) for c in f'''{ruleset:08}'''[:8]]







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







def 						A_(			A		:						list[list[int]]):
							UpperCamelCase					       =			Image.new('RGB'						,			(len(cells[0]), len(A)))
							UpperCamelCase					       =			img.load()
							# Generates image
							for w in range(img.width):
														for h in range(img.height):
																					UpperCamelCase					       =			255 - int(255 * cells[h][w])
																					UpperCamelCase					       =			(color, color, color)
							return img


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




