Fonction "Bad Letters"
This commit is contained in:
parent
f9cf15d487
commit
e2452c1434
38
wgamesolv.py
38
wgamesolv.py
@ -103,24 +103,20 @@ def resolv_kl(liste, lettres):
|
||||
# if validate == len(kl):
|
||||
# klFilter.append(mot)
|
||||
|
||||
def resolv_bl(liste, lettres):
|
||||
# Bad Letters : élimination des mots contenant des lettres invalidées (hors pattern)
|
||||
#if bl:
|
||||
# if klFilter:
|
||||
# mots = klFilter
|
||||
# elif patternFilter:
|
||||
# mots = patternFilter
|
||||
# else:
|
||||
# mots = goodLen
|
||||
# for mot in mots:
|
||||
# invalidate = 0
|
||||
# for l in bl:
|
||||
# if l in mot and l in pattern:
|
||||
# if pattern.count(l) != mot.count(l):
|
||||
# invalidate += 1
|
||||
# elif l in mot:
|
||||
# invalidate += 1
|
||||
# if invalidate == 0:
|
||||
# blFilter.append(mot)
|
||||
lettres = list(set(list(lettres)))
|
||||
MotsSuppr = []
|
||||
for mot in liste:
|
||||
for lettre in lettres:
|
||||
if lettre in mot:
|
||||
MotsSuppr.append(mot)
|
||||
for mot in MotsSuppr:
|
||||
try:
|
||||
liste.pop(liste.index(mot))
|
||||
except:
|
||||
pass
|
||||
return liste
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -187,12 +183,6 @@ if __name__ == "__main__":
|
||||
print("Tu as merdé ta pattern petit scarabé !")
|
||||
exit(2)
|
||||
|
||||
# Known Letters
|
||||
kl = args.knownLetters
|
||||
|
||||
# Bad Letters
|
||||
bl = args.badLetters
|
||||
|
||||
liste = load_dict(args.dictionary)
|
||||
liste = resolv_len(liste, args.nbLetters)
|
||||
liste = resolv_fl(liste, args.firstLetter)
|
||||
@ -209,6 +199,8 @@ if __name__ == "__main__":
|
||||
exit(0)
|
||||
if args.knownLetters:
|
||||
liste = resolv_kl(liste, args.knownLetters)
|
||||
if args.badLetters:
|
||||
liste = resolv_bl(liste, args.badLetters)
|
||||
if len(liste) > 1:
|
||||
print(liste)
|
||||
print(f"Il y a {len(liste)} mots dans la liste")
|
||||
|
Loading…
Reference in New Issue
Block a user