Skip to content

Instantly share code, notes, and snippets.

@MLLeKander
Last active December 2, 2017 12:03
Show Gist options
  • Save MLLeKander/e7a164afd8ac6537c23e68296579b295 to your computer and use it in GitHub Desktop.
Save MLLeKander/e7a164afd8ac6537c23e68296579b295 to your computer and use it in GitHub Desktop.
Advent of Code
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])
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