Nettoyage
This commit is contained in:
parent
e4b517168a
commit
fc93178303
33
wgamesolv.py
33
wgamesolv.py
@ -10,8 +10,8 @@ def load_dict(dict_file):
|
||||
with open(dict_file, "r") as dico:
|
||||
liste = json.load(dico)
|
||||
return liste
|
||||
except:
|
||||
print("Impossible d'ouvrir le fichier" + fp)
|
||||
except Exception as error:
|
||||
print(f"Impossible d'ouvrir le fichier {dict_file} : {error}")
|
||||
exit(2)
|
||||
|
||||
|
||||
@ -20,13 +20,14 @@ def noDouble(mots):
|
||||
ndList = []
|
||||
for mot in mots:
|
||||
llist = []
|
||||
for l in mot:
|
||||
if not l in llist:
|
||||
llist.append(l)
|
||||
for lettre in mot:
|
||||
if lettre not in llist:
|
||||
llist.append(lettre)
|
||||
if len(mot) == len(llist):
|
||||
ndList.append(mot)
|
||||
return(ndList)
|
||||
|
||||
|
||||
def firstTryFilter(mots, max_mots):
|
||||
'''
|
||||
First Try : sélectionne des mots ayant des chances de valider ou invalider
|
||||
@ -71,19 +72,12 @@ def resolv_pattern(liste, pattern):
|
||||
liste = list(set(liste))
|
||||
return liste
|
||||
|
||||
#if pattern:
|
||||
# patternCount = len(pattern) - pattern.count(".")
|
||||
# for mot in goodLen:
|
||||
# patternEval = 0
|
||||
# for l in range(len(mot)):
|
||||
# if mot[l] == pattern[l]:
|
||||
# patternEval += 1
|
||||
# if patternEval == patternCount :
|
||||
# patternFilter.append(mot)
|
||||
#
|
||||
|
||||
def resolv_kl(liste, lettres):
|
||||
# Known Letters : élimination des mots ne comprenant pas les lettres validées (hors pattern)
|
||||
'''
|
||||
Known Letters : élimination des mots ne comprenant pas
|
||||
les lettres validées (hors pattern)
|
||||
'''
|
||||
lettres = list(set(list(lettres)))
|
||||
MotsRestants = []
|
||||
for mot in liste:
|
||||
@ -93,7 +87,10 @@ def resolv_kl(liste, lettres):
|
||||
|
||||
|
||||
def resolv_bl(liste, lettres):
|
||||
# Bad Letters : élimination des mots contenant des lettres invalidées (hors pattern)
|
||||
'''
|
||||
Bad Letters : élimination des mots contenant
|
||||
des lettres invalidées (hors pattern)
|
||||
'''
|
||||
lettres = list(set(list(lettres)))
|
||||
MotsSuppr = []
|
||||
for mot in liste:
|
||||
@ -103,7 +100,7 @@ def resolv_bl(liste, lettres):
|
||||
for mot in MotsSuppr:
|
||||
try:
|
||||
liste.pop(liste.index(mot))
|
||||
except:
|
||||
except ValueError:
|
||||
pass
|
||||
return liste
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user