LQ Newbie
Registered: Mar 2004
Distribution: debian sarge, 2.6.6, and ALSA finally works!!
Posts: 18
Rep:
|
the easiestway is to look at a simple example.
If you create the combinations of three numbers from 6 numbers (20 combinations ), then you can see how the pattern builds up, just extend the idea to your 5 from 52
i.e Source cards, 1,2,3,4,5,6
as output want all three card combinations
1,2,3
1,2,4
1,2,5
1,2,6 Have reached maximum value on card 3, so increment card 2
1,3,4 Note, when increment card 2, card 3 must have a start value one higher
1,3,5
1,3,6 reached max again, inc card2, set card3 = card2+1
1,4,5
1,4,6 and again, inc card 2, set card3 = card2+1
1,5,6 card 2 is card3MaxValue-1, cannot go any higher with card 2, so now increment card 1, card2 = card1+1, card3=card2+1
2,3,4 inc card 3
2,3,5 inc card 3
2,3,6 inc card 3, card 3 = max, inc card 2
2,4,5 inc card 3
2,4,6 inc card 3, card 3 = max, inc card 2
2,5,6 card2=card3MaxValue-1, inc card1, card2=card1+1. card3 = card2+1
3,4,5 inc card 3
3,4,6 card3 at max, inc card 2
3,5,6 card2 = card3MaxValue-1, inc card1, card2 = card1+1, card3 = card2+1
4,5,6 card1=card2MaxValue-1, card2 = card3MaxValue-1, all cards at max value, end of sequenuce
Hope this helps
|