


"""simple docstring"""



from __future__ import annotations

import math







def 						__lowerCAmelCase		(		lowercase						:						int				)			->		bool:


    """simple docstring"""





    if 1 < number < 4:
        # 2 and 3 are primes
        return True
    elif number < 2 or number % 2 == 0 or number % 3 == 0:
        # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
        return False

    # All primes number are in format of 6k +/- 1
    for i in range(5		,							int(math.sqrt(lowercase				) + 1				)		,							6				):
        if number % i == 0 or number % (i + 2) == 0:
            return False
    return True







def 						__lowerCAmelCase		(		lowercase						:						int				)			->		list[int]:


    """simple docstring"""





    snake_case					:   Any         =					str(lowercase				)
    snake_case					:   Tuple         =					[n]
    for i in range(1		,							len(lowercase				)				):
        list_nums.append(int(str_num[i:]				)				)
        list_nums.append(int(str_num[:-i]				)				)
    return list_nums







def 						__lowerCAmelCase		(		lowercase						:						int				)			->		bool:


    """simple docstring"""





    if len(str(lowercase				)				) > 3:
        if not is_prime(int(str(lowercase				)[-3:]				)				) or not is_prime(int(str(lowercase				)[:3]				)				):
            return False
    return True







def 						__lowerCAmelCase		(		lowercase						:						int = 11				)			->		list[int]:


    """simple docstring"""





    snake_case					:   list[int]         =					[]
    snake_case					:   Dict         =					13
    while len(lowercase				) != count:
        if validate(lowercase				):
            snake_case					:   Optional[int]         =					list_truncated_nums(lowercase				)
            if all(is_prime(lowercase				) for i in list_nums				):
                list_truncated_primes.append(lowercase				)
        num += 2
    return list_truncated_primes







def 						__lowerCAmelCase		(		)			->		int:


    """simple docstring"""





    return sum(compute_truncated_primes(11				)				)


if __name__ == "__main__":
  print(F'''{sum(compute_truncated_primes(11)) = }''')









"""simple docstring"""



from typing import Any







def 						__lowerCAmelCase		(		lowercase						:						list		,							lowercase						:						list		,							lowercase						:						dict		,							lowercase						:						dict		,							lowercase						:						dict		,							)			->		list:


    """simple docstring"""





    _validation(
        lowercase		,							lowercase		,							lowercase		,							lowercase		,							lowercase		,							)
    # Creates data structures and fill initial step
    snake_case					:   dict         =					{}
    snake_case					:   dict         =					{}
    for state in states_space:
        snake_case					:   int         =					observations_space[0]
        snake_case					:   Any         =					(
            initial_probabilities[state] * emission_probabilities[state][observation]
        )
        snake_case					:   Union[str, Any]         =					None

    # Fills the data structure with the probabilities of
    # different transitions and pointers to previous states
    for o in range(1		,							len(lowercase				)				):
        snake_case					:   Optional[Any]         =					observations_space[o]
        snake_case					:   str         =					observations_space[o - 1]
        for state in states_space:
            # Calculates the argmax for probability function
            snake_case					:   str         =					""
            snake_case					:   List[Any]         =					-1
            for k_state in states_space:
                snake_case					:   Tuple         =					(
                    probabilities[(k_state, prior_observation)]
                    * transition_probabilities[k_state][state]
                    * emission_probabilities[state][observation]
                )
                if probability > max_probability:
                    snake_case					:   Optional[Any]         =					probability
                    snake_case					:   int         =					k_state

            # Update probabilities and pointers dicts
            snake_case					:   List[str]         =					(
                probabilities[(arg_max, prior_observation)]
                * transition_probabilities[arg_max][state]
                * emission_probabilities[state][observation]
            )

            snake_case					:   List[Any]         =					arg_max

    # The final observation
    snake_case					:   Dict         =					observations_space[len(lowercase				) - 1]

    # argmax for given final observation
    snake_case					:   str         =					""
    snake_case					:   Optional[int]         =					-1
    for k_state in states_space:
        snake_case					:   int         =					probabilities[(k_state, final_observation)]
        if probability > max_probability:
            snake_case					:   Optional[int]         =					probability
            snake_case					:   List[Any]         =					k_state
    snake_case					:   str         =					arg_max

    # Process pointers backwards
    snake_case					:   List[str]         =					last_state
    snake_case					:   Optional[int]         =					[]
    for o in range(len(lowercase				) - 1		,							-1		,							-1				):
        result.append(lowercase				)
        snake_case					:   List[str]         =					pointers[previous, observations_space[o]]
    result.reverse()

    return result







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							)			->		None:


    """simple docstring"""





    _validate_not_empty(
        lowercase		,							lowercase		,							lowercase		,							lowercase		,							lowercase		,							)
    _validate_lists(lowercase		,							lowercase				)
    _validate_dicts(
        lowercase		,							lowercase		,							lowercase				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							)			->		None:


    """simple docstring"""





    if not all(
        [
            observations_space,
            states_space,
            initial_probabilities,
            transition_probabilities,
            emission_probabilities,
        ]				):
        raise ValueError("There's an empty parameter"				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						Any				)			->		None:


    """simple docstring"""





    _validate_list(lowercase		,							"observations_space"				)
    _validate_list(lowercase		,							"states_space"				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						str				)			->		None:


    """simple docstring"""





    if not isinstance(_object		,							lowercase				):
        snake_case					:   List[str]         =					F'{var_name} must be a list'
        raise ValueError(lowercase				)
    else:
        for x in _object:
            if not isinstance(lowercase		,							lowercase				):
                snake_case					:   Tuple         =					F'{var_name} must be a list of strings'
                raise ValueError(lowercase				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						Any		,							lowercase						:						Any		,							)			->		None:


    """simple docstring"""





    _validate_dict(lowercase		,							"initial_probabilities"		,							lowercase				)
    _validate_nested_dict(lowercase		,							"transition_probabilities"				)
    _validate_nested_dict(lowercase		,							"emission_probabilities"				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						str				)			->		None:


    """simple docstring"""





    _validate_dict(_object		,							lowercase		,							lowercase				)
    for x in _object.values():
        _validate_dict(lowercase		,							lowercase		,							lowercase		,							lowercase				)







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						str		,							lowercase						:						type		,							lowercase						:						bool = False				)			->		None:


    """simple docstring"""





    if not isinstance(_object		,							lowercase				):
        snake_case					:   int         =					F'{var_name} must be a dict'
        raise ValueError(lowercase				)
    if not all(isinstance(lowercase		,							lowercase				) for x in _object				):
        snake_case					:   Optional[Any]         =					F'{var_name} all keys must be strings'
        raise ValueError(lowercase				)
    if not all(isinstance(lowercase		,							lowercase				) for x in _object.values()				):
        snake_case					:   Optional[int]         =					"nested dictionary " if nested else ""
        snake_case					:   int         =					F'{var_name} {nested_text}all values must be {value_type.__name__}'
        raise ValueError(lowercase				)


if __name__ == "__main__":
  from doctest import testmod

  testmod()





