diff --git a/.gitignore b/.gitignore index d5e4f15f8c02ac458b0019ffbb99d969fdc719db..5fb58aff55a75922b3006105626b794fd853899f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -**/__pycache__ \ No newline at end of file +**/__pycache__ +**/test.py diff --git a/polynome.py b/polynome.py index a807c3ebb775ec4b520c02ac404a1f10ac65b2f0..6d28631c74b38f487501928222de40153c487b2f 100644 --- a/polynome.py +++ b/polynome.py @@ -45,5 +45,5 @@ class polynome(): # Using horner method res = 0 for i in range(len(self.coefs) - 1, -1, -1): - res = (res * x + self.coefs[i]) % self.prime_mod + res = (res * x + self.coefs[i]) return res diff --git a/reed_solomon.py b/reed_solomon.py index 698cc4aa8aaaaec9df3181c768fad2e94efb04ef..d6ae2ad451ed7264ef7f85f72c6ffd5066d5f8a1 100644 --- a/reed_solomon.py +++ b/reed_solomon.py @@ -1,9 +1,26 @@ # Created on 09/12/2021 from polynome import * from inverse_mult import * +from itertools import combinations def get_possibilities(l: list): - pass + + # Transforme the list in list of tupples with their indexes + for x, _ in enumerate(l): + l[x] = (x, l[x]) + + # ! la valeur 20 est hardcodée. Paramètre de fonction ?? + + l_fixe = l[20:] # Liste contenant aucune erreur + l_posi = l[:20] # Liste contenant des erreurs, + + p = list(combinations(l_posi, 2)) + + for x, y in enumerate(p): + p[x] = list(y) + p[x].extend(l_fixe) + + return p def lagrange_compute(l: list) -> polynome: list_s = [0] * len(l) @@ -37,4 +54,4 @@ if __name__ == '__main__': #print(list_) poly = lagrange_compute(list_) poly.show() - #print(poly.evaluate(0)) \ No newline at end of file + #print(poly.evaluate(0))