diff options
| author | 2023-12-04 10:40:34 +0100 | |
|---|---|---|
| committer | 2023-12-04 10:41:07 +0100 | |
| commit | e688c2b674fc7ad6a964a48df379e5abd01843a7 (patch) | |
| tree | e73ee82805e5521463706d117bd036cc1ae13ac8 /day1/__init__.py | |
| parent | 1de244cfb7ef2017981402c7d1eaa1b5a0aa16b7 (diff) | |
| download | 2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.gz 2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.bz2 2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.zip | |
Day4
Diffstat (limited to 'day1/__init__.py')
| -rw-r--r-- | day1/__init__.py | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/day1/__init__.py b/day1/__init__.py index ee66fd3..ea27c01 100644 --- a/day1/__init__.py +++ b/day1/__init__.py | |||
| @@ -10,10 +10,7 @@ class Assignment(BaseAssignment, ABC): | |||
| 10 | def run(self, input: Iterator[list[int]]) -> int: | 10 | def run(self, input: Iterator[list[int]]) -> int: |
| 11 | input = list(input) | 11 | input = list(input) |
| 12 | print(input) | 12 | print(input) |
| 13 | return sum([ | 13 | return sum([int(f"{item[0]}{item[-1]}") for item in input]) |
| 14 | int(f'{item[0]}{item[-1]}') | ||
| 15 | for item in input | ||
| 16 | ]) | ||
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | class AssignmentOne(Assignment): | 16 | class AssignmentOne(Assignment): |
| @@ -53,18 +50,8 @@ class AssignmentTwo(Assignment): | |||
| 53 | numbers[index] = int(i) | 50 | numbers[index] = int(i) |
| 54 | 51 | ||
| 55 | return [ | 52 | return [ |
| 56 | value | 53 | value for key, value in sorted(numbers.items(), key=lambda item: item[0]) |
| 57 | for key, value | ||
| 58 | in sorted( | ||
| 59 | numbers.items(), | ||
| 60 | key=lambda item: item[0] | ||
| 61 | ) | ||
| 62 | ] | 54 | ] |
| 63 | 55 | ||
| 64 | def parse_item(self, item: str) -> list[int]: | 56 | def parse_item(self, item: str) -> list[int]: |
| 65 | return self._parse_item(item) | 57 | return self._parse_item(item) |
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | |||
