blob: ce728ccb9e5daa47e0d0527519f912cdd458df38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
from typing import Iterator, List
from aoc import AssignmentBase
class Assignment(AssignmentBase):
def parse_item(self, item: str) -> int:
return int(item)
def read_input(self, example = False) -> List[int]:
return sorted(super().read_input(example))
class AssignmentOne(Assignment):
def run(self, input: List) -> int:
front_position = 0
end_position = -1
while True:
sum = input[front_position] + input[end_position]
if sum > 2020:
end_position -= 1
elif sum < 2020:
front_position += 1
else:
break
return input[front_position] * input[end_position]
class AssignmentTwo(Assignment):
def run(self, input: List) -> int:
for a in input:
for b in input:
for c in input:
if a + b + c == 2020:
return a * b * c
|