first commit

This commit is contained in:
2020-12-02 12:34:15 +01:00
parent e7158639f6
commit f4c3aeabee
13 changed files with 1421 additions and 0 deletions

27
2017/alt2.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python
import itertools
with open('input2.txt') as f:
data = []
for line in f.read().splitlines():
data.append(list(map(int, line.split())))
def part1():
checksum = 0
for row in data:
checksum += max(row) - min(row)
return checksum
def part2():
checksum = 0
for row in data:
combos = list(itertools.combinations(row, 2))
for c in combos:
a, b = max(c), min(c)
if a % b == 0:
checksum += a//b
return checksum
print(part1())
print(part2())