# Board puzzles with algebra of binary variables facts for kids

**Board puzzles with algebra of binary variables** ask players to locate the hidden objects based on a set of clue cells and their neighbors marked as variables (unknowns). A variable with value of 1 corresponds to a cell with an object. Contrary, a variable with value of 0 corresponds to an empty cell—no hidden object.

## Contents

## Overview

These puzzles are based on algebra with binary variables taking a pair of values, for example, (no, yes), (false, true), (not exists, exists), (**0**, **1**). It invites the player quickly establish some equations, and inequalities for the solution. The partitioning can be used to reduce the complexity of the problem. Moreover, if the puzzle is prepared in a way that there exists a unique solution only, this fact can be used to eliminate some variables without calculation.

The problem can be modeled as binary integer linear programming which is a special case of integer linear programming.

## Algebra with binary variables

Below the letters in the mathematical statements are used as variables where each can take the value either **0** or **1** only. A simple example of an equation with binary variables is given below:

**a****+****b****=****0**

Here there are two variables * a* and

*but one equation. The solution is constrained by the fact that*

**b***and*

**a***can take only values*

**b****0**or

**1**. There is only one solution here, both

**a****= 0**, and

**b****= 0**. Another simple example is given below:

**a****+****b****=****2**

The solution is straightforward: * a* and

*must be*

**b****1**to make

**a****+**

*equal to*

**b****2**.

Another interesting case is shown below:

**a****+****b****+****c****=****2**

**a****+****b****≤****1**

Here, the first statement is an equation and the second statement is an inequality indicating the three possible cases:

**a****= 1**and**b****= 0**,**a****= 0**and**b****= 1**, and**a****= 0**and**b****= 0**,

The last case causes a contradiction on * c* by forcing

**c****= 2**, which is not possible. Therefore, either first or second case is correct. This leads to the fact that

*must be*

**c****1**.

The modification of a large equation into smaller form is not difficult. However, an equation set with binary variables cannot be always solved by applying linear algebra. The following is an example for applying the subtraction of two equations:

**a****+****b****+****c****+****d****= 3**

**c****+****d****= 1**

The first statement has four variables whereas the second statement has only two variables. The latter one means that the sum of * c* and

*is*

**d****1**. Using this fact on the first statement, the equations above can be reduced to

**a****+****b****= 2**

**c****+****d****= 1**

## The algebra on a board

A game based on the algebra with binary variables can be visualized in many different ways. One generic way is to represent the right side of an equation as a clue in a cell (clue cell), and the neighbors of a clue cell as variables. A simple case is shown in Figure 1. The neighbors can be assumed to be the up/down, left/right, and corner cells that are sharing an edge or a corner. The white cells may contain a hidden object or nothing. In other words, they are the binary variables. They take place on the left side of the equations. Each clue cell, a cell with blue background in Figure 1, contains a positive number corresponding to the number of its neighbors that have hidden objects. The total number of the objects on the board can be given as an additional clue. The same board with variables marked is shown in Figure 2.

### The reduction into a set of equations with binary variables

The main equation is written by using the total number of the hidden objects given. From the first figure this corresponds to the following equation

**a****+****b****+****c****+****d****+****e****+****f****+****g****+****h****+****i****+****j****+****k****+****m****= 3**

The other equations are composed one by one for each clue cells:

**a****+****b****+****c****+****e****+****f****+****h****+****i****+****j****= 1**

**f****+****g****+****j****+****m****= 1**

**h****+****i****+****j****+****k****= 2**

**i****+****j****+****m****= 2**

Although there are several ways to solve the equations above, the following explicit way can be applied:

- It is known from the equation set that
**i****+****j****+****m****= 2**. However, sinceand**j**are neighbors of a cell with number**m****1**, the following is true:**j****+****m****≤ 1**. This means that the variablemust be**i****1**. - Since
**i****= 1**and the variableis the neighbor to the clue cell with number**i****1**, the variables,**a**,**b**,**c**,**e**,**f**, and**h**must be zero. The same result can be obtained by replacing**j****i****= 1**into the second equation as follows:**a****+****b****+****c****+****e****+****f****+****h****+****j****= 0**. This is equivalent to**a****= 0**,**b****= 0**,**c****= 0**,**e****= 0**,**f****= 0**,**h****= 0**,**j****= 0**. - Figure 3 is obtained after Step 1 and Step 2. The grayed cells with '–' are the variables with value
**0**. The cell with the symbol**Δ**corresponds to the variable with value**1**. The variableis the only neighbor of the left most clue cell with value**k****2**. This clue cell has one neighbor with an object and only one remaining cell with variable. Therefore,**k**must be**k****1**. - Similarly, the variable
must be**m****1**too because it is the only remaining variable neighbor to the right most clue cell with value**2**. - Since
**k****= 1**,**m****= 1**and**i****= 1**, we complete the marking of three hidden objects therefore**d****= 0**, and**g****= 0**. The final solution is given in Figure 4.

