Created
December 1, 2017 19:28
-
-
Save jdiez17/2e90c3f4d85a15db6324afa71137bec3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def day1(seq, cmp): | |
| return functools.reduce(operator.add, map(lambda ic: int(ic[1]), filter(cmp, enumerate(seq)))) | |
| def day1_part1(seq): | |
| return day1(seq, lambda ic: ic[1] == seq[ic[0]-1]) | |
| def day1_part2(seq): | |
| return day1(seq, lambda ic: ic[1] == seq[(ic[0] + (len(seq) // 2)) % len(seq)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment