2024/1 challenge
This commit is contained in:
parent
f99892ba74
commit
d5079efa4c
|
@ -0,0 +1 @@
|
|||
__pycache__/
|
|
@ -0,0 +1,14 @@
|
|||
input = [i.rstrip() for i in open("input").readlines()]
|
||||
splitted = [i.split(' ') for i in input]
|
||||
|
||||
left = [int(i[0]) for i in splitted]
|
||||
left = sorted(left)
|
||||
right = [int(i[1]) for i in splitted]
|
||||
right = sorted(right)
|
||||
|
||||
output = []
|
||||
for index in range(len(left)):
|
||||
signed_dist = int(left[index]) - int(right[index])
|
||||
output.append(abs(signed_dist))
|
||||
|
||||
print(sum(output))
|
|
@ -0,0 +1,14 @@
|
|||
from collections import Counter
|
||||
input = [i.rstrip() for i in open("input").readlines()]
|
||||
splitted = [i.split(' ') for i in input]
|
||||
|
||||
left = [int(i[0]) for i in splitted]
|
||||
right = [int(i[1]) for i in splitted]
|
||||
|
||||
counted = Counter(right)
|
||||
|
||||
score = 0
|
||||
for item in left:
|
||||
score += item * counted[item]
|
||||
|
||||
print(score)
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue