• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Unscrambler issues (Self-Resolved)

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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?
Thanks,
cc11rocks aka John Price
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you start by telling us what you are trying to do, rather than make us guess?
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Thanks,
John Price aka cc11rocks

EDIT: I just figured it out! Had to do two fixes:

Thanks,
cc11rocks aka John Price
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I change line 26 to:

?
Thanks,
cc11rock aka John Price

EDIT: I found a noticeable time improvement with this above code (the new change to line 26).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic