day01
This commit is contained in:
parent
6a7054552c
commit
d07daa6422
37
day01.py
37
day01.py
@ -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
|
||||||
|
|||||||
2001
inputs/input01
2001
inputs/input01
File diff suppressed because it is too large
Load Diff
@ -1 +1,10 @@
|
|||||||
1122
|
199
|
||||||
|
200
|
||||||
|
208
|
||||||
|
210
|
||||||
|
200
|
||||||
|
207
|
||||||
|
240
|
||||||
|
269
|
||||||
|
260
|
||||||
|
263
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
1111
|
|
||||||
@ -1 +0,0 @@
|
|||||||
1234
|
|
||||||
@ -1 +0,0 @@
|
|||||||
91212129
|
|
||||||
@ -1 +1,10 @@
|
|||||||
1212
|
199
|
||||||
|
200
|
||||||
|
208
|
||||||
|
210
|
||||||
|
200
|
||||||
|
207
|
||||||
|
240
|
||||||
|
269
|
||||||
|
260
|
||||||
|
263
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
1221
|
|
||||||
@ -1 +0,0 @@
|
|||||||
123425
|
|
||||||
@ -1 +0,0 @@
|
|||||||
123123
|
|
||||||
@ -1 +0,0 @@
|
|||||||
12131415
|
|
||||||
Loading…
Reference in New Issue
Block a user