Move python solutions to separate directory

This commit is contained in:
Joscha 2019-12-05 08:45:38 +00:00
parent 47e97f4533
commit 3903907973
70 changed files with 0 additions and 0 deletions

View file

@ -1,37 +0,0 @@
import sys
def load_line(filename):
with open(filename, "r") as f:
return list(map(int, f.read()[:-1]))
# PART 1
def sum_matching(digits):
offset = digits[1:] + digits
total = 0
for x, y in zip(digits, offset):
if x == y:
total += x
return total
# PART 2
def sum_matching_2(digits):
offset = digits[len(digits)//2:] + digits
total = 0
for x, y in zip(digits, offset):
if x == y:
total += x
return total
def main(filename):
digits = load_line(filename)
print(f"Solutions for {filename}")
total = sum_matching(digits)
print(f"Part 1: {total}")
total_2 = sum_matching_2(digits)
print(f"Part 2: {total_2}")
if __name__ == "__main__":
for filename in sys.argv[1:]:
main(filename)