Skip to content

Instantly share code, notes, and snippets.

@loudambiance
Created December 16, 2021 04:13
Show Gist options
  • Save loudambiance/a4e39300788bf37dfd471d64ff182f51 to your computer and use it in GitHub Desktop.
Save loudambiance/a4e39300788bf37dfd471d64ff182f51 to your computer and use it in GitHub Desktop.
with open('task1b.txt') as f:
lines = f.read().splitlines()
count = 0
a = lines.pop(0)
b = lines.pop(0)
c = lines.pop(0)
for line in lines:
sum1 = int(a) + int(b) + int(c)
sum2 = int(b) + int(c) + int(line)
if sum2 > sum1:
count = count + 1
a = b
b = c
c = line
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment