• Threads: 1
  • Posts: 1
Joined: Nov 16, 2022
November 16th, 2022 at 10:16:26 AM permalink
Can anyone provide a similar table for the suits in 7-card hands?

Quote: Wizard

I've been thinking about this off and on. I offer the following solution for those like me who are strong in math and weak in programming.

Before I go further, let me remind you the formula for choosing k out of n items, with replacement, is combin(n+k-1,k). Think of the deck having k-1 "repeat" cards.

First, let's ask the question how many classes of 5-card hands are there?

  1. There are combin(13,5)=1,287 ways all five cards can be in the same suit.
  2. There are combin(13,4)*13=9,295 ways four cards can be in the same suit and one singleton in another suit.
  3. There are combin(13,3)*combin(13,2)=22,308 ways 3 cards can be in the same suit and 2 in another suit.
  4. There are combin(13,3)*combin(13+2-1,2)=26,026 ways 3 cards can be in the same suit and 1 each in two other suits.
  5. There are (COMBIN(13,2)*(COMBIN(13,2)+1)/2)*13=40,053 ways 2 cards can be in two separate suits and 1 in a third suit.
  6. There are COMBIN(13,2)*COMBIN(13+3-1,3)=35,490 ways 2 cards can be in one suit and 3 singletons in the other 3 suits.

Add that up and you get 133,459.

If you're going to cycle through the whole deck you have to weight all 133,459 by the appropriate number of suits in each class. Here is a table to help you with that.

Suit distribution Comments Ranks Suits Product
5,0 All 1287 4 5148
4,1 All 9295 12 111540
3,2 All 22308 12 267696
3,1,1 Matching singletons 3718 12 44616
3,1,1 Non-matching singletons 22308 24 535392
2,2,1 Both matching ranks 1014 12 12168
2,2,1 One matching rank 11154 24 267696
2,2,1 No matching ranks 27885 24 669240
2,1,1,1 Matching ranks 1014 4 4056
2,1,1,1 One matching rank 12168 12 146016
2,1,1,1 No matching ranks 22308 24 535392
Total 134459 2598960

I admit this is not elegant like the solutions posted earlier. It will require more code and just one math error will screw everything up. However, it isn't a memory hog. It should use quite little.

I can confirm the 7-card case has 6,009,159 classes of hands. Upon request, I can supply a similar math table for that.

I'm still working on the bit mapping solution, just for my own programming edification.
link to original post

  • Jump to: