On 15 June 2004 00:07, Michael Benbow wrote: > Thanks Mike, > > I have read up a lot on permutation but I'm not completely sure that > this will solve my problem. From what I can gather > permutation takes a > sample (i.e. ABC) and tells you how many different ways it > can arrange > the letters, with order mattering. What I need to do is take > a variable > number of groups (in my example, 3) and then display the combinations > of ways that my sample (in my example, 2) can be spread across > the groups.
Ah, yes -- sorry. Something in your original post must have made me think you just wanted the number of ways, not the actual permutations. (And, in any case, I don't think this *is* actually a permutation, so I think I was doubly trigger happy!) [...] > The example again is as follows.. > > A [1][2] B C > A B [1][2] C > A B C [1][2] > A [1] B [2] C > A B [1] C [2] > A [1] B C [2] > A [2] B [1] C > A [2] C C [1] > A B [2] C [1] > > Think of the letters as being static amongst all possible > combinations, and the numbers as the piece of data which is > varying. In my actual code both fields are integers but this > isn't really important here. I've been fiddling with this for half an hour or so, and I'm pretty convinced the solution is going to involve a recursive function. However, it might help if you could say exactly what you want as a result: printed out (in a format similar to the above), inserted into a database (how?), or some sort of PHP data structure (such as a multi-level array) containing all the possible results? Don't guarantee to come up with a final (or even an approximate!) solution, but knowing what you're trying to work towards would help...! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php