Last active
December 2, 2017 12:14
-
-
Save jacoelho/e237948e010829def9e64443472e32a2 to your computer and use it in GitHub Desktop.
advent 2017 day
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
def transform(input): | |
return [int(x) for x in input] | |
def consecutive(L): | |
for prev, n in zip(L, L[1:] + L[:1]): | |
if prev == n: | |
yield n | |
for v in [ "1122", "1111", "1234", "91212129"]: | |
print(sum(transform(consecutive(v)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment