This commit is contained in:
Holly McFarland 2024-12-04 18:00:43 -05:00
commit dfd296d8f4
3 changed files with 23 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vs

11
day_01/part_a.py Normal file
View File

@ -0,0 +1,11 @@
import aocd
def solve(data):
pairs = zip(*(map(sorted, zip(*(map(int, line.split()) for line in data.split('\n'))))))
return sum(abs(a-b) for a,b in pairs)
if __name__ == '__main__':
solution = solve(aocd.get_data(year=2024, day=1))
print(solution)
aocd.submit(solution, year=2024, day=1, part='a')

11
day_01/part_b.py Normal file
View File

@ -0,0 +1,11 @@
import aocd
def solve(data):
list_a, list_b = zip(*(map(int, line.split()) for line in data.split('\n')))
return sum(num*list_a.count(num)*list_b.count(num) for num in set(list_a))
if __name__ == '__main__':
solution = solve(aocd.get_data(year=2024, day=1))
print(solution)
aocd.submit(solution, year='2024', day=1, part='b')