This commit is contained in:
Stefan Harmuth 2021-12-01 06:13:44 +01:00
parent 6a7054552c
commit d07daa6422
11 changed files with 2040 additions and 27 deletions

View File

@ -2,27 +2,30 @@ from aoc import AOCDay
class Day(AOCDay): class Day(AOCDay):
test_solutions_p1 = [3, 4, 0, 9] test_solutions_p1 = [7]
test_solutions_p2 = [6, 0, 4, 12, 4] test_solutions_p2 = [5]
def part1(self): def part1(self):
res = 0 count = 0
number = self.input[0] depths = self.getInputListAsType(int)
if number[0] == number[-1]: for i, x in enumerate(depths):
res += int(number[0]) if i == 0:
continue
for i in range(len(number) - 1): if x > depths[i-1]:
if number[i] == number[i+1]: count += 1
res += int(number[i])
return res return count
def part2(self): def part2(self):
res = 0 count = 0
number = self.input[0] depths = self.getInputListAsType(int)
half = len(number) // 2
for i in range(half):
if number[i] == number[i+half]:
res += int(number[i]) * 2
return res for x in range(3, len(depths)):
mid = depths[x-2] + depths[x-1]
a = mid + depths[x-3]
b = mid + depths[x]
if a < b:
count += 1
return count

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,10 @@
1122 199
200
208
210
200
207
240
269
260
263

View File

@ -1 +0,0 @@
1111

View File

@ -1 +0,0 @@
1234

View File

@ -1 +0,0 @@
91212129

View File

@ -1 +1,10 @@
1212 199
200
208
210
200
207
240
269
260
263

View File

@ -1 +0,0 @@
1221

View File

@ -1 +0,0 @@
123425

View File

@ -1 +0,0 @@
123123

View File

@ -1 +0,0 @@
12131415