Skip to content

Commit 550690a

Browse files
committed
AoC 2025 Day 5 - faster
1 parent 123bcb2 commit 550690a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/python/AoC2025_05.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
@dataclass(frozen=True)
3232
class Database:
33-
id_ranges: set[RangeInclusive]
33+
id_ranges: list[RangeInclusive]
3434
available_ids: list[int]
3535

3636
@classmethod
@@ -41,7 +41,7 @@ def from_input(cls, input_data: InputData) -> Self:
4141
lo, hi = map(int, line.split("-"))
4242
ranges.add(RangeInclusive.between(lo, hi))
4343
pids = [int(line) for line in blocks[1]]
44-
return cls(ranges, pids)
44+
return cls(RangeInclusive.merge(ranges), pids)
4545

4646

4747
Input = Database
@@ -60,7 +60,7 @@ def part_1(self, database: Input) -> Output1:
6060
)
6161

6262
def part_2(self, database: Input) -> Output2:
63-
return sum(rng.len for rng in RangeInclusive.merge(database.id_ranges))
63+
return sum(rng.len for rng in database.id_ranges)
6464

6565
@aoc_samples(
6666
(

0 commit comments

Comments
 (0)