Jon
The algorithm is not complicated; it's just five nested loops, each with
a counter that increments by 1, while ensuring that no duplicates occur.
So for loop 1 the counter, g1, goes from 1 to N-4, where N is the number
of numbers (20 in your case), in loop 2, g2 goes from g1+1 to N-3, etc,
until in loop 5, g5 goes from g4+1 to N.
Then the combination for a particular set of indexes, g1,g2,g3,g4,g5 is
the concatenation of the five related numbers from your number list.
This requires five TOs, a relationship between each index and the
NumberID for your list of N numbers.
Incidentally, this process will generate 15504 combinations, 20!/(15!*5!).
Let me know if you'd like to see my demo.
Ross
Jon Rosen wrote:
> I'm looking for a script or algorithm to do combinations/combinadics,
> similar to what you would use if you were calculating lottery
> combinations or word combinations. Let's say I want to get all
> combinations, 5 digits at a time, from a list of 20 (or more) numbers.
> Do you happen to have a script to do this with FileMaker? I want to save
> the results in records, and because there could be a large number of
> results, so I think a script would be more appropriate than a custom
> function. Thanks for your help.
>
> Regards,
>
> Jon
> -------------------------------------------
> Jon Rosen
> Principal Developer
> ErgoSoma
> FileMaker Database Design & Development
> Voice: 954-447-2907
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au