Last active
December 6, 2021 14:03
-
-
Save spielkind/5d68dec53dcffda191e13dc958221f76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
with open('day1.txt') as f: | |
measurements= [int(x) for x in f] | |
def compare(n): | |
return sum(1 for i in range(len(n)) if n[i]>n[i-1]) | |
print("Part One: ",compare(measurements)) | |
sliding = [sum(measurements[i:i+3]) for i in range(len(measurements)-2)] | |
print("Part Two: ",compare(sliding)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment