


"""simple docstring"""







from math import factorial

a__    :							dict[str, int]            =					{str(digit): factorial(digit) for digit in range(1_0)}




def        UpperCAmelCase__	(lowerCAmelCase_       ):




					'''simple docstring'''


					if not isinstance(lowerCAmelCase_  ,						lowerCAmelCase_       ):
										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(lowerCAmelCase_       )       )




def        UpperCAmelCase__	(lowerCAmelCase_ = 60  ,						lowerCAmelCase_ = 100_0000       ):




					'''simple docstring'''


					if not isinstance(lowerCAmelCase_  ,						lowerCAmelCase_       ) or not isinstance(lowerCAmelCase_  ,						lowerCAmelCase_       ):
										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
					__SCREAMING_SNAKE_CASE						       =    0
					# the cached sizes of the previous chains
					__SCREAMING_SNAKE_CASE						       =    {}

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

										# Stop computing the chain when you find a cached size, a repeating item or the
										# length is greater then the desired one.
										__SCREAMING_SNAKE_CASE						       =    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(lowerCAmelCase_       )
															chain_set_length += 1
															__SCREAMING_SNAKE_CASE						       =    digit_factorial_sum(lowerCAmelCase_       )

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

										__SCREAMING_SNAKE_CASE						       =    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()}")




"""simple docstring"""







from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					return math.sqrt(sum(pow(a - b  ,						2       ) for a, b in zip(lowerCAmelCase_  ,						lowerCAmelCase_       )       )       )




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					if dataset.ndim != value_array.ndim:
										__SCREAMING_SNAKE_CASE						       =    (
										    "Wrong input data's dimensions... "
										    f"""dataset : {dataset.ndim}, value_array : {value_array.ndim}"""
										)
										raise ValueError(lowerCAmelCase_       )

					try:
										if dataset.shape[1] != value_array.shape[1]:
															__SCREAMING_SNAKE_CASE						       =    (
															    "Wrong input data's shape... "
															    f"""dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}"""
															)
															raise ValueError(lowerCAmelCase_       )
					except IndexError:
										if dataset.ndim != value_array.ndim:
															raise TypeError("Wrong shape"       )

					if dataset.dtype != value_array.dtype:
										__SCREAMING_SNAKE_CASE						       =    (
										    "Input data have different datatype... "
										    f"""dataset : {dataset.dtype}, value_array : {value_array.dtype}"""
										)
										raise TypeError(lowerCAmelCase_       )

					__SCREAMING_SNAKE_CASE						       =    []

					for value in value_array:
										__SCREAMING_SNAKE_CASE						       =    euclidean(lowerCAmelCase_  ,						dataset[0]       )
										__SCREAMING_SNAKE_CASE						       =    dataset[0].tolist()

										for dataset_value in dataset[1:]:
															__SCREAMING_SNAKE_CASE						       =    euclidean(lowerCAmelCase_  ,						lowerCAmelCase_       )

															if dist > temp_dist:
																				__SCREAMING_SNAKE_CASE						       =    temp_dist
																				__SCREAMING_SNAKE_CASE						       =    dataset_value.tolist()

										answer.append([vector, dist]       )

					return answer




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					return np.dot(lowerCAmelCase_  ,						lowerCAmelCase_       ) / (norm(lowerCAmelCase_       ) * norm(lowerCAmelCase_       ))


if __name__ == "__main__":
		import doctest

		doctest.testmod()
