-
-
Save MLLeKander/e7a164afd8ac6537c23e68296579b295 to your computer and use it in GitHub Desktop.
Advent of Code
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
s = open('inputs/1.in').read() | |
midp = 1 | |
print sum(int(e[0]) for e in zip(s,s[midp:]+s[:midp]) if e[0] == e[1]) | |
midp = len(s)/2 | |
print sum(int(e[0]) for e in zip(s,s[midp:]+s[:midp]) if e[0] == e[1]) |
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
import sys, itertools | |
l = [map(int, line.split()) for line in open('inputs/2.in').readlines()] | |
def f(row): | |
return max(row)-min(row) | |
print sum(map(f,l)) | |
def f(row): | |
for i, j in itertools.combinations(sorted(row), 2): | |
if j % i == 0: | |
return j / i | |
print sum(map(f, l)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment