diff --git a/projet_conso.py b/projet_conso.py index c0dac65..d2bd374 100644 --- a/projet_conso.py +++ b/projet_conso.py @@ -87,9 +87,14 @@ def distance (t1 ,t2) : +(temperatureref1 -temperatureref2)**2) return distancefin - - - - - - +def kPlusProches(point, tableau): + """prend en paramètre en tuple et un tableau et renvoie une liste de tuples + triee""" + point = numero_jour, temperature_moyenne, temperature_reference + liste_distances = [] + for i in range(len(tableau)): + voisin = (i + 1, tableau[i][1], tableau[i][2]) + d = distance(point, voisin) + liste_distances.append((d, i)) + liste_distances.sort() + return liste_distances \ No newline at end of file