Set algorithm

G

Guest

Guest
Archived from groups: comp.ai.games (More info?)

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:

Mercedes, Honda, Brazil (invalid because Mercedes, Honda are from the
same set)

What kind of algorithm should I use for creating this.

Any suggestions?

Thanks,

Enkh
 
G

Guest

Guest
Archived from groups: comp.ai.games (More info?)

"Enkh" <enkhtr@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
 
G

Guest

Guest
Archived from groups: comp.ai.games (More info?)

"AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message
news:MGEtd.157171$V41.115107@attbi_s52...
>
> 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}.

Also, the length of the result set will be:
(length_list1 +1) * (length_list2 +1) * ... * (length_listN + 1) for N lists.
In the example this is:
(3+1) * (3+1) * (3+1) = 4*4*4 = 64 results.

-:|:-
AngleWyrm
 

TRENDING THREADS