



'''simple docstring'''




def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__     ,__magic_name__						)->    bool:



			"""simple docstring"""



			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 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__						)->    bool:



			"""simple docstring"""



			if curr_ind == len(__magic_name__						):
						# 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(__magic_name__						)						):
						if valid_connection(__magic_name__     ,__magic_name__     ,__magic_name__     ,__magic_name__						):
									# Insert current vertex  into path as next transition
									snake_case_				:					int   =       next_ver
									# Validate created path
									if util_hamilton_cycle(__magic_name__     ,__magic_name__     ,curr_ind + 1						):
												return True
									# Backtrack
									snake_case_				:					Union[str, Any]   =       -1
			return False






def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__ = 0						)->    list[int]:



			"""simple docstring"""



			snake_case_				:					List[str]   =       [-1] * (len(__magic_name__						) + 1)
			# initialize start and end of path with starting index
			snake_case_				:					str   =       start_index
			# evaluate and if we find answer return path either return empty array
			return path if util_hamilton_cycle(__magic_name__     ,__magic_name__     ,1						) else []












'''simple docstring'''




def 	__UpperCAmelCase       ( __magic_name__						)->    list[int]:



			"""simple docstring"""



			if length <= 0 or not isinstance(__magic_name__     ,__magic_name__						):
						raise ValueError("Length must be a positive integer."						)
			return [n * (2 * n - 1) for n in range(__magic_name__						)]


if __name__ == "__main__":
		print(hexagonal_numbers(length=5))
		print(hexagonal_numbers(length=10))




