santa_helpers package¶
Submodules¶
santa_helpers.distances module¶
santa_helpers.neighbors module¶
santa_helpers.parse module¶
santa_helpers.paths module¶
- santa_helpers.paths.get_direction(ch: str) Tuple[int, int] [source]¶
Coordinates point for direction
- Args:
ch: str - direction as a single letter UDLR or NEWS
- Returns:
tuple (x, y) - direction coordinates. E.g.:
N -> (0, 1) # north S -> (0, -1) # south L -> (-1, 0) # left
- Raises KeyError:
if direction char not in allowed directions.
- santa_helpers.paths.get_target_point(start: Tuple[int, int], steps: str) Tuple[int, int] [source]¶
Coordinates of target point based on start point and steps.
- Args:
start: tuple (x, y) - coordinates of the starting point. steps: string e.g U15 - contains direction (U D L R or N E S W)
and number of steps.
- Directions - two direction systems are possible:
- Relative orientations:
U - Up -> (0, 1) D - Down -> (0, -1) L - Left -> (-1, 0) R - Right -> (1, 0)
- Geographical directions:
N - North -> (0, 1) E - East -> (1, 0) S - South -> (0, -1) W - West -> (-1, 0)
- Returns:
tuple (x, y) - coordinates of the target point.
- santa_helpers.paths.path_points(start, steps)[source]¶
Generate coordinates of each path point based on start point and steps.
- Args:
start: tuple (x, y) - coordinates of the starting point. steps: string e.g U15 - contains direction (UDLR or NESW)
and number of steps.
- Directions - two direction systems are possible:
- Relative orientations:
U - Up -> (0, 1) D - Down -> (0, -1) L - Left -> (-1, 0) R - Right -> (1, 0)
- Geographical directions:
N - North -> (0, 1) E - East -> (1, 0) S - South -> (0, -1) W - West -> (-1, 0)
- Yields:
tuple (x, y) - point.
Module contents¶
Top-level package for santa-helpers.