Board GamesCard GamesCollectingLawn GamesParty GamesPerforming ArtsPuzzlesTabletop Gaming
  • »
  • »
  • Math Strategies and Game Theory: How to Win the Matchstick Game (Subtraction Game)

Math Strategies and Game Theory: How to Win the Matchstick Game (Subtraction Game)

Updated on April 04, 2016
calculus-geometry profile image

TR Smith is a teacher and creator who uses mathematics in her line of work every day.


Joined: 5 years agoFollowers: 215Articles: 453
The matchstick game or subtraction game is easy to win if you know the secret strategy!
The matchstick game or subtraction game is easy to win if you know the secret strategy!

In elementary school you may have played a simple two-player math game called either "Matchsticks" or "Subtraction," and sometimes mistakenly called "Nim." (Nim is a different, though similar game.) At the start of the game you and your opponent are given a pile of N matches where the number N is known to both of you. On each of your turns, you can take up to K matches from the pile. The person who takes the last match loses, and the other is declared the winner.

Often N is set to 20 and K is set to 3. That is, the game starts with a pile of 20 matches and on each of your turns you can take 1, 2, or 3 matches from the pile.

If the number of matches N is of a certain form, and you start first, AND you know the secret winning strategy, then you can always force your opponent to grab the last match. This is a fun math trick to teach children and it shows how math can be applied in real life to their advantage. Your kids will also enjoy playing with other children who don't know the trick!


What conditions on the number N guarantee a win for the first player?

If K is fixed, then the first player has a 100% chance of winning so long as N is not of the form

(K + 1)*P + 1

where P is any non-negative integer. For example, suppose K = 3. Since K + 1 = 4, the first player can always win as long as N is not of the form 4P + 1. Explicitly, N cannot be equal to 1, 5, 9, 13, 17, 21, ... That means N can be equal to 2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 14, 16, 18, 19, 20, ...

The matchstick game is a fun and educational homeschool activity for kids.
The matchstick game is a fun and educational homeschool activity for kids.

What happens if N is of the form (K + 1)*P + 1 but the second player doesn't know the strategy? In this case, the second player will probably eventually, unwittingly subtract a number of matches that reduces the pile to a number not of the form (K + 1)*P + 1. Then the first player can proceed with the strategy explained in the next section and win.

If N is of the form (K + 1)*P + 1 and the second player does know the strategy, then he or she can force the first player to grab the last match.


The Strategy

The game strategy is simple: Always subtract a number of matches that leaves the other player with a pile of size (K + 1)*P + 1. For example, if K = 3, then on each of her turns the first player must take away enough matches so that the number of remaining matches is 21, 17, 13, 9, 5, and eventually 1.

If K = 4, then the target numbers are of the form 5P + 1. Thus, the first player must always leave the second player with a pile whose size is 26, 21, 16, 11, 6, and eventually 1.


Example Game Play

Suppose N = 35 and K = 5. That is, the players start with 35 matches and on each of their turns they can subtract up to 5 matches from the pile. Since K + 1 = 6, and 35 is not of the form 6P + 1, Player 1 has a winning strategy so long as she subtracts enough matches to make the pile's size at a number of the form 6P + 1. Numbers of the form 6P + 1 are 31, 25, 19, 13, 7, and 1. Here is the game play:

Player 1: She subtracts 4 matches to leave 31 matches.

Player 2: No matter what he does, he cannot subtract enough matches to make the pile's size be 25 (because he can only take 1, 2, 3, 4 or 5 matches). So let's say he takes 3 matches, leaving 28 matches.

Player 1: She takes 3 matches, leaving 25.

Player 2: He takes 1 match, leaving 24.

Player 1: She takes 5 matches, leaving 19.

Player 2: He takes 4 matches, leaving 15.

Player 1: She takes 2 matches, leaving 13.

Player 2: He takes 5 matches, leaving 8.

Player 1: She takes 1 match, leaving 7.

Player 2: He takes 3 matches, leaving 4.

Player 1: She takes 3 matches, leaving 1.

Player 2: He is forced to take the last match, and therefore player 1 wins!


Playing games of strategy helps keep your mind sharp as you age.
Playing games of strategy helps keep your mind sharp as you age.

Have Fun!

Now that you know the winning strategy, you can use this secret to play and win against people who haven't yet figured it out. The matchstick game is part of a broader class of games known as "Nim Games" in which the winning strategy depends on performing some modular arithmetic to keep the sum of the remaining objects at a number of a certain form. This is an excellent game to teach children the value of doing mental arithmetic quickly.

More Math Games and Activities

Here are more math puzzles, games, and problem solving tutorials to keep your mind sharp. Also great for homeschoolers to give their children extra math practice


Comments

    0 of 8192 characters used
    Post Comment

    • lisa 4 years ago

      This game is suggested in my home school lesson plans as an alternative to subtraction drill sheets, but your explanation of the winning strategy is much clearer than the one given in my lesson book. My book only explains how to win for K = 3 and N = 30. The way you generalized the problem makes it easier to expand the game.

      As I see it, the strategy is to make sure than on two sucessive turns, the number of matches take adds up to K. Starting with the 2nd and 3rd turns, then the 4th and 5th turns, then the 6th and 7th turns etcetera.

      I think if you have more than one kid it's more fun to teach the strategy to the youngest so he can beat his older siblings!

    • calculus-geometry profile image
      Author

      TR Smith 4 years ago from Germany

      You're right (with a slight correction). After the first player has subtracted enough matches to make the number of remaining matches (K + 1)*P + 1, then on each pair of turns that follow, the total number taken must add up to K +1. (Not K.)

      That means you don't even have to keep track of the number in the pile, just keep track of how many your opponent takes. If K = 3 and he takes 2, then you take 3 + 1 - 2 = 2.

    • Eileen 3 years ago

      Hi, may I ask if there is a strategy for different number of players but a fixed number for K and N? Or is there no possible strategy like this? Thank you. :)

    • calculus-geometry profile image
      Author

      TR Smith 3 years ago from Germany

      Thanks for the good question, Eileen. With more than two players this modular arithmetic strategy no longer works perfectly since you can't predict whether or how the other players will work as a team to force another player to lose, as is common in multi-player games.

      For example, suppose K = 3 and there are 4 matches in the pile. Player A can take 3 and force Player B to take the last match. Or Player A can take 2 matches, allowing B to take 1 match, and forcing Player C to take the last match. Toward the end of the game, a player may realize she won't lose, and can choose who loses. Then there's nothing the other players can do about it.

      There's also the question of how you define winner and loser with more than 2 players. Some variants declare everyone the winner except for the person who takes the last match. In other versions it's the player whose turn occurs just before the last match is taken. And yet in other versions it's the player whose turn would come after. It could also be the player with the most matches among those who didn't take the last match.

    • Eileen 3 years ago

      Wow! Thank you so much for taking your time to answer my question! :)

    • nood 3 years ago

      I thought the matchstick game was everybody light a match at the same time and the last one to keep their match on fire in their hand is the winner. Your version sounds less painful, I will have to try it sometime.

    Click to Rate This Article