day02 package

Subpackages

Submodules

day02.day2 module

day2 solution.

class day02.day2.Color(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Color enum.

BLUE = 'blue'
GREEN = 'green'
RED = 'red'
class day02.day2.Draw(string: str)[source]

Bases: object

Class representing a draw from the bag.

blue: int = 0
green: int = 0
parse_color_count(string: str) tuple[int, Color][source]

string: 1 blue.

parse_colors_count(string: str) None[source]

string: 1 blue, 4 green, 5 red.

red: int = 0
class day02.day2.Game(string: str)[source]

Bases: object

Game class, showing multiple draws.

blue: int = 0
green: int = 0
id: int
parse_draws(string: str) list[Draw][source]

string: 1 blue; 4 green, 5 blue; 11 red, 3 blue.

power_level() int[source]

Returns r*g*b.

red: int = 0
day02.day2.game_filter(game: Game) bool[source]

Returns true if the game satisfies the constraints of Question 1.

day02.day2.get_games(input_file: str) list[Game][source]

Gets the games from the input file.

Parameters:

input_file (str) – input file name

Returns:

list of Games

Return type:

list[Game]

day02.day2.main() None[source]

Parses data into data structures, then prints out answer to q1 and q2.

day02.day2.part1(games: list[Game]) int[source]

Solves part 1.

day02.day2.part2(games: list[Game]) int[source]

Solves part2.

Module contents

day02 implementation.