All possible combinations algorithm

Josh Coates jcoates at
Wed Jun 15 08:45:17 MDT 2005

>Given an array of elements (with an unknown length), I need to find all
>possible combinations of that array.

um...dude - this is kind of a silly question.

is this one of your homework problems..?

Josh Coates

-----Original Message-----
From: plug-bounces at [mailto:plug-bounces at]On Behalf Of
Dan Wilson
Sent: Tuesday, June 14, 2005 11:03 PM
To: plug at
Subject: All possible combinations algorithm

Ok folks, I need the help of some good mathematicians/programmers.  I
know some of you are very good with this type of stuff and I am not.

Given an array of elements (with an unknown length), I need to find all
possible combinations of that array.  Say I have an array with the
values of:

'hey', 'you', and 'guys'

I need an algorithm that allows me to combine each of these array
elements into a string... all combinations:

"hey you guys"
"hey guys you"
"you hey guys"
"you guys hey"
"guys hey you"
"guys you hey"

I'm sure I could pound this out, but I'm sure some of you have done this
in the past or know a specific algorithm that would do the trick.



PS. This is for PHP, so if you have code examples, that would be even

| This has been a P.L.U.G. mailing. |
|      Don't Fear the Penguin.      |
|  IRC: #utah at   |

More information about the PLUG mailing list