# Combinations of Poker hand

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

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)

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.

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

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

[quote=344985:@Michael Martz]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[/quote]

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

432*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

Dave,

[quote=344989:@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[/quote]

permutations - order matters
combinations - order does NOT matter

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

[code]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[/code]

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

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

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