Skip to content

Primitives

Year

The year of the problem (starts from 2015).

Source code in aoc/primitives.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@final
@frozen()
class Year:
    """The year of the problem (starts from `2015`)."""

    value: int = field()
    """The contained value."""

    @value.validator
    def check_value(self, attribute: Attribute[int], value: int) -> None:
        if value < FIRST_YEAR:
            raise ValueError(EXPECTED_YEAR)

    def __str__(self) -> str:
        return year(self.value)

value: int = field() class-attribute instance-attribute

The contained value.

Day

The day of the problem (in [1, 25] range).

Source code in aoc/primitives.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@final
@frozen()
class Day:
    """The day of the problem (in `[1, 25]` range)."""

    value: int = field()
    """The contained value."""

    @value.validator
    def check_value(self, attribute: Attribute[int], value: int) -> None:
        if value < FIRST_DAY:
            raise ValueError(EXPECTED_DAY)

        if value > LAST_DAY:
            raise ValueError(EXPECTED_DAY)

    def __str__(self) -> str:
        return day(self.value)

value: int = field() class-attribute instance-attribute

The contained value.

Key

The key of the problem.

This is essentially the (year, day) combination of Year and Day.

Source code in aoc/primitives.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@final
@frozen()
class Key:
    """The key of the problem.

    This is essentially the `(year, day)` combination of
    [`Year`][aoc.primitives.Year] and [`Day`][aoc.primitives.Day].
    """

    year: Year
    """The year of the problem."""

    day: Day
    """The day of the problem."""

    def __str__(self) -> str:
        return key(self.year, self.day)

year: Year instance-attribute

The year of the problem.

day: Day instance-attribute

The day of the problem.

Part

Bases: Enum

The part of the problem.

Source code in aoc/primitives.py
85
86
87
88
89
90
91
92
93
94
95
class Part(Enum):
    """The part of the problem."""

    ONE = 1
    """Part one of the problem."""

    TWO = 2
    """Part two of the problem."""

    ONLY = ONE
    """The only part of the problem."""

ONE = 1 class-attribute instance-attribute

Part one of the problem.

TWO = 2 class-attribute instance-attribute

Part two of the problem.

ONLY = ONE class-attribute instance-attribute

The only part of the problem.