Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Matched pairs represented by triplets??
Message
De
10/03/2003 11:22:25
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00763480
Message ID:
00763696
Vues:
15
Please re-read my thread. This does not answer the problem. I am attempting to determine the least number of triplets (a-j) that will cover the 10 matched pairs listed.

Neil

>Neil,
>
>The number of combinations of 10 things taken 3 at a time is 10! / ( (10-3)! * 3! ) or 120.
>
>this sql will give you all the permutations of N items taken 3 at a time:
>
>
create cursor x1 ( i1 i )
>for i = 1 to 10
>   insert into x1 values ( i )
>endfor
>
>
>select x1.i1, x2.i1, x3.i1 ;
>   from x1 ;
>   left join x1 as x2 on x1.i1 != x2.i1 ;
>   left join x1 as x3 on x1.i1 != x3.i1 and x2.i1 != x3.i1 ;
>   into cursor ThePermutations
>
>given 10 items in x1 the result will have 720 rows because it considers 1,2,3 and 1,3,2 and 2,1,3 and 2,3,1 and 3,1,2 and 3,2,1 as distinct permutations, for combinations you don't care about the order so any one of those 6 results is all you want.
>
>
select x1.i1 as i1, x2.i1 as i2, x3.i1 as i3 ;
>   from x1 ;
>   left join x1 as x2 on x1.i1 < x2.i1 ;
>   left join x1 as x3 on x1.i1 < x3.i1 and x2.i1 < x3.i1 ;
>   into cursor TheCombinations ;
>   having ! isnull( i2 ) and ! isnull( i3 )
>
>This will eliminate the replications based on order and give you just the combinations.
>
>>I have 10 comma delimited number pairs:
>>
>>I have 10 letters. Each of the letters can represent 3 of the of the comma delimited pairs. ie:
>>
>>
>>How do I figure out the least number of letters that will represent all of the comma delimited number pairs. ie: I was able to eye ball the list and figure out that j,i,f,a will do it. But how do you program logic. How about representing the numbers in data tables and using joins and unions. Any takers?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform