32 lines
673 B
Python
Executable File
32 lines
673 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
def main(args):
|
|
list1 = []
|
|
list2 = []
|
|
|
|
with open(args.file) as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
tmp = line.split(" ")
|
|
list1.append(int(tmp[0]))
|
|
list2.append(int(tmp[3]))
|
|
|
|
list1.sort()
|
|
list2.sort()
|
|
|
|
distance = 0
|
|
|
|
for i in range(len(list1)):
|
|
distance += abs(list1[i] - list2[i])
|
|
|
|
print(distance)
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog='AdventOfCode 2024, Day 01, part 1',
|
|
)
|
|
parser.add_argument('-f', '--file', required=True)
|
|
args = parser.parse_args()
|
|
main(args) |