# Alice and Bob play at cards

To pass the time Alice and Bob play a simple game of chance where cards are drawn in pairs from a shuffled standard 52-card deck. If two red cards are drawn Alice wins the round. If two black cards are drawn Bob wins the round. Otherwise the round continues and they draw another pair of cards.

To make things interesting, Alice and Bob wager as follows. Before a pair of cards is drawn each player antes up $$1 + n$$ dollars, where $$n$$ is the number of cards drawn in the round so far, with the pot going to the eventual winner of the round. For example, if Bob wins after a sequence black-red,black-black he nets \$4 since each player contributed \$1 before the 1st draw and \$3 before the 2nd. If the deck is exhausted before a round is won then all cards are gathered and reshuffled and the round continues with the fresh deck (without resetting the count for wagering). In the interest of moving things along, Alice and Bob are both willing to play multiple rounds without collecting cards and reshuffling as long as they view the expected value of the next round as close to even. Each has their own rough threshold for “close”, but Alice is faster to call for reshuffles than Bob. After starting the game with 3 remarkable rounds, and having reshuffled once due to an exhausted deck, Alice and Bob are both breaking even with \$0 net gain or loss. So far neither player has been close to calling for a reshuffle, but Bob calls for one now before continuing.

How many cards were drawn in each of the 3 rounds, and who won each round?

Bob must've won the last round, resulting in fewer black cards in the remaining deck, otherwise he wouldn't call for a reshuffle.

Sum of the won money is $$\left(\frac{n}{2}\right)^2$$, where $$n$$ is the number of rounds played. So we have to solve: $$\left(\frac{n_{1}}{2}\right)^2 + \left(\frac{n_{2}}{2}\right)^2 = \left(\frac{n_{3}}{2}\right)^2$$, where $$n_{1},n_{2},n_{3}$$ are the number of rounds, but not necessarily in the correct order. These are Pythagorean triples. We know their sum is larger than 26 and smaller than 52. The only valid solution for this puzzle are (5,12,13) and (8,15,17).

So I'd say: The first solution is unlikely because there would be still 44 cards remaining in the set after the last round, giving Bob a good enough chance to continue. Therefore, I'd say he won round 1 with 16 cards tallied. He felt his chances are still good enough, so he continued. Alice won round 2 with 34 cards tallied, leaving 2 cards (one red and one black). Thus, chances of losing in the next round were zero, so they continued. Bob won third round with 30 cards tallied. He felt 24 cards, where 11 were black and 13 were red were too bad so he asked for a reshuffle.

EDIT: typos for the 3rd round - I repeated 34 but meant 30 and incorrectly calculated the remaining cards.

EDIT2: 17 cards in the first round and 35 in the second is more likely, because it avoids a round with 0% winning chance. In the last round we would then have 20 or 19 cars, making it even less likely for Bob to continue.

• nit-nittting, but should they really have paid antes after the first card oif the third round was drawn ? It is not a potentially round-winning draw because they both knew the color of the (non-winning) card that was about to be drawn... – Evargalo Aug 5 '19 at 11:55
• You're right. Also, I completely overlooked the fact that the number of tallied cards could be odd. So there could be 17 cards tallied in the 1st round and 35 in the second (sum of won money is an integer division of played rounds), leaving no cards. Thus, the round in question would be avoided. Cards would have to be shuffled for round 3. – Ardweaden Aug 5 '19 at 13:24
• @Ardweaden Thanks for your reply! Carlos, who happened to be watching the game, confirms that the rounds were won by Bob, Alice, and Bob with 16, 34, and 30 cards drawn respectively. I should add though that there additional possibilities you didn't discuss (two non-primitive pythagorean triples). I'll expand on this in a separate answer. – 53x15 Aug 5 '19 at 15:27
• @Evargalo Thanks for pointing this out. I guess it would be better to describe the game as drawing two cards at a time with a required ante before each draw so the "potentially round winning" phrasing can be dropped. – 53x15 Aug 5 '19 at 15:30
• @Ardweaden Two other comments on your answer: (1) while the 5-12-13 solution does leave 44 cards after the last round, and this is more than the number remaining with the other candidate discussed, this doesn't really rule anything out since Bob's threshold for "close" is unspecified. (2) I think you meant "chances of losing in the next two draws were zero" rather than "in the next round". The round can cross a reshuffle boundary when the deck is exhausted. I think rephrasing the problem as suggested above where two cards are drawn at a time can reduce the potential ambiguity here. – 53x15 Aug 5 '19 at 15:54

The players ante a sequence of odd numbers, so if a round ends after $$x$$ pairs of cards are drawn then a player's payoff is $$\pm x^2$$.

Since the players break even after three rounds we must have $$x^2 + y^2 = z^2$$, where $$x,y,z$$ are the number of pairs drawn in each round, but not necessarily in that order. The tuple $$(x,y,z)$$ is therefore a Pythagorean triple, which we can enumerate with Euclid's formula, taking care to include non-primitive triples.

The deck was reshuffled once due to exhaustion, so we know that $$52 < 2x + 2y + 2z < 104$$. This limits the possible (x,y,z) triples to:

(5, 12, 13)
(8, 15, 17)
(9, 12, 15)
(12, 16, 20)


Each of these can be further permuted 6 ways giving 24 possibilities.

We make the following observations:

(1) A round can't cross a reshuffle boundary unless it started with the players even in the number of prior wins (or else one player's advantage would force a win before the reshuffle). The second round can never cross a reshuffle boundary.

(2) Since there was a reshuffle and since no tuple has a subset that consumes exactly 52 cards, some round must have crossed the reshuffle boundary. It could not have been the first since no tuple admits a round that large, so it must have been the third, with the first two rounds including a win for Alice and a win for Bob. We know that Bob won the third round since it's he who requests the shuffle. This means that Alice won just one round, necessarily the longest, and this longest round was not the last.

(3) We don't know either player's reshuffle threshold, but we can rule out cases where there were fewer cards left in the deck after round 1 than are left in the deck after round 3. In such cases if Bob asks for a reshuffle after round 3 then either he or Alice would have asked for one after round 1.

Applying these criteria we can rule out 22 of the 24 tuple permutations, leaving only (9, 15, 12) and (8, 17, 15), which translate to:

  r1(bob):   18 drawn, 34 remaining
r2(alice): 30 drawn,  4 remaining
r3(bob):   24 drawn, 32 remaining

r1(bob):   16 drawn, 36 remaining
r2(alice): 34 drawn,  2 remaining
r3(bob):   30 drawn, 24 remaining


In the first of these cases there's not much difference between 32 and 34 cards, and the problem stated that previously neither player had been close to calling for a reshuffle. If 32 cards is under Bob's threshold then 34 cards would have been close.

So the best answer is 16, 34, and 30 cards were drawn in rounds 1-3, which were won by Bob, Alice, and Bob respectively.