Created
December 13, 2021 00:10
-
-
Save itayzit/b6c24fa7dc0c4f8c5318a0707f6d1136 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
# Part 1 solution | |
import gamla | |
with open(filename, "r") as f: | |
result = gamla.pipe( | |
f.readlines(), | |
gamla.map(str.strip), | |
gamla.map(gamla.split_text(" ")), | |
gamla.bifurcate( | |
gamla.filter(gamla.inside("forward")), | |
gamla.filter(gamla.inside("down")), | |
gamla.filter(gamla.inside("up")), | |
), | |
gamla.map(gamla.map(gamla.compose_left(gamla.second, int))), | |
gamla.map(sum), | |
list, | |
gamla.star(lambda forward, down, up: forward * (down - up)), | |
) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment