|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I would like to list all the ways in which the following can be rearranged:
A B C D E That is, I would like the program to list all the combinations/permutations, or whatever (i.e. ABCDE, ABCED, ABDCE etc.). If this was all I wanted to do then it should be easy to solve via five nested For...Next loops. But there is an added factor. I do not know in advance whether the number of letters will be 5, 6 (e.g. ABCDEF), 10 (e.g. ABCDEFGHIJ) or any other number. I did not think that this would make the problem more difficult, but I cannot see how to generate a code to deal with this. Any suggestions gratefully received. |
|
#2
|
|||
|
|||
|
Hi,
Don't have time to write out the entire code, but I'd suggest a recursive procedure. As permutations are inherently defined recursively, this shouldn't be too hard. Mind the stack though, recursion tends to exhaust the stack very rapidly. Your five nested For..Next's are basically a recursion too, but with a predetermined number of recursions. Rgrds, Michiel |
|
#3
|
|||
|
|||
|
First you need to define the ground rules. Are you working only with capitalized alphabetic characters, or will other characters be involved. The "universe" of allowable characters will determine how many steps are needed in your loop for each column.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#4
|
|||
|
|||
|
i have added some program wich i wrote earlier. hope it helps.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > This should be easy ... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|