52 choose 7

B

bob

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?

Thanks.
 
A

Alf P. Steinbach

* (e-mail address removed):
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?

Define

* "best"

* what the C++ question is.
 
A

Alf P. Steinbach

* said:
asymptotically efficient...

That's a no-brainer, if you think about it (oops).

jeez I really dislike this kind of ppl

And the C++ question was?

Btw., don't multipost articles; read up on netiquette, please.
 
R

Robert J. Hansen

The question makes me think you haven't thought about the problem for
long enough to have yet moved into the "so how do I implement this?"
range. What you're asking is algorithmic analysis, not
language-specific.

That said, I'd suggest you start thinking about whether you really need
this massive set. With 133,784,560 different elements in the set,
you're talking about a nontrivial amount of data. If your ultimate
goal is to look through the set looking for the frequency certain hands
come up, you're going to be far better served solving your problem via
math and statistics instead of exhaustive analysis.

Once you understand your problem well, then start thinking about what
language to use to solve your problem. Then we'll be happy to help if
you have questions about how to turn your algorithm into C++.

But as is, you don't seem to understand your problem very well, and
we're not going to understand your problem for you.
 
R

Ron Natalie

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?
52 ? 7 if you are using APL.
 
D

David White

Robert said:
The question makes me think you haven't thought about the problem for
long enough to have yet moved into the "so how do I implement this?"
range. What you're asking is algorithmic analysis, not
language-specific.

That said, I'd suggest you start thinking about whether you really
need this massive set. With 133,784,560 different elements in the
set, you're talking about a nontrivial amount of data.

But you don't necessarily need to keep it all. Depending on what you are
doing you might only need to look at each one and throw it away. On today's
PCs, 133 million hands can be analysed pretty quickly.
If your
ultimate goal is to look through the set looking for the frequency
certain hands come up, you're going to be far better served solving
your problem via math and statistics instead of exhaustive analysis.

I don't think so. Just for fun I once computed the probabilities of various
poker hands using maths alone, but it's very easy to make mistakes that way,
and how do you prove that you didn't make a mistake? Sometime after writing
them all out in a nice table, I discovered that the probability I'd
calculated for getting two pairs when dealt five cards was a factor of 2 out
(1/21 instead of 1/10.5) because I had made a mistake. On the other hand,
it's hard to go wrong if you simply deal every possible hand and count the
two-pairs among them. An additional advantage is that you can make the
criteria that constitute a matching hand anything you like without having to
work out each time how to work it out.

DW
 
G

Guest

The original post was:

<quote>
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?
</quote>

asymptotically efficient...

The problem of choosing 7 cards out of 52 has nothing to do with
asymptotical efficiency.

Ali
 
G

Guest

Ali Çehreli said:
The original post was:

<quote>
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?
</quote>



The problem of choosing 7 cards out of 52 has nothing to do with
asymptotical efficiency.

Never mind; I misread what I quoted :(

Ali
 
Z

Zara

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?

Thanks.

How about using for(..) loops?
It is trivial, if you think a little.
Do you homework
 
G

Guest

Memory-efficient or time-efficient?

you should ask who started the thread. i'd say both
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top