




from __future__ import annotations

from collections.abc import Iterable







class  UpperCAmelCase:



	"""simple docstring"""






	def __init__(					self	,				lowerCamelCase	,				lowerCamelCase    ) ->      Union[str, Any]:





								"""simple docstring"""


								lowercase__  :	List[str]        =							float(lowercase_    ), float(lowercase_    )

	def __eq__(					self	,				lowerCamelCase    ) ->      Optional[Any]:





								"""simple docstring"""


								return self.x == other.x and self.y == other.y

	def __ne__(					self	,				lowerCamelCase    ) ->      Tuple:





								"""simple docstring"""


								return not self == other

	def __gt__(					self	,				lowerCamelCase    ) ->      Dict:





								"""simple docstring"""


								if self.x > other.x:
															return True
								elif self.x == other.x:
															return self.y > other.y
								return False

	def __lt__(					self	,				lowerCamelCase    ) ->      Optional[Any]:





								"""simple docstring"""


								return not self > other

	def __ge__(					self	,				lowerCamelCase    ) ->      Optional[int]:





								"""simple docstring"""


								if self.x > other.x:
															return True
								elif self.x == other.x:
															return self.y >= other.y
								return False

	def __le__(					self	,				lowerCamelCase    ) ->      Dict:





								"""simple docstring"""


								if self.x < other.x:
															return True
								elif self.x == other.x:
															return self.y <= other.y
								return False

	def __repr__(					self    ) ->      str:





								"""simple docstring"""


								return f"""({self.x}, {self.y})"""







	def __hash__(					self    ) ->      List[str]:





								"""simple docstring"""


								return hash(self.x    )

def  snake_case_					(		SCREAMING_SNAKE_CASE_    ,)      ->			List[str]:
							lowercase__  :	list[Point]        =							[]
							if list_of_tuples:
														for p in list_of_tuples:
																					if isinstance(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ):
																												points.append(SCREAMING_SNAKE_CASE__    )
																					else:
																												try:
																																			points.append(Point(p[0]    ,p[1]    )    )
																												except (IndexError, TypeError):
																																			print(
																																			    F"""Ignoring deformed point {p}. All points"""
																																			    " must have at least 2 coordinates."    )
							return points
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			str:





							if not hasattr(SCREAMING_SNAKE_CASE__    ,"__iter__"    ):
														lowercase__  :	Optional[int]        =							F"""Expecting an iterable object but got an non-iterable type {points}"""
														raise ValueError(SCREAMING_SNAKE_CASE__    )

							if not points:
														lowercase__  :	Dict        =							F"""Expecting a list of points but got {points}"""
														raise ValueError(SCREAMING_SNAKE_CASE__    )

							return _construct_points(SCREAMING_SNAKE_CASE__    )
def  snake_case_					(		SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    )      ->			Any:
							lowercase__  :	Optional[Any]        =							(a.x * b.y + b.x * c.y + c.x * a.y) - (a.y * b.x + b.y * c.x + c.y * a.x)
							return det
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			Dict:
							lowercase__  :	Dict        =							sorted(_validate_input(SCREAMING_SNAKE_CASE__    )    )
							lowercase__  :	Tuple        =							len(SCREAMING_SNAKE_CASE__    )
							lowercase__  :	List[str]        =							set()

							for i in range(n - 1    ):
														for j in range(i + 1    ,SCREAMING_SNAKE_CASE__    ):
																					lowercase__  :	List[str]        =							False
																					lowercase__  :	Any        =							True
																					for k in range(SCREAMING_SNAKE_CASE__    ):
																												if k != i and k != j:
																																			lowercase__  :	Optional[int]        =							_det(points[i]    ,points[j]    ,points[k]    )

																																			if det_k > 0:
																																										lowercase__  :	Any        =							True
																																			elif det_k < 0:
																																										lowercase__  :	Optional[Any]        =							True
																																			else:
																																										# point[i], point[j], point[k] all lie on a straight line
																																										# if point[k] is to the left of point[i] or it's to the
																																										# right of point[j], then point[i], point[j] cannot be
																																										# part of the convex hull of A
																																										if points[k] < points[i] or points[k] > points[j]:
																																																	lowercase__  :	Tuple        =							False
																																																	break

																												if points_left_of_ij and points_right_of_ij:
																																			lowercase__  :	int        =							False
																																			break

																					if ij_part_of_convex_hull:
																												convex_set.update([points[i], points[j]]    )

							return sorted(SCREAMING_SNAKE_CASE__    )
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			Optional[int]:
							lowercase__  :	Any        =							sorted(_validate_input(SCREAMING_SNAKE_CASE__    )    )
							lowercase__  :	str        =							len(SCREAMING_SNAKE_CASE__    )

							# divide all the points into an upper hull and a lower hull
							# the left most point and the right most point are definitely
							# members of the convex hull by definition.
							# use these two anchors to divide all the points into two hulls,
							# an upper hull and a lower hull.

							# all points to the left (above) the line joining the extreme points belong to the
							# upper hull
							# all points to the right (below) the line joining the extreme points below to the
							# lower hull
							# ignore all points on the line joining the extreme points since they cannot be
							# part of the convex hull

							lowercase__  :	Tuple        =							points[0]
							lowercase__  :	Tuple        =							points[n - 1]

							lowercase__  :	Union[str, Any]        =							{left_most_point, right_most_point}
							lowercase__  :	List[Any]        =							[]
							lowercase__  :	Optional[int]        =							[]

							for i in range(1    ,n - 1    ):
														lowercase__  :	int        =							_det(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,points[i]    )

														if det > 0:
																					upper_hull.append(points[i]    )
														elif det < 0:
																					lower_hull.append(points[i]    )

							_construct_hull(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    )
							_construct_hull(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    )

							return sorted(SCREAMING_SNAKE_CASE__    )
