day08 package

Subpackages

Submodules

day08.day8 module

day8 solution.

class day08.day8.Cycle(start_location: Location, location_steps: list[LocationStep], cycle_start: LocationStep)[source]

Bases: object

Find a cycle.

property cycle_length: int

Return length of the repeating part.

cycle_start: LocationStep
cycle_start_index: int
end_zs: list[int]
get_location(index: int) LocationStep[source]

Gets a location given a step index.

location_steps: list[LocationStep]
start_location: Location
class day08.day8.Directions(steps: str)[source]

Bases: object

Simple directions string.

get_step(index: int) str[source]

Returns a step given its index.

get_steps_iterator() Iterator[str][source]

Returns a iterator that loops through indefinitely.

steps: str
class day08.day8.Location(name: str, left: str, right: str)[source]

Bases: object

A location on our map, with names of other locations.

left: str
name: str
right: str
class day08.day8.LocationStep(location: Location, steps: int)[source]

Bases: object

Location + how many steps to get here.

location: Location
steps: int
class day08.day8.WorldMap[source]

Bases: object

world map class.

add_location(location: Location) None[source]

Add location to our mappings.

mappings: dict[str, Location]
day08.day8.find_cycle(location: Location, world_map: WorldMap, directions: Directions) Cycle[source]

Finds the cycle from a start location.

day08.day8.follow_directions(directions: Directions, world_map: WorldMap) int[source]

Follows directions until we hit zzz.

day08.day8.follow_directions_multi(directions: Directions, world_map: WorldMap) int[source]

Follow all mappings ending in A until all of them are ZZZ.

day08.day8.get_location_as(world_map: WorldMap) list[Location][source]

Returns locations with an A at the end.

day08.day8.main() None[source]

Main function, solve the things.

day08.day8.read_input(path: str) tuple[Directions, WorldMap][source]

Reads input into directions/world_map.

Module contents

Day08 solution.