20 lines
526 B
Python
20 lines
526 B
Python
|
sweep = []
|
||
|
|
||
|
with open("input.txt") as f:
|
||
|
lines = f.readlines()
|
||
|
for line in lines:
|
||
|
sweep.append(int(line))
|
||
|
|
||
|
comparison = zip(sweep[1:],sweep)
|
||
|
differences = [(d2 - d1) for d2, d1 in comparison]
|
||
|
increases = [(d > 0) for d in differences]
|
||
|
part1 = sum(increases)
|
||
|
print(part1)
|
||
|
|
||
|
window = zip(sweep,sweep[1:],sweep[2:])
|
||
|
sums = [(d1 + d2 + d3) for d1, d2, d3 in window]
|
||
|
comparison = zip(sums[1:],sums)
|
||
|
differences = [(d2 - d1) for d2, d1 in comparison]
|
||
|
increases = [(d > 0) for d in differences]
|
||
|
part2 = sum(increases)
|
||
|
print(part2)
|