
"""simple docstring"""

def 							A						(    snake_case				:list[list[int]]    , snake_case				:int    , snake_case				:int    , snake_case				:list[int]		)				->     bool:

 # 1. Validate that path exists between current and next vertices
 if graph[path[curr_ind - 1]][next_ver] == 0:
  return False

 # 2. Validate that next vertex is not already in path
 return not any(vertex == next_ver for vertex in path		)






def 							A						(    snake_case				:list[list[int]]    , snake_case				:list[int]    , snake_case				:int		)				->     bool:

 # Base Case
 if curr_ind == len(snake_case		):
  # return whether path exists between current and starting vertices
  return graph[path[curr_ind - 1]][path[0]] == 1

 # Recursive Step
 for next_ver in range(0    , len(snake_case		)		):
  if valid_connection(snake_case    , snake_case    , snake_case    , snake_case		):
   # Insert current vertex  into path as next transition
   __UpperCamelCase      =	next_ver
   # Validate created path
   if util_hamilton_cycle(snake_case    , snake_case    , curr_ind + 1		):
    return True
   # Backtrack
   __UpperCamelCase      =	-1
 return False






def 							A						(    snake_case				:list[list[int]]    , snake_case				:int = 0		)				->     list[int]:
 __UpperCamelCase      =	[-1] * (len(snake_case		) + 1)
 # initialize start and end of path with starting index
 __UpperCamelCase      =	__UpperCamelCase      =	start_index
 # evaluate and if we find answer return path either return empty array
 return path if util_hamilton_cycle(snake_case    , snake_case    , 1		) else []





"""simple docstring"""

def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 __UpperCamelCase      =	0
 while n > 0:
  res += n % 1_0
  n //= 1_0
 return res






def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 return n if n < 1_0 else n % 1_0 + sum_of_digits(n // 1_0		)






def 							A						(    snake_case				:int		)				->     int:
 return sum(int(snake_case		) for c in str(abs(snake_case		)		)		)






def 							A						(    )				->     None:
 from collections.abc import Callable
 from timeit import timeit

 def benchmark_a_function(snake_case				:Callable    , snake_case				:int		) -> None:
  __UpperCamelCase      =	f'{func.__name__}({value})'
  __UpperCamelCase      =	timeit(f'__main__.{call}'    , setup='import __main__'		)
  print(f'{call:56} = {func(snake_case		)} -- {timing:.4f} seconds'		)

 for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
  for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
   benchmark_a_function(snake_case    , snake_case		)
  print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()