### Use of uniqueness

In the example above (Figure 2), the variables * a*,

*,*

**b***, and*

**c***are the neighbors of the clue cell*

**e****1**and they are not neighbors of any other cell. It is obvious that the followings are possible solutions:

**a****= 1**,**b****= 0**,**c****= 0**,**e****= 0****a****= 0**,**b****= 1**,**c****= 0**,**e****= 0****a****= 0**,**b****= 0**,**c****= 1**,**e****= 0****a****= 0**,**b****= 0**,**c****= 0**,**e****= 1**

However, if the puzzle is prepared so that we should have one only one (unique) solution, we can set that all these variables * a*,

*,*

**b***, and*

**c***must be 0. Otherwise there become more than one solutions.*

**e**### Use of partitioning

Some puzzle configurations may allow the player to use partitioning for complexity reduction. An example is given in Figure 5. Each partition corresponds to a number of the objects hidden. The sum of the hidden objects in the partitions must be equal to the total number of objects hidden on the board. One possible way to determine a partitioning is to choose the lead clue cells which have no common neighbors. The cells outside of the red transparent zones in Figure 5 must be empty. In other words, there are no hidden objects in the all-white cells. Since there must be a hidden object within the upper partition zone, the third row from top shouldn't contain a hidden object. This leads to the fact that the two variable cells on the bottom row around the clue cell must have hidden objects. The rest of the solution is straightforward.

### Use of try-and-check method

At some cases, the player can set a variable cell as **1** and check if any inconsistency occurs. The example in Figure 6 shows an inconsistency check. The cell marked with an hidden object **Δ** is under the test. Its marking leads to the set all the variables (grayed cells) to be **0**. This follows the inconsistency. The clue cell marked red with value **1** does not have any remaining neighbor that can include a hidden object. Therefore, the cell under the test must not include a hidden object. In algebraic form we have two equations:

**a****+****b****+****c****+****d****= 1**

**a****+****b****+****c****+****d****+****e****+****f****+****g****= 1**

Here * a*,

*,*

**b***, and*

**c***correspond to the top four grayed cells in Figure 6. The cell with*

**d***is represented by the variable*

**Δ***, and the other two grayed cells are marked as*

**f***and*

**e***. If we set*

**g**

**f****= 1**, then

**a****= 0**,

**b****= 0**,

**c****= 0**,

**d****= 0**,

**e****= 0**,

**g****= 0**. The first equation above will have the left hand side equal to

**0**while the right hand side has

**1**. A contradiction.

Try-and-check may need to be applied consequently in more than one step on some puzzles in order to reach a conclusion. This is equivalent to binary search algorithm to eliminate possible paths which lead to inconsistency.

## Complexity

Because of binary variables, the equation set for the solution does not possess linearity property. In other words, the rank of the equation matrix may not always address the right complexity.

The complexity of this class of puzzles can be adjusted in several ways. One of the simplest method is to set a ratio of the number of the clue cells to the total number of the cells on the board. However, this may result a largely varying complexity range for a fixed ratio. Another method is to reduce clue cells based on some problem solving strategies step by step. The complex strategies may be enabled for high complexity levels such as subtracting an equation with another one, or the higher depth of try-and-check steps. When the board size increases, the range of the problem cases increases. The ratio of the number of hidden objects to the total number of cells affects the complexity of the puzzle too.

- Paul Halmos,
*Naive set theory*. Princeton, NJ: D. Van Nostrand Company, 1960. Reprinted by Springer-Verlag, New York, 1974. (Springer-Verlag edition). - Alexander Schrijver,
*Theory of Linear and Integer Programming*. John Wiley & Sons, 1986. Reprinted in 1999. . - Adam Drozdek,
*Data Structures and Algorithms in C++*, Brooks/Cole, second edition, 2000. .

*Kiddle Encyclopedia.*