Day 1
commit
eae5d96cf4
|
@ -0,0 +1 @@
|
|||
*/input.txt
|
|
@ -0,0 +1,27 @@
|
|||
def parse_input() -> tuple[list[int], list[int]]:
|
||||
raw_input = open("input.txt").read()
|
||||
|
||||
line1 = []
|
||||
line2 = []
|
||||
|
||||
for raw_line in raw_input.splitlines():
|
||||
num1, num2 = raw_line.split()
|
||||
line1.append(int(num1))
|
||||
line2.append(int(num2))
|
||||
return line1, line2
|
||||
|
||||
def main() -> int:
|
||||
line1, line2 = parse_input()
|
||||
line1.sort()
|
||||
line2.sort()
|
||||
|
||||
distances = [abs(num1 - num2) for num1, num2 in zip(line1, line2)]
|
||||
|
||||
result = sum(distances)
|
||||
|
||||
print(result)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue