diff options
Diffstat (limited to 'day15')
| -rw-r--r-- | day15/__init__.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/day15/__init__.py b/day15/__init__.py index c22f0c1..5885f37 100644 --- a/day15/__init__.py +++ b/day15/__init__.py | |||
| @@ -4,6 +4,7 @@ from abc import ABC | |||
| 4 | from collections import namedtuple | 4 | from collections import namedtuple |
| 5 | from dataclasses import dataclass, field | 5 | from dataclasses import dataclass, field |
| 6 | from typing import Tuple, Iterator, Any, Set, Union | 6 | from typing import Tuple, Iterator, Any, Set, Union |
| 7 | from typing import Tuple, Iterator, Any, Set, List | ||
| 7 | 8 | ||
| 8 | from aoc import BaseAssignment | 9 | from aoc import BaseAssignment |
| 9 | 10 | ||
| @@ -47,7 +48,7 @@ class Sensor: | |||
| 47 | 48 | ||
| 48 | @dataclass | 49 | @dataclass |
| 49 | class Map: | 50 | class Map: |
| 50 | sensors: Set[Sensor] = field(default_factory=set) | 51 | sensors: List[Sensor] = field(default_factory=list) |
| 51 | beacons: Set[Coordinate] = field(default_factory=set) | 52 | beacons: Set[Coordinate] = field(default_factory=set) |
| 52 | 53 | ||
| 53 | def __post_init__(self): | 54 | def __post_init__(self): |
| @@ -80,11 +81,11 @@ class Assignment(BaseAssignment[int, Tuple[Sensor, Coordinate]], ABC): | |||
| 80 | return sensor, beacon | 81 | return sensor, beacon |
| 81 | 82 | ||
| 82 | def create_map(self, input: Iterator[Tuple[Sensor, Coordinate]]) -> Map: | 83 | def create_map(self, input: Iterator[Tuple[Sensor, Coordinate]]) -> Map: |
| 83 | sensors = set() | 84 | sensors = list() |
| 84 | beacons = set() | 85 | beacons = set() |
| 85 | 86 | ||
| 86 | for sensor, beacon in input: | 87 | for sensor, beacon in input: |
| 87 | sensors.add(sensor) | 88 | sensors.append(sensor) |
| 88 | beacons.add(beacon) | 89 | beacons.add(beacon) |
| 89 | 90 | ||
| 90 | return Map(sensors, beacons) | 91 | return Map(sensors, beacons) |
| @@ -94,6 +95,8 @@ class AssignmentOne(Assignment): | |||
| 94 | example_result = 26 | 95 | example_result = 26 |
| 95 | example_kwargs = {"y": 10} | 96 | example_kwargs = {"y": 10} |
| 96 | 97 | ||
| 98 | # Wrong: 4062163 | ||
| 99 | |||
| 97 | def run(self, input: Iterator[Tuple[Sensor, Coordinate]], y=2000000): | 100 | def run(self, input: Iterator[Tuple[Sensor, Coordinate]], y=2000000): |
| 98 | map = self.create_map(input) | 101 | map = self.create_map(input) |
| 99 | 102 | ||
