trois premiers jours
This commit is contained in:
21
day1.py
Normal file
21
day1.py
Normal file
@ -0,0 +1,21 @@
|
||||
import numpy as np
|
||||
|
||||
l = np.loadtxt("day1.txt")
|
||||
# l = np.array([[3,4],
|
||||
# [4,3],
|
||||
# [2,5],
|
||||
# [1,3],
|
||||
# [3,9],
|
||||
# [3,3]])
|
||||
|
||||
a,b = np.sort(l[:,0]),np.sort(l[:,1])
|
||||
dist = np.abs(a - b)
|
||||
tot = np.sum(dist)
|
||||
# print(tot)
|
||||
|
||||
sim = 0
|
||||
for i in a :
|
||||
for j in b :
|
||||
if i == j:
|
||||
sim += i
|
||||
print(sim)
|
||||
Reference in New Issue
Block a user