-
-
Save Tomalak/200a2603aef29ff37a71c2b4f7b6cb3d 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 = list(map(int, f)) | |
def compare(values): | |
return [m for i, m in enumerate(values) if i and m > values[i-1]] | |
print(f"Part One: {len(compare(measurements))}") | |
sliding = [ | |
sum(measurements[i:i+2]) for i, _ in enumerate(measurements) | |
if i < len(measurements) - 2 | |
] | |
print(f"Part Two: {len(compare(sliding))}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment