






from math import factorial

__a      :       dict[str, int]				  =   {str(digit): factorial(digit) for digit in range(10)}



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			int    )						->      int:





    """simple docstring"""

    if not isinstance(__lowercase			,				__lowercase    ):
        raise TypeError("""Parameter number must be int"""    )

    if number < 0:
        raise ValueError("""Parameter number must be greater than or equal to 0"""    )

    # Converts number in string to iterate on its digits and adds its factorial.
    return sum(DIGIT_FACTORIAL[digit] for digit in str(__lowercase    )    )



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			int = 6_0			,				__lowercase   :			int = 1_0_0_0_0_0_0    )						->      int:





    """simple docstring"""

    if not isinstance(__lowercase			,				__lowercase    ) or not isinstance(__lowercase			,				__lowercase    ):
        raise TypeError("""Parameters chain_length and number_limit must be int"""    )

    if chain_length <= 0 or number_limit <= 0:
        raise ValueError(
            """Parameters chain_length and number_limit must be greater than 0"""    )

    # the counter for the chains with the exact desired length
    __A         =	0
    # the cached sizes of the previous chains
    __A         =	{}

    for start_chain_element in range(1			,				__lowercase    ):
        # The temporary set will contain the elements of the chain
        __A         =	set()
        __A         =	0

        # Stop computing the chain when you find a cached size, a repeating item or the
        # length is greater then the desired one.
        __A         =	start_chain_element
        while (
            chain_element not in chain_sets_lengths
            and chain_element not in chain_set
            and chain_set_length <= chain_length
        ):
            chain_set.add(__lowercase    )
            chain_set_length += 1
            __A         =	digit_factorial_sum(__lowercase    )

        if chain_element in chain_sets_lengths:
            chain_set_length += chain_sets_lengths[chain_element]

        __A         =	chain_set_length

        # If chain contains the exact amount of elements increase the counter
        if chain_set_length == chain_length:
            chains_counter += 1

    return chains_counter


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  print(f"""{solution()}""")












import random
import sys

import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap

__a      :       List[Any]				  =   "Usage of script: script_name <size_of_canvas:int>"

__a      :       Dict				  =   [0] * 100 + [1] * 10
random.shuffle(choice)



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			int    )						->      list[list[bool]]:





    """simple docstring"""

    __A         =	[[False for i in range(__lowercase    )] for j in range(__lowercase    )]
    return canvas



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			list[list[bool]]    )						->      None:





    """simple docstring"""

    for i, row in enumerate(__lowercase    ):
        for j, _ in enumerate(__lowercase    ):
            __A         =	bool(random.getrandbits(1    )    )



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			list[list[bool]]    )						->      list[list[bool]]:





    """simple docstring"""

    __A         =	np.array(__lowercase    )
    __A         =	np.array(create_canvas(current_canvas.shape[0]    )    )
    for r, row in enumerate(__lowercase    ):
        for c, pt in enumerate(__lowercase    ):
            __A         =	__judge_point(
                __lowercase			,				current_canvas[r - 1 : r + 2, c - 1 : c + 2]    )

    __A         =	next_gen_canvas
    del next_gen_canvas  # cleaning memory as we move on.
    __A         =	current_canvas.tolist()
    return return_canvas



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			bool			,				__lowercase   :			list[list[bool]]    )						->      bool:





    """simple docstring"""

    __A         =	0
    __A         =	0
    # finding dead or alive neighbours count.
    for i in neighbours:
        for status in i:
            if status:
                alive += 1
            else:
                dead += 1

    # handling duplicate entry for focus pt.
    if pt:
        alive -= 1
    else:
        dead -= 1

    # running the rules of game here.
    __A         =	pt
    if pt:
        if alive < 2:
            __A         =	False
        elif alive == 2 or alive == 3:
            __A         =	True
        elif alive > 3:
            __A         =	False
    else:
        if alive == 3:
            __A         =	True

    return state


if __name__ == "__main__":
  if len(sys.argv) != 2:
    raise Exception(usage_doc)

  __a      :       str				  =   int(sys.argv[1])
  # main working structure of this module.
  __a      :       List[Any]				  =   create_canvas(canvas_size)
  seed(c)
  __a  ,__a      :       int				  =   plt.subplots()
  fig.show()
  __a      :       Union[str, Any]				  =   ListedColormap(["w", "k"])
  try:
    while True:
      __a      :       Dict				  =   run(c)
      ax.matshow(c, cmap=cmap)
      fig.canvas.draw()
      ax.cla()
  except KeyboardInterrupt:
    # do nothing.
    pass




