PDA

View Full Version : Three Book Payment To Do This Calculation


David Sklansky
04-30-2003, 06:50 AM
I will send three of my books of your choice to the first person who correctly answers this for me showing his work.

The game is deuce to seven loball. Except to make the calculations easier we will say that flushes don't count against you. Another player stands pat indicating a pat ten or better. You have a T6543. What is your chances of winning losing or pushing.

The reason why this problem is time consuming is that you can't simply count the number of hands that beat you vs. those that don't. Because of the cards in your hand. For instance there is normally 1024 ways to be dealt a 75432. Now there are only 432 ways. But an 87432 can be dealt 576 ways and a 98752 can be dealt 768 ways.

droidboy
04-30-2003, 11:07 AM
<pre><font class="small">code:</font><hr>
T6543 beats 54096 hands
T6543 ties 243 hands
T6543 bested by 75028 hands
</pre><hr>

droidboy
04-30-2003, 11:15 AM
http://www.cs.wisc.edu/~prock/poker/lowball.txt

droidboy
04-30-2003, 11:23 AM
just in case:

<pre><font class="small">code:</font><hr>
p(win) = 54096/129367 ~= .4181
p(tie) = 243/129367 ~= .0018
p(lose) = 75028/129367 ~= .5799
</pre><hr>

CrackerZack
04-30-2003, 11:36 AM
Not quite right plus I don't think this is what he meant when he said show your work.

droidboy
04-30-2003, 11:43 AM
last solution was for A-5, not 2-7

Here is the answer for 2-7:

<pre><font class="small">code:</font><hr>
T6543 beats 28848 hands p(win) = .5035
T6543 ties 243 hands p(tie) = .0042
T6543 bested by 28200 hands p(lose) = .4922
</pre><hr>

http://www.cs.wisc.edu/~prock/poker/loball.txt

Ed Miller
04-30-2003, 11:44 AM
I wrote a program to generate the total number of pat 9's and 10's given the dead cards (ignoring straights). The algorithm is recursive and uses this equation:

Total n card hands m or better = (3 or 4 as appropriate, given m) * total n-1 card hands m-1 or better + total n card hands m-1 or better

The full source code is at the bottom.. but this is the output of the program:

The number of possible hands pat 7 or better are: 2376
The number of possible hands pat 8 or better are: 9612
The number of possible hands pat 9 or better are: 28560
The number of possible hands pat 10 or better are: 59523

The program ignores straights, so the actual numbers are:

Pat 9's: 28560 - (324 + 324 + 432 + 576) = 26904
Pat 10's: 59523 - (324 + 324 + 432 + 576 + 576) = 57291

In addition to the pat 9's, the following hands beat T6543:

T5432
T6432
T6532
T6542

each of which is made 324 ways. So the total number of hands that beats T6543 is 26904 + 324*4 = 28200.

Your chance of losing is 28200/57291 = 49.22%
Your chance of pushing is 243/57291 = 0.42%
Your chance of winning is 28848/57291 = 50.35%

C Source code for my program:

<pre><font class="small">code:</font><hr>
unsigned long num_hands(int cards_in_hand, int highest_card)
{
if (highest_card == cards_in_hand) return 0;
if (cards_in_hand == 1)
{
switch (highest_card)
{
case 2: return 4;
case 3: return 7;
case 4: return 10;
case 5: return 13;
case 6: return 16;
case 7: return 20;
case 8: return 24;
case 9: return 28;
case 10: return 31;
}
}
return ( highest_card &gt; 6 &amp;&amp; highest_card &lt; 10 ? 4l : 3l) * num_hands(cards_in_hand - 1, highest_card - 1) + num_hands(cards_in_hand, highest_card - 1);
}

int main()
{
int i;
for ( i = 7 ; i &lt; 11 ; i++ ) printf("The number of possible hands pat %d or better are: %u\n", i, num_hands(5, i));
}
</pre><hr>

CrackerZack
04-30-2003, 11:47 AM
And I was spending my time trying to do it with Combinations, factorials, etc. I knew I should've just opened up IntelliJ.

Ed Miller
04-30-2003, 11:47 AM
I was bested by one minute....

but I should get points because my code was like 10x more elegant...

Homer
04-30-2003, 11:56 AM
I wrote a program in VB to calculate this. The answers I got are:

Hands that beat T6543 = 28200
Hands that lose to T6543 = 28848
Hands that push with T6543 = 243

I could provide the source code if desired but it is long and unelegant.

...now off to see if by some miracle I was the first to provide an answer (yeah right!).

-- Homer

Homer
04-30-2003, 11:58 AM
I'm quite impressed majorkong. My VB code is about 3 times as long as yours. Of course I don't know jack [censored] about programming so I think I'll just pat myself on the back for at least getting the correct answer! /forums/images/icons/grin.gif

-- Homer

Ed Miller
04-30-2003, 12:05 PM
And to think, I quit my job writing code for a living to play poker. I think I chose very poorly...

droidboy
04-30-2003, 12:10 PM
I'll give you points, but they are for obfuscation, not elegance. I can't understand a whit of your code.

/forums/images/icons/smile.gif

Ed Miller
04-30-2003, 12:13 PM
Case closed... /forums/images/icons/tongue.gif

Homer
04-30-2003, 12:14 PM
Hell no. Take a shot at poker while you're still young. I think you said before that you are 24-25 (correct me if I'm wrong), so if you're going to give it a shot now is the time. I'm about the same age and am presently sitting behind a computer slaving away, dreaming about being in your shoes, getting out there and living life. Sitting behind a desk all day isn't living. Go play poker. Have fun. Make some money. Live.

-- An overly dramatic Homer

droidboy
04-30-2003, 12:17 PM
Five, one for each card.

Is there something wrong with looping? As opposed to two term recursion? What am I missing? Maybe I'm just biased, but I my code is fairly straightforward. I really can't see how your code works. I believe it does, but I just can't see it.

David Sklansky
04-30-2003, 06:20 PM
Droidboy, Homer J, and Majorkong. Pleae email me your address and choice of books. There may also be an opportunity to make some money as long as your programs can answer the more general questions for hand vs minimum pat hand. My email adress is Dsklansky@aol.com

PS I just guessed at the answer that is 50-50. Not bad huh?

Homer
04-30-2003, 08:02 PM
Thanks for your generosity David. I will send an e-mail to you with my selections. As for development of code for the more general question, I will leave that to Majorkong and/or Droidboy, as it is obvious that their programming skills are far more advanced than mine. If neither of them is interested, then I would of course be happy to help.

-- Thanks, Homer

CrackerZack
05-01-2003, 09:43 AM
I'm a resident geek also but took the questions too literally and tried to do the math solution. The combinations were a nightmare. As for a generic program that will do things like this, post some reqt's and I'll be involved in writing some of it.

Homer
05-01-2003, 09:53 AM
I'm a resident geek

I think most of us here are resident geeks! /forums/images/icons/tongue.gif

When David said that he might actually consider paying someone for the general solution, I was quite surprised, as I am certain that there are 10-20 people here who would be able to do it, and would be willing to do it free of charge (perhaps a dedication in David's next book would do....jk).

-- Homer

MickeyMcD
05-02-2003, 12:43 PM
know what sklansky, u can have my fifty bucks Im just going to buy the books just thinking about this problem makes my head hurt

Mickey

tewall
05-02-2003, 03:13 PM
It looks like his code works with some supplmental arithmetic, whereas yours gives the answer. I agree with you that your code is much easier to read. However MK deserves credit for thinking of doing it the way he did. I certainly wouldn't have thought of that.

I did have one question on yours, however. Why did you include the "A" when you never used it?