Created
December 11, 2021 00:05
-
-
Save itayzit/710e6d65ca4c886ac81725a23d4df1a0 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
# A solution to both parts of AoC challenge day 1. | |
import gamla | |
PART = 1 | |
with open(filename, "r") as f: | |
result = gamla.pipe( | |
f.readlines(), | |
gamla.map(int), | |
gamla.sliding_window(1 if PART == 1 else 3), | |
gamla.map(sum), | |
gamla.sliding_window(2), | |
gamla.reduce(lambda sum_so_far, window: sum_so_far + int(window[1] > window[0]), 0), | |
) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment