Fonction "Bad Letters"

This commit is contained in:
Antoine Van Elstraete 2022-01-24 21:46:06 +01:00
parent f9cf15d487
commit e2452c1434

View File

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