Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findWord(aListChars, aWord, aTrialNum):
- cnt = 1
- words = []
- found = False
- while cnt < aTrialNum:
- word = ""
- buff = [e for e in aListChars]
- while len(buff) > 0:
- rnd = random.randrange(len(buff))
- word += buff.pop(rnd)
- if word == aWord: #"chrząszcz"
- print("DBUG: Match: %s %d" % (word, cnt))
- found = True
- break
- cnt += 1
- if found:
- break
- # DBUG
- # print(word)
- # if not (word in words):
- # words.append(word)
- return found
- l = ["z","z","s","r","c","h","c","z","ą"]
- w = "chrząszcz"
- print(find_word(l, w, 20000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement