summaryrefslogtreecommitdiffstats
path: root/day1
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2023-12-04 10:40:34 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2023-12-04 10:41:07 +0100
commite688c2b674fc7ad6a964a48df379e5abd01843a7 (patch)
treee73ee82805e5521463706d117bd036cc1ae13ac8 /day1
parent1de244cfb7ef2017981402c7d1eaa1b5a0aa16b7 (diff)
download2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.gz
2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.tar.bz2
2023-e688c2b674fc7ad6a964a48df379e5abd01843a7.zip
Day4
Diffstat (limited to 'day1')
-rw-r--r--day1/__init__.py17
-rw-r--r--day1/test_init.py3
2 files changed, 4 insertions, 16 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
19class AssignmentOne(Assignment): 16class 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
diff --git a/day1/test_init.py b/day1/test_init.py
index 5e85eee..6b7f64d 100644
--- a/day1/test_init.py
+++ b/day1/test_init.py
@@ -1,6 +1,7 @@
1# -*- coding: utf-8 -*-
1from day1 import AssignmentTwo 2from day1 import AssignmentTwo
2 3
3 4
4class TestDayOnePartTwo: 5class TestDayOnePartTwo:
5 def test_parse_input(self): 6 def test_parse_input(self):
6 assert AssignmentTwo._parse_item('twone') == [2, 1] 7 assert AssignmentTwo._parse_item("twone") == [2, 1]