It is printing out all the possible values instead of just one word. For example, if word1 = "is", then it will print out "is" and "si". If word1 is "will", the results will be
What is the problem and how do I fix it?
cc11rocks aka John Price
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
I am making an "Unscrambler". Basically, it should pick up a String, then compare it to the list of words. If you type in "lliw", it should print out "will". If you type in "wlli", it should still print out "will". What is actually happening is above.
John Price aka cc11rocks
It's good that you got the code to work. However...
That code appears to compare the input string to all possible permutations of the letters in each word of the list. There's a process which only requires one comparison for each word in the list; this would be both faster (there are 5,040 permutations of a 7-letter word) and easier to read. I won't tell you what it is, just that it requires pre-processing each word in the list to make that comparison possible.