Determine if a matchsticks game is possible

79 Views Asked by At

I am looking to create a matchsticks game where you remove some number of matchsticks from a grid to create a certain number of squares. You can try playing it here. For example, you could be asked to remove 7 matchsticks to create 4 squares, so the solution would be

 ---   ---   ---                ---   ---   ---  
|    |     |    |              |               |
 ---   ---   ---     Becomes        
|    |     |    |    ------>   |               |
 ---   ---   ---                ---   ---   ---
|    |     |    |              |    |     |    |
 ---   ---   ---                ---   ---   ---

If the grid of matchsticks was always a 3x3 grid, is there a way to verify that any arbitrary combination of removed matchsticks and created squares will result in a game that can be played?

Side note: I don't know if these tags fully apply to this question, so please tell me if they don't or if there are other tags I should be using.

1

There are 1 best solutions below

1
On

I don't think that there's a way to check the trickier cases without brute force: just trying all the possibilities of removing sticks. For example, it's probably impossible to confirm without lots of casework that there's no way to remove $7$ matchsticks to leave exactly $7$ squares (given that both $6$ and $8$ are possible).

On the other hand, brute force isn't out of the question for a $3 \times 3$ problem: there's only $2^{24} = 16\,777\,216$ cases, even if we don't try to take symmetry into account. It's when we increase the size of the grid that we need to search for different approaches.

If you're creating the matchsticks game, you have another option open to you: choose a random set of sticks to remove (weighted however you like toward more or fewer sticks), count the number of squares left, and challenge the player to reproduce your solution. The disadvantage is that harder versions of the puzzle, which have fewer solutions, are also less frequently generated.