Word sorting / permutation w/ array?
Hello everyone, I have a quick question regarding a (most likely) simple problem I am having with a Java program.
I am trying to find out how to display possible instances (permutations) of four words. I am putting these four words in an array that stores a max of 4.
I know the final code has to use an array, and I am guessing a couple of for loops as well. Am I even right on this assumption?
How I have it is getting four input boxes as strings and then have it display the possibilities. So, for example, the words one, two, three, and four would display the 24 possible combinations on one line per combination:
1) one two three four
2) two one three four
3) two one four three
The only code I have that is at all remotely similar is permutations that actually scramble the acutal words (example: OK sorted to KO). Does anyone know a simple way to do this, which involves an array and not several pages of code? My problem is that I am unfamiliar with how Java does / can do permutations of words.
Thanks in advance!
Last edited by boomchip; 11-14-2005 at 08:01 AM.
In your array of words you are storing strings at each of four positions. Your permutation is just a permutation of indexes 0 to 3 - then plug in the values from the original array ...
It should be easy to adapt the code you have to your problem since a word can be thought of and addressed as an array of characters ... and this is what your code is probably doing.
By fulcanelli in forum Java
Last Post: 11-12-2005, 01:38 PM
Last Post: 11-01-2005, 09:05 AM
By kanakatam in forum Java
Last Post: 04-15-2005, 09:06 PM
By Jason Salas in forum ASP.NET
Last Post: 04-20-2003, 11:39 PM
By Jim Drohan in forum Java
Last Post: 11-22-2000, 11:05 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center