diff --git a/wgamesolv.py b/wgamesolv.py index 404434d..c23b866 100755 --- a/wgamesolv.py +++ b/wgamesolv.py @@ -57,10 +57,12 @@ def resolv_len(liste, lenght): def resolv_pattern(liste, pattern): # Pattern : élimination des mots ne satisfaisant pas la pattern - pattern_dict = {} + pattern_dict, not_pattern_dict = {}, {} for lettre in pattern: - if lettre != ".": + if lettre != "." and lettre.isupper(): pattern_dict.update({pattern.index(lettre): lettre}) + if lettre != "." and lettre.islower(): + not_pattern_dict.update({pattern.index(lettre): lettre.upper()}) MotsOK, MotsKO = [], [] for mot in liste: for key in pattern_dict: @@ -68,6 +70,10 @@ def resolv_pattern(liste, pattern): MotsOK.append(mot) else: MotsKO.append(mot) + for key in not_pattern_dict: + if mot[key] == not_pattern_dict[key]: + MotsKO.append(mot) + MotsKO = set(MotsKO) liste = [mot for mot in MotsOK if mot not in MotsKO] liste = list(set(liste)) return liste