From 5dad04d59a9e33ec4ae1799b735eb0886fd46e4a Mon Sep 17 00:00:00 2001 From: unknown <nicolas.albanesi@etu.hesge.ch> Date: Thu, 16 Dec 2021 10:45:43 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20param=C3=A8tres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++----- reed_solomon.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 2037ad7..4f62319 100644 --- a/main.py +++ b/main.py @@ -14,15 +14,20 @@ def correct_list(len_list: int, p: polynome): if __name__ == "__main__": l = [115, 117, 101, 118, 122, 116, 57, 108, 32, 224, 62, 116, 115, 140, 32, 108, 153, 83, 169, 117, 108, 112, 32, 110, 101, 55, 96, 61, 160, 218, 228, 156, 224, 203, 12, 75, 180, 23, 220, 211, 137, 139, 206] + + # PARAMETRES + # Variables dans reed_solomon.py + INDEX_MAX = 20 + ERROR_MAX = 9 + MSG_LEN = 25 + + # Find the correct polynom reed_solomon = reed_decode(l) l_ok = correct_list(len(l), reed_solomon) - print(l) - print(l_ok) - - print("".join(map(chr, l[:25]))) - print("".join(map(chr, l_ok[:25]))) + print("Message recu : " + "".join(map(chr, l[:MSG_LEN]))) + print("Message décodé : " + "".join(map(chr, l_ok[:MSG_LEN]))) \ No newline at end of file diff --git a/reed_solomon.py b/reed_solomon.py index de9a566..ea424ed 100644 --- a/reed_solomon.py +++ b/reed_solomon.py @@ -3,6 +3,13 @@ from polynome import * from inverse_mult import * from itertools import combinations + +# Global Variables +# Parameters +INDEX_MAX = 20 +ERROR_MAX = 9 + + def get_possibilities(l_og: list, index: int): l = l_og.copy() # Transforme the list in list of tupples with their indexes @@ -43,9 +50,9 @@ def check_nb_error(l: list, p: polynome) -> int: def reed_decode(l: list) -> polynome: - for points in get_possibilities(l, 20): + for points in get_possibilities(l, INDEX_MAX): err = check_nb_error(l, lagrange_compute(points)) - if ((err) <= 9): + if ((err) <= ERROR_MAX): # ? Chercher un polynome avec moins de 9 erreurs ? # Possibilité d'optimiser en evitant de compute 2 fois le poly return lagrange_compute(points) \ No newline at end of file -- GitLab