34 lines
490 B
Python
34 lines
490 B
Python
|
example = """
|
||
|
3 4
|
||
|
4 3
|
||
|
2 5
|
||
|
1 3
|
||
|
3 9
|
||
|
3 3
|
||
|
"""
|
||
|
|
||
|
|
||
|
parsed = [[],[]]
|
||
|
|
||
|
for x in open('input.txt', 'r').readlines():
|
||
|
if x:
|
||
|
a = [y for y in x.split(" ") if y]
|
||
|
|
||
|
parsed[0].append(a[0])
|
||
|
parsed[1].append(a[1])
|
||
|
|
||
|
parsed[0] = sorted(parsed[0])
|
||
|
parsed[1] = sorted(parsed[1])
|
||
|
|
||
|
asd = []
|
||
|
|
||
|
for x, y in zip(parsed[0], parsed[1]):
|
||
|
x = int(x)
|
||
|
y = int(y)
|
||
|
if x > y:
|
||
|
asd.append(x-y)
|
||
|
else:
|
||
|
asd.append(y-x)
|
||
|
|
||
|
num = sum(asd)
|
||
|
print(num)
|