day11 package

Subpackages

Submodules

day11.day11 module

day11 solution.

class day11.day11.Galaxy(row: int, col: int, id: int)[source]

Bases: object

Galaxy represented as its position and unique id.

col: int
distance(other: Galaxy, universe: Universe) int[source]

Return distance from one galaxy to another.

Accounts for “expanded” spaces in the universe

id: int
row: int
class day11.day11.Point(row: int, col: int, item: str)[source]

Bases: object

Point represented by character and whether it is expanded.

col: int
get_point_distance(expansion_rate: int) int[source]

Returns how big this “point” is based on if its expanded.

is_expanded: bool = False
item: str
row: int
class day11.day11.Universe(contents: list[list[Point]], expansion_rate: int = 2)[source]

Bases: object

Universe class; 2d array of . and #.

col_lookup: list[int]
contents: list[list[Point]]
expand_contents() None[source]

Expands the contents of the universe.

expanded_to_lookup(expanded_items: list[int], size: int) list[int][source]

Convert from [3,7], 10 to 00011112222.

expansion_rate: int = 2
grab_galaxies() list[Galaxy][source]

Grabs all galaxies.

init_lookups(expanded_rows: list[int], expanded_cols: list[int]) None[source]

Initialize lookup tables.

num_cols: int
num_rows: int
row_lookup: list[int]
day11.day11.get_total_distance(galaxies: list[Galaxy], universe: Universe) int[source]

Returns total distance of all galaxies.

day11.day11.is_empty(items: list[Point]) bool[source]

Returns True if all the content is ..

day11.day11.main() None[source]

Main function, runs q1 and q2.

day11.day11.parse_input(path: str) Universe[source]

Parse input file and return a universe.

Module contents

Day11 solution.