Google Answers Logo
View Question
 
Q: Combinatorics Formula for Cards ( No Answer,   1 Comment )
Question  
Subject: Combinatorics Formula for Cards
Category: Computers > Algorithms
Asked by: flemlord-ga
List Price: $100.00
Posted: 26 Jul 2006 13:01 PDT
Expires: 25 Aug 2006 13:01 PDT
Question ID: 749817
Combinatorics Formula for Cards

I have five random cards of a standard 52-card deck, two face-down and
three face-up. I need a formula that generates a unique sequential
number for each possible combination of five cards.

It matters what cards are face-down vs. what cards are face-up. But it
doesn't matter what order the face-up cards are in or what order the
face-down cards are in.  (If it didn't matter what order the cards
were in, this would be easy. There would be 2,598,960
(52x51x50x49x48/2/3/4/5) possible combinations.)

Example 1:    Ah Ac | Kh Qh Jh     is the same as
              Ac Ah | Jh Kh Qh

Example 2:    Ah Ac | Kh Qh Jh     is not the same as
              Jh Ac | Kh Qh Ah

There are 25,989,600 possible combinations (52*51/2 x 50*49*48/2/3 =
1326 x 19600 = 25,989,600). Which is too many for us to keep in memory
(this is for a computer program), so I'm adding some additional rules
which will reduce the number of unique combinations.

Reduction Rule #1: 

Suits are interchangable as long of all cards of a suit remain the same suit.

For example, 

Example 3:  Ah Kh | Qh Jh Th    is the same as
            Ac Kc | Qc Jc Tc    is the same as
            Ad Kd | Qd Jd Td

Example 4:  Ah Kh | Qc Jc Tc    is not the same as
            Ad Kd | Qd Jd Td    is not the same as
            Ah Kd | Qh Jd Td

Example 5:  Ah Kh | Qh Jh Tc    is the same as
            Ah Kh | Qh Jh Td    is the same as
            As Ks | Qs Js Td

Reduction Rule #2: 

A hand with a face-down card having no matching cards of that suit, is
identical to a hand with a face-down card having one matching board
card of that suit.

Example 6:  Ah Kd | Qc Jc Ts    is the same as
            Ah Kd | Qc Jc Th    is the same as
            Ah Kd | Qc Jc Td 

Example 7:  Ah Kd | Qd Jc Ts    is the same as
            Ad Kh | Qd Jc Ts    is the same as
            Ac Ks | Qd Jc Ts

Example 8:  Ah Kd | Qc Jc Ts    is not the same as
            Ah Kc | Qc Jc Ts

Example 9:  Ah Kd | Qc Jc Ts    is not the same as
            Ah Kh | Qc Jc Ts    is not the same as
            Ah Kh | Qc Jc Th

Note: After taking Reduction Rule #2 into account, the only time we
should have a card combination that uses all four different suits
would be when we have four of a kind (all four cards of one suit). Any
other possible combination should be reducable to a fewer number of
suits.


What I Need: 

I need a formula or short computer program that will accept five cards
as variables/parameters and returns a unique integer value that
reflects the rules above. The unique integers should be sequential so
that, if there are 1M unique integers, the integers should be numbered
0-1M.

If you would like, you can assume the integers passed as parameters
have already had the two reduction rules applied to them. I'm capable
of taking a raw formula and doing the work to turn it into a program.

Please include as much of the "theory" behind the formula as possible.


Qualifications for computer programs:

We realize applying Rule #1 and #2 may require a programatic solution.
But the bulk of the work should be formulaic. We're not just looking
for a fast code-based approach. Specifically:

1. It is NOT acceptible to do an array search or hash. We want
something faster. Array lookups are ok as long as the arrays are
reasonably sized (see #2).

2. It not acceptible to, at any point in your code, use arrays with
more elements than the total number of unique integers.

3. Speed is an issue. Make sure the program runs in less than, say,
1,000 operations. (A fraction of a second on any modern computer.)

4. Readability is important too. We'd like it to be less than 200 lines.

We'd prefer C# code but will take pseudo-code too.


Hints: 

1. There will be no more than 2.6M unique integers.

2. My understanding is that a mathematician with experience in
combanatorics should have no problem with this.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Combinatorics Formula for Cards
From: jackbond-ga on 08 Aug 2006 09:00 PDT
 
Did you ever receive an answer on this? If not, I've got some code
that I've used in my own poker statistical package that might work for
you.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy