All possible combinations algorithm

Jordan Gunderson jordy at gundy.org
Wed Jun 15 09:42:10 MDT 2005


Here it is with tardmode taken off.  The wording is a little better.

> Hey Dan,
> 
> Thanks for the math question.  If the number of elements is E, the number 
> of possible arrangements is equal to the E! (read "E factoral").  It's E 
> times all of the integers between E and zero.  Be careful though, because it 
> gets really big really fast.
> 
> In this example, I started out with one element in the first sequence.  In each following 
> sequence I placed the next element in all of the possible positions from 
> the possibilities (separated by dashes) of the preceding sequence, starting in the last 
> position and moving forward.
> 
> Thanks for the fun question.  Jordy
> ______________________________
> 
> A     1 Elements = 1! = 1 = 1
> 
> AB    2 Elements = 2! = 2*1 = 2
> -- 
> BA
> 
> ABC   3 Elements = 3! = 3*2*1 = 6
> ACB
> CAB
> ---
> BAC
> BCA
> CAB
> 
> ABCD  4 Elements = 4! = 4*3*2*1 = 24
> ABDC
> ADBC
> DABC
> ----
> ACBD
> ACDB
> ADCB
> DACB
> ----
> CABD
> CADB
> CDAB
> DCAB
> ----
> BACD
> BADC
> BDAC
> DBAC
> ----
> BCAD
> BCDA
> BDCA
> DBCA
> ----
> CABD
> CADB
> CDAB
> DCAB
> ----
> .===================================.
> | This has been a P.L.U.G. mailing. |
> |      Don't Fear the Penguin.      |
> |  IRC: #utah at irc.freenode.net   |
> `==================================='




More information about the PLUG mailing list