trois premiers jours

This commit is contained in:
Marguerite Miallier
2024-12-03 19:04:09 +01:00
commit c394f7298d
3 changed files with 155 additions and 0 deletions

21
day1.py Normal file
View 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)