From af5215b869e19282fb20fcecbf96c67e983cff64 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Sat, 17 Dec 2022 14:46:31 +0100 Subject: Day 15 [WIP] --- day15/__init__.py | 9 ++++++--- 1 file 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 from collections import namedtuple from dataclasses import dataclass, field from typing import Tuple, Iterator, Any, Set, Union +from typing import Tuple, Iterator, Any, Set, List from aoc import BaseAssignment @@ -47,7 +48,7 @@ class Sensor: @dataclass class Map: - sensors: Set[Sensor] = field(default_factory=set) + sensors: List[Sensor] = field(default_factory=list) beacons: Set[Coordinate] = field(default_factory=set) def __post_init__(self): @@ -80,11 +81,11 @@ class Assignment(BaseAssignment[int, Tuple[Sensor, Coordinate]], ABC): return sensor, beacon def create_map(self, input: Iterator[Tuple[Sensor, Coordinate]]) -> Map: - sensors = set() + sensors = list() beacons = set() for sensor, beacon in input: - sensors.add(sensor) + sensors.append(sensor) beacons.add(beacon) return Map(sensors, beacons) @@ -94,6 +95,8 @@ class AssignmentOne(Assignment): example_result = 26 example_kwargs = {"y": 10} + # Wrong: 4062163 + def run(self, input: Iterator[Tuple[Sensor, Coordinate]], y=2000000): map = self.create_map(input) -- cgit v1.2.3