All possible combinations algorithm
Michael Halcrow
mike at halcrow.us
Thu Jun 16 11:55:26 MDT 2005
On Tue, Jun 14, 2005 at 11:03:29PM -0600, Dan Wilson wrote:
> PS. This is for PHP, so if you have code examples, that would be
> even better.
For those who are interested in further exploring this problem in a
real programming language, I found this excellent little collection of
routines:
http://www.cs.berkeley.edu/~fateman/mma1.6/comb.lisp
This comment should give you a good idea of how you can build your
algorithm recursively:
;; otherwise take an element, e, out of the bag.
;; generate all permutations of the remaining elements.
;; and add e to the front of each of these.
;; do this for all possible e to generate all permutations.
Mmmmmm.... Lisp..... almost as scrumptious as Objective Caml...
Mike
.___________________________________________________________________.
Michael A. Halcrow
Security Software Engineer, IBM Linux Technology Center
GnuPG Fingerprint: 419C 5B1E 948A FA73 A54C 20F5 DB40 8531 6DCA 8769
I stole this Sig.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://plug.org/pipermail/plug/attachments/20050616/3919c998/attachment.bin
More information about the PLUG
mailing list