312 views

# Combinations of Poker hand

1. 2 weeks ago

### Michael M

Aug 10

Hello,

I am terrible at figuring this stuff out and could use some help. I need to figure out all the possible combinations of a 4 card poker hand: Ad Ac Kd Ks . So it would be AcAdKsKd, KdAcKsAd, KsKdAcAd and so forth using the 4 different card strings. I think there are 24 different combos? I found some code here but I couldn't get it to work right.

Any help would be greatly appreciated.

Thanks

2. ### Norman P

Aug 10 Xojo Inc

https://betterexplained.com/articles/easy-permutations-and-combinations/

you're interested in combinations because order doesnt matter

getting Ad Ac Kd Ks is the same hand as Ac Kd Ks Ad (and several others depending on how the cards are dealt)

3. ### Michael M

Aug 10

Hey. Yeah the order does not matter. I have a large text file I need to search thru but I cannot make heads or tails on how the card syntax is ordered..some have high cards first, some low and many in between so its kind of random. So the only way to do it is too run thru every possible ordering of the same hand.

4. ### Dave S

Aug 10 San Diego, California USA

unique combinations of 4 playing cards, regardless of order is 6,479,400
raise that to the standard 5 card poker hand and it is 311,875,200

while we are at it :)
1 card = 52
2 cards = 2,652
3 cards = 132,600

5. ### Michael M

Aug 10

Hey..yeah I know the total possible combinations but I need to know how to return the number of combinations of ONE 4 card hand as far as its ordering. So how would I return all of the combinations of AdAcKsKh ? It would be something like this:

Thanks

6. ### Douglas H

Aug 10 Pre-Release Testers, Xojo Pro

@Michael M Hey..yeah I know the total possible combinations but I need to know how to return the number of combinations of ONE 4 card hand as far as its ordering. So how would I return all of the combinations of AdAcKsKh ? It would be something like this:

Thanks

You are still using the word combinations where it appears you mean permutations. I'd suggest you read the link Norman gave above.

7. ### Dave S

Aug 10 San Diego, California USA

4*3*2*1
there are 4 possible cards that could be 1st
once you take that , there are 3 that can be 2nd, 2 that could be 3rd

24 Combinations of any 4 unique cards

• When the order doesn't matter, it is a Combination.
• When the order does matter it is a Permutation.

And Douglas... he is looking for COMBINATIONS, as he wants, all the possible order

there is only one permutation of 4 cards taken 4 at a time...
but there are 24 combinations in which those cards can be arranged

8. ### Douglas H

Aug 10 Pre-Release Testers, Xojo Pro

Dave,

@Dave S And Douglas... he is looking for COMBINATIONS, as he wants, all the possible order

there is only one permutation of 4 cards taken 4 at a time...
but there are 24 combinations in which those cards can be arranged

9. ### Norman P

Aug 10 Xojo Inc

permutations - order matters
combinations - order does NOT matter

10. ### Michael M

Aug 10

Hey..ok I get it now. I found this code and it works great:

```Function Permutations(s As String, delimiter As String = ".") As String()
Dim tmpArr() As String
Dim perms() As String
Dim result() As String
Dim firstStr As String
Dim i As Integer
Dim j As Integer

tmpArr = Split(s, delimiter)

if tmpArr.Ubound <= 0 then
result.Append tmpArr(0)
else

firstStr = tmpArr(0)

tmpArr.Remove(0)
perms = Permutations(Join(tmpArr, delimiter))

for i = 0 to perms.Ubound
tmpArr = Split(perms(i), delimiter)
for j = 0 to tmpArr.Ubound + 1
tmpArr.Insert(j, firstStr)
result.Append(Join(tmpArr, delimiter))
tmpArr.Remove(j)
next j
next i

end if

return result

End Function```

thanks for everybodys help in clarifying the difference between permutation and combination.

11. ### Tim H

Aug 10 Pre-Release Testers Portland, OR USA
Edited 2 weeks ago by Tim H

Wouldn't it be easier to sort the cards in the hand so you have a canonical order?

12. last week

### Bryan D

Aug 11 Pre-Release Testers, Xojo Pro

You can easily compute the probability of certain hands using the hypergeometric distribution. I have this in a function if you like.