diff --git a/1/1.py b/1/1.py index 2474bd1..e25f050 100644 --- a/1/1.py +++ b/1/1.py @@ -1,13 +1,5 @@ -def distances(left: list[int], right: list[int]) -> list[int]: - left, right = sorted(left), sorted(right) - return [abs(l-r) for l, r in zip(left, right)] - -if __name__ == '__main__': - 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))) \ No newline at end of file +with open('1.input') as f: + l,r=[],[] + 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])) + print(sum(d(l,r))) \ No newline at end of file