Add 2024 AoC, solution for day 1 and 2

This commit is contained in:
Maya Herrscher committed 2024-12-02 09:30:41 +01:00
1 parent 4a5a3ba757
commit b0749e224f
10 files changed
+2223

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys, math
if __name__ == '__main__':
tuples = [[int(l) for l in line.strip('\n').split(' ')] for line in open(sys.argv[1])]
first, second = [sorted(a) for a in zip(*tuples)]
# first = []
# second = []
# for line in lines:
# f, s = line.split(' ')
# first.append(int(f))
# second.append(int(s))
# first.sort()
# second.sort()
# challenge 1
res1 = sum([abs(x-y) for (x,y) in zip(first, second)])
print(f"challenge 1:\n{res1}\n")
# challenge 2
res2 = sum([x * second.count(x) for x in first])
print(f"challenge 2:\n{res2}")