You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
382 B
26 lines
382 B
3 years ago
|
import math
|
||
|
|
||
|
values = []
|
||
|
with open("input", "r") as file:
|
||
|
for line in file.readlines():
|
||
|
values.append(int(line))
|
||
|
|
||
|
increases = 0
|
||
|
before = math.inf
|
||
|
for v in values:
|
||
|
if v > before:
|
||
|
increases += 1
|
||
|
before = v
|
||
|
|
||
|
print(increases)
|
||
|
|
||
|
increases = 0
|
||
|
before = math.inf
|
||
|
for i in range(len(values) - 2):
|
||
|
s = sum(values[i:i+3])
|
||
|
if s > before:
|
||
|
increases += 1
|
||
|
before = s
|
||
|
|
||
|
print(increases)
|