Ok, so this is what i want to do and i really need your help guys, because i’m new with php…
So lets say i have 5 letters: A; B; C; D and E. and what i want a php script to do is to generate all possible combinations of those letters with no repeats. For example:
ABCDE
ECDBA
CBAED
…
and so on, until theres no combinations left (543*2=120 combinations)
so if you can, please help…
what you want to do is count in a different base (ie: decimal=base 10, hex=base 16, binary=base 2). so, build a ticker similar to an analog speedometer.
take your variables (A, B, C, D, E) and put them into an array. count the array elements and construct a string of that length, starting with 0-0-0-0-0. next build a function or class that increments the 1st digit. when it reaches 4, it increments the next digit by one and returns itself to 0. the function/class will probably need to be recursive. have it terminate at 4-4-4-4-4
by the way: props for the creative problem. it took me quite a while to figure out the best way to think about it
well, there’s a problem… you see i want that all letters would appear only once per combination. so letters combination:
A B C D E is cool, but
A A B C E is not cool
so making speedometer would’nt work, because there would be such comninations like:
0-0-0-0-0
0-0-0-0-1 and so on…
On a side note, if you have a scientific calculator handy it should have an ! (exclamation mark) button which is the factorial function. It returns the number of combinations of how much discrete information you have. Like ABCDE would have 5, so that’s 5 factorial (5!) which gives 120. You probably already knew that, but it might be interesting to someone else