hi,
This is my problem i have programmed a little word unscrambler i have a file wordlist.txt in my python folder and this program works just fine and unscrambles one word at a time but i dont how how to edit it to make it unscramble 10 words at a time can someone please help??
thanks
ps i want it to print the solution in this format:
word1, word2, word3,.......all the way to word10
here is my code
ps it prints the same solution multiple times
and my reasonably fast machine cried and locked up. :lol:
Another possibility would be to test whether your scramble is an anagram for each word in the list. You could do this by seeing whether each letter in the scramble is somewhere in the word, removing that letter from the word if found. Here's the idea:
"""returns True if source is an anagram of target, False
otherwise."""
# speed-up if your dictionary is large:
# if len(source) != len(target): return False
for i in source:
pos = target.find(i)
if pos == -1:
returnFalse
else:
# remove found letter from the target (non-destructively)
target = target[:pos]+target[pos+1:]
returnTrue
In the worst case, this runs O(n^2 * length of dictionary), but with much better performance on average. I found a noticeable speed-up just on this: print isanagram("Hi There", "There Hi")
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.