diff options
| author | 2023-12-03 15:34:46 +0100 | |
|---|---|---|
| committer | 2023-12-03 15:34:46 +0100 | |
| commit | 8d8312b9ea8cee09e861165749449961a5c66ab9 (patch) | |
| tree | fd1316a9733154176b0356ee09ee2e5e391a73e0 /day2/__init__ (conflicted copy 2023-12-03 150713).py | |
| parent | d1bbbd066202b7e8a6ef75ef961de20ef4331a40 (diff) | |
| download | 2023-8d8312b9ea8cee09e861165749449961a5c66ab9.tar.gz 2023-8d8312b9ea8cee09e861165749449961a5c66ab9.tar.bz2 2023-8d8312b9ea8cee09e861165749449961a5c66ab9.zip | |
Day 2
Diffstat (limited to 'day2/__init__ (conflicted copy 2023-12-03 150713).py')
| -rw-r--r-- | day2/__init__ (conflicted copy 2023-12-03 150713).py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/day2/__init__ (conflicted copy 2023-12-03 150713).py b/day2/__init__ (conflicted copy 2023-12-03 150713).py new file mode 100644 index 0000000..1191e0f --- /dev/null +++ b/day2/__init__ (conflicted copy 2023-12-03 150713).py | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | from abc import ABC | ||
| 3 | from enum import Enum | ||
| 4 | from typing import Iterator | ||
| 5 | |||
| 6 | from aoc import BaseAssignment, I, T | ||
| 7 | |||
| 8 | |||
| 9 | class Color(Enum): | ||
| 10 | red = 'red' | ||
| 11 | green = 'green' | ||
| 12 | blue = 'blue' | ||
| 13 | |||
| 14 | ColorCount = tuple[int, Color] | ||
| 15 | |||
| 16 | class Assignment(BaseAssignment, ABC): | ||
| 17 | def parse_item(self, item: str) -> list[tuple[ColorCount, ...]]: | ||
| 18 | _, items = item.split(': ') | ||
| 19 | |||
| 20 | return [ | ||
| 21 | tuple( | ||
| 22 | tuple(( | ||
| 23 | int(_.split(' ')[0]), | ||
| 24 | Color(_.split(' ')[1]) | ||
| 25 | )) | ||
| 26 | for _ in pair.split(', ') | ||
| 27 | ) | ||
| 28 | for pair in items.split('; ') | ||
| 29 | ] | ||
| 30 | |||
| 31 | |||
| 32 | class AssignmentOne(Assignment): | ||
| 33 | example_result = 8 | ||
| 34 | def run(self, input: Iterator[I]) -> T: | ||
| 35 | for i in input: | ||
| 36 | print(i) | ||
| 37 | |||
| 38 | |||
| 39 | class AssignmentTwo(Assignment): | ||
| 40 | pass | ||
