Skip to content

Instantly share code, notes, and snippets.

@Solaxun
Created December 4, 2021 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Solaxun/4ab40ac537c69836e95b6c5d6c2d1a3a to your computer and use it in GitHub Desktop.
Save Solaxun/4ab40ac537c69836e95b6c5d6c2d1a3a to your computer and use it in GitHub Desktop.
AoC 2021: Python Day 1
data = open('day1.txt').read().splitlines()
data = [int(a) for a in data]
cnt = 0
for a,b in zip(data,data[1:]):
if b > a:
cnt += 1
print(cnt)
cnt, prevsum = 0,0
for i in range(len(data)-3):
total = sum(data[i:i+3])
if total > prevsum:
cnt +=1
prevsum = total
print(cnt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment