Subj : Re: cards To : comp.programming From : Willem Date : Tue Oct 04 2005 10:44 pm bob@coolgroups.com wrote: ) Roger Willcocks wrote: )> wrote in message )> news:1128448274.935279.78050@g47g2000cwa.googlegroups.com... )> > Let's say you want to iterate through all of the possible combinations )> > that occur when you choose 7 cards from a fifty two card deck. Anyone )> > know the best way to do this? )> )> Are the same cards, but in a different order, a different combination? ) ) I'm trying to analyze the Texas Holdem probabilities. So order doesn't matter, I guess ? Well then it's real easy: for (c1 = 0; c1 < 52-6; c1++) for (c2 = c1+1; c2 < 52-5; c2++) for (c3 = c2+1; c3 < 52-4; c3++) for (c4 = c3+1; c4 < 52-3; c4++) for (c5 = c4+1; c5 < 52-2; c5++) for (c6 = c5+1; c6 < 52-1; c6++) for (c7 = c6+1; c7 < 52-0; c7++) do_something(c1,c2,c3,c4,c5,c6,c7); If you want a more general routine that can handle different numbers of cards, that's not much more complex, but quite a bit harder to think of. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT .