From 7382d1a9d8b0ffb441e8fd6c7d0675f02d3568ec Mon Sep 17 00:00:00 2001 From: setop Date: Sun, 1 Dec 2024 15:35:36 +0100 Subject: [PATCH] day 1, cleanup py --- d01/run.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/d01/run.py b/d01/run.py index 9008393..9869975 100644 --- a/d01/run.py +++ b/d01/run.py @@ -3,19 +3,11 @@ from collections import Counter L1 = [] L2 = [] -L = sys.stdin.readlines() -for l in L: +for l in sys.stdin.readlines(): [a,b] = l[:-1].split(" ") L1.append(int(a)) L2.append(int(b)) - -S = 0 -for a, b in zip(sorted(L1), sorted(L2)): - S += abs(b-a) -print("1:", S) - C2 = Counter(L2) -S=0 -for n in L1: - S += n * C2[n] -print("2:", S) + +print(sum(abs(b-a) for a, b in zip(sorted(L1), sorted(L2))), + sum(n * C2[n] for n in L1))