def  snake_case_					(		SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    )      ->			Any:





							if points:
														lowercase__  :	Any        =							None
														lowercase__  :	int        =							float("-inf"    )
														lowercase__  :	Any        =							[]

														for p in points:
																					lowercase__  :	int        =							_det(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    )

																					if det > 0:
																												candidate_points.append(SCREAMING_SNAKE_CASE__    )

																												if det > extreme_point_distance:
																																			lowercase__  :	Optional[Any]        =							det
																																			lowercase__  :	List[str]        =							p

														if extreme_point:
																					_construct_hull(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    )
																					convex_set.add(SCREAMING_SNAKE_CASE__    )
																					_construct_hull(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    )
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			Any:
							lowercase__  :	int        =							sorted(_validate_input(SCREAMING_SNAKE_CASE__    )    )
							lowercase__  :	Tuple        =							len(SCREAMING_SNAKE_CASE__    )

							lowercase__  :	Tuple        =							points[:2]
							for i in range(2    ,SCREAMING_SNAKE_CASE__    ):
														lowercase__  :	Optional[Any]        =							_det(convex_hull[1]    ,convex_hull[0]    ,points[i]    )
														if det > 0:
																					convex_hull.insert(0    ,points[i]    )
																					break
														elif det < 0:
																					convex_hull.append(points[i]    )
																					break
														else:
																					lowercase__  :	Dict        =							points[i]
							i += 1

							for j in range(SCREAMING_SNAKE_CASE__    ,SCREAMING_SNAKE_CASE__    ):
														if (
														    _det(convex_hull[0]    ,convex_hull[-1]    ,points[j]    ) > 0
														    and _det(convex_hull[-1]    ,convex_hull[0]    ,points[1]    ) < 0
														):
																					# The point lies within the convex hull
																					continue

														convex_hull.insert(0    ,points[j]    )
														convex_hull.append(points[j]    )
														while _det(convex_hull[0]    ,convex_hull[1]    ,convex_hull[2]    ) >= 0:
																					del convex_hull[1]
														while _det(convex_hull[-1]    ,convex_hull[-2]    ,convex_hull[-3]    ) <= 0:
																					del convex_hull[-2]

    # `convex_hull` is contains the convex hull in circular order
							return sorted(convex_hull[1:] if len(SCREAMING_SNAKE_CASE__    ) > 3 else convex_hull    )
