excellent
This commit is contained in:
parent
f6868c7d28
commit
431c304645
18
1/1.py
18
1/1.py
@ -1,13 +1,5 @@
|
|||||||
def distances(left: list[int], right: list[int]) -> list[int]:
|
with open('1.input') as f:
|
||||||
left, right = sorted(left), sorted(right)
|
l,r=[],[]
|
||||||
return [abs(l-r) for l, r in zip(left, right)]
|
d=lambda a,b:[abs(a-b) for a,b in zip(sorted(a), sorted(b))]
|
||||||
|
for i in f:l.append(int(i.split()[0])),r.append(int(i.split()[1]))
|
||||||
if __name__ == '__main__':
|
print(sum(d(l,r)))
|
||||||
with open('1.input') as file:
|
|
||||||
left, right = [], []
|
|
||||||
for line in file:
|
|
||||||
l, r = line.split()
|
|
||||||
l, r = int(l), int(r)
|
|
||||||
left.append(l)
|
|
||||||
right.append(r)
|
|
||||||
print(sum(distances(left, right)))
|
|
Loading…
Reference in New Issue
Block a user