day 1, cleanup py
This commit is contained in:
parent
cf7806ca01
commit
7382d1a9d8
16
d01/run.py
16
d01/run.py
|
@ -3,19 +3,11 @@ from collections import Counter
|
||||||
|
|
||||||
L1 = []
|
L1 = []
|
||||||
L2 = []
|
L2 = []
|
||||||
L = sys.stdin.readlines()
|
for l in sys.stdin.readlines():
|
||||||
for l in L:
|
|
||||||
[a,b] = l[:-1].split(" ")
|
[a,b] = l[:-1].split(" ")
|
||||||
L1.append(int(a))
|
L1.append(int(a))
|
||||||
L2.append(int(b))
|
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)
|
C2 = Counter(L2)
|
||||||
S=0
|
|
||||||
for n in L1:
|
print(sum(abs(b-a) for a, b in zip(sorted(L1), sorted(L2))),
|
||||||
S += n * C2[n]
|
sum(n * C2[n] for n in L1))
|
||||||
print("2:", S)
|
|
||||||
|
|
Loading…
Reference in New Issue