def  snake_case_					(		)      ->			List[Any]:
							lowercase__  :	Union[str, Any]        =							[
							    (0, 3),
							    (2, 2),
							    (1, 1),
							    (2, 1),
							    (3, 0),
							    (0, 0),
							    (3, 3),
							    (2, -1),
							    (2, -4),
							    (1, -3),
							]
							# the convex set of points is
							# [(0, 0), (0, 3), (1, -3), (2, -4), (3, 0), (3, 3)]
							lowercase__  :	List[Any]        =							convex_hull_bf(SCREAMING_SNAKE_CASE__    )

							lowercase__  :	Dict        =							convex_hull_recursive(SCREAMING_SNAKE_CASE__    )
							assert results_bf == results_recursive

							lowercase__  :	int        =							convex_hull_melkman(SCREAMING_SNAKE_CASE__    )
							assert results_bf == results_melkman

							print(SCREAMING_SNAKE_CASE__    )


if __name__ == "__main__":
						main()





import hashlib
import importlib.util
import json
import os
import pathlib
from types import ModuleType

import pytest
import requests

__a  :		str		     =   pathlib.Path.cwd().joinpath('''project_euler''')
__a  :		Tuple		     =   pathlib.Path.cwd().joinpath(
    '''scripts''', '''project_euler_answers.json'''
)

with open(PROJECT_EULER_ANSWERS_PATH) as file_handle:
						__a  :		dict[str, str]		     =   json.load(file_handle)
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			ModuleType:
							lowercase__  :	List[str]        =							importlib.util.spec_from_file_location(file_path.name    ,str(SCREAMING_SNAKE_CASE_    )    )
							lowercase__  :	int        =							importlib.util.module_from_spec(SCREAMING_SNAKE_CASE_    )  # type: ignore
							spec.loader.exec_module(SCREAMING_SNAKE_CASE_    )  # type: ignore
							return module
def  snake_case_					(		)      ->			list[pathlib.Path]:
							lowercase__  :	List[str]        =							[]
							for problem_dir_path in PROJECT_EULER_DIR_PATH.iterdir():
														if problem_dir_path.is_file() or problem_dir_path.name.startswith("_"    ):
																					continue
														for file_path in problem_dir_path.iterdir():
																					if file_path.suffix != ".py" or file_path.name.startswith(("_", "test")    ):
																												continue
																					solution_file_paths.append(SCREAMING_SNAKE_CASE_    )
							return solution_file_paths
def  snake_case_					(		)      ->			str:
							with open(os.environ["GITHUB_EVENT_PATH"]    ) as file:
														lowercase__  :	str        =							json.load(SCREAMING_SNAKE_CASE_    )
							return event["pull_request"]["url"] + "/files"
def  snake_case_					(		)      ->			list[pathlib.Path]:
							lowercase__  :	Optional[Any]        =							[]
							lowercase__  :	Dict        =							{
							    "Accept": "application/vnd.github.v3+json",
							    "Authorization": "token " + os.environ["GITHUB_TOKEN"],
							}
							lowercase__  :	Union[str, Any]        =							requests.get(get_files_url()    ,headers=SCREAMING_SNAKE_CASE_    ).json()
							for file in files:
														lowercase__  :	Optional[Any]        =							pathlib.Path.cwd().joinpath(file["filename"]    )
														if (
														    filepath.suffix != ".py"
														    or filepath.name.startswith(("_", "test")    )
														    or not filepath.name.startswith("sol"    )
														):
																					continue
														solution_file_paths.append(SCREAMING_SNAKE_CASE_    )
							return solution_file_paths
def  snake_case_					(		)      ->			list[pathlib.Path]:
							if os.environ.get("CI"    ) and os.environ.get("GITHUB_EVENT_NAME"    ) == "pull_request":
														# Return only if there are any, otherwise default to all solutions
														if filepaths := added_solution_file_path():
																					return filepaths
							return all_solution_file_paths()




@pytest.mark.parametrize(
    "solution_path"    ,collect_solution_file_paths()    ,ids=lambda SCREAMING_SNAKE_CASE_    : F"""{path.parent.name}/{path.name}"""    ,)
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			None:
							lowercase__  :	str        =							solution_path.parent.name[8:].zfill(3    )
							lowercase__  :	str        =							PROBLEM_ANSWERS[problem_number]
							lowercase__  :	Optional[Any]        =							convert_path_to_module(SCREAMING_SNAKE_CASE_    )
							lowercase__  :	str        =							str(solution_module.solution()    )  # type: ignore
							lowercase__  :	List[str]        =							hashlib.shaaaa(answer.encode()    ).hexdigest()
							assert (
							    answer == expected
							), F"""Expected solution to {problem_number} to have hash {expected}, got {answer}"""