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.
 
 

35 lines
743 B

#!/usr/bin/env python3
import sys
if __name__ == '__main__':
measurements = open(sys.argv[1]).read().strip('\n\n').split('\n')
meas = [int(i) for i in measurements]
# challenge 1
incr = 0
last = 0
for i in meas:
if i > last:
incr += 1
last = i
res1 = str(incr - 1)
print("challenge 1: " + res1 + "\n")
# challenge 2
incr = 0
first = meas[0]
second = meas[1]
third = meas[2]
last = first + second + third
for i in meas[3:]:
first = second
second = third
third = i
nex = first + second + third
if nex > last:
incr += 1
last = nex
res2 = str(incr)
print("challenge 2: " + res2 + "\n")