"Enkh" <enkhtr.DeleteThis@yahoo.com> wrote in message
news:7643fe57.0412032224.2cb10ad0@posting.google.com...
> Hi,
>
> I'm looking for a algorithm that creates unique sets from distinct
> sets. For example, I have the following 3 sets that I want to create
> different sets from.
>
> Car: Mercedes, Honda, Toyota
> Drink: water, juice, soda
> Country: Brazil, Canada, England
>
> The sets should have only one set item from the set. For example the
> sets generated would be like:
>
> Mercedes
> Honda
> Toyota
> water
> juice
> soday
> Brazil
> Canada
> England
> Mercedes, water, Brazil
> water, Brazil
> Mercedes, Brazil
>
> So these sets would be necessarily unique and will be all
> possible-combinations of sets without two elements of one set being
> together:
Ok, so the Permutation{water, Brazil} and the Permutation {Brazil, water} are to
be considered the same thing? If the ordering is irrelevant, (the two should be
counted only once) then this is probably a Combination:
{ Mercedes|Honda|Toyota, water|juice|soda, Brazil|Canada|England }.
This could be implemented as a nested loop structure, in pseudocode like so:
for( Cars= 0..Toyota )
for( Drinks= 0..soda )
for( Countries= 0..England )
append_result(Cars, Drinks, Countries);
Note that I've used 0 to indicate an empty, so that {0,0,England} represents the
set {England}.
-

:-
AngleWyrm