22 lines
462 B
Python
22 lines
462 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
INPUT_FILE = 'input.txt'
|
||
|
|
||
|
def main():
|
||
|
left, right = [], []
|
||
|
contents = open(INPUT_FILE, 'r').readlines()
|
||
|
for line in contents:
|
||
|
fields = line.split(' ')
|
||
|
left.append(int(fields[0]))
|
||
|
right.append(int(fields[-1]))
|
||
|
left.sort()
|
||
|
right.sort()
|
||
|
diff_sum = 0
|
||
|
for pair in list(zip(left, right)):
|
||
|
diff_sum += abs(pair[0] - pair[1])
|
||
|
print(diff_sum)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|