# Sum to 15 Card Game

Another week, another riddler. This week’s:

From John Hanna, a different kind of “card” game:

You and I are playing a game. It’s a simple one: Spread out on a table in front of us, face up, are nine index cards with the numbers 1 through 9 on them. We take turns picking up cards and putting them in our hands. There is no discarding.

The game ends in one of two ways. If we run out of cards to pick up, the game is a draw. But if one player has a set of three cards in his or her hand that add up to exactly 15 before we run out of cards, that player wins. (For example, if you had 2, 4, 6 and 7, you would win with the 2, 6 and 7. However, if you had 1, 2, 3, 7 and 8, you haven’t won because no set of three cards adds up to 15.)

Let’s say you go first. With perfect play, who wins and why?

This one is pretty fun. Here is how I looked at it:

Imagining that each player can see into the future, they will take the option that maximizes their outcome. Therefore my plan was to find the end result of every hand (9! or ~400,000 outcomes). Then, go up a level — when the player had to decide between the two outcomes they would pick the one that gives them the best result. You do this again and again, flipping who gets to choose between the options and therefore which direction they are optimizing for.

At the end of this we see that the players will result in a tie every time.

Code can be found here