day21 package

Subpackages

Submodules

day21.day21 module

day21 solution.

class day21.day21.SmartSteps(boards_to_edge: int, steps: int)[source]

Bases: object

How many boards to edge of solution, and steps to simulate.

boards_to_edge: int
steps: int
day21.day21.calculate_smart_steps(board_size: int, steps: int) SmartSteps[source]

Given a board size and num steps, calculate how many steps we actually need.

day21.day21.main() None[source]

Load data then solve part1/part2.

day21.day21.mini_solve(start_pos: Position, maze: Maze, steps: int, distances: BaseDistanceMaze) BaseDistanceMaze[source]

Given a BaseDistanceMaze, runs steps steps then returns the maze.

day21.day21.naive_solve(start_pos: Position, maze: Maze, steps: int, distances: BaseDistanceMaze) int[source]

Naively solve a maze.

day21.day21.solve(start_pos: Position, maze: Maze, steps: int, unlimited_map: bool = False, brute_force: bool = False) int[source]

Solve the maze.

Parameters:
  • start_pos (Position) – start position

  • maze (Maze) – maze to solve

  • steps (int) – number of steps

  • unlimited_map (bool, optional) – whether the map is infinite (Default=False)

  • brute_force (bool, optional) – Whether to brute force. (Defaults=False).

Returns:

number of valid positions.

Return type:

int

Module contents

Day21 solution.