Evens Coin Puzzle I (math21)
Problem
4×4
: Take 16 coins and put them on a
grid such that every cell is covered by
a coin. Remove 6 coins leaving an even number of coins in each row and in each column
(see [2] and [3]).
Modeling Steps
We dene a
4 × 4 square grid.
In each of the 16 cells in the
4 × 4 square grid we can place
a coin, but we do not know where.
1. The (unknown) fact of whether a coin
{1 . . . 4}
is is not
or
(i, j)
with
i, j ∈
xi,j . Hence, we introduce a binary
xi,j = 0 means there is no coin at
at position (i, j).
can be modeled by a binary variable
variable for each of the 16 square positions.
position
at a position
(i, j), xi,j = 1
means there
16 − 6)
2. We must have 10 (=
is
a coin
coins left in the square grid.
constraint:
X
Hence we have the
xi,j = 10
i,j
P
j xi,j must be a
multiple of 2 in each row i. Let's introduce another integer varibale ni for each row
3. The number of coins in each row must be even.
i. 2ni
That means
is certainly an even number. Hence, we have :
X
xi,j = 2ni
for each row
i ∈ {1 . . . 4}
j
P
i xi,j must
be a multiple of 2 in each column j . Let's introduce another integer varibale mj for
4. The number of coins in each column must be even. That means that
each column
j . 2mj is
X
certainly an even number. Hence, we have:
xi,j = 2mj
for each column
j ∈ {1 . . . 4}
i
5. The two previous constraints guarantee that the number of coins in each row and
in each column is even.
6. We need a feasible solution.
The complete model code in LPL for this model is as follows (see [1]):
Listing 1: The Model
model math21 "Evens Coin Puzzle I";
set i,j := [1..4];
binary variable x{i,j};
integer n{i} [0..2]; m{j} [0..2];
constraint
TOTAL: sum{i,j} x = 16-6;
CROW{i}: sum{j} x = 2*n;
CCOL{j}: sum{i} x = 2*m;
1
solve;
Write(’The grid with coins at * is\n
%2s \n’, {j}j);
Write{i}(’
%s %2s \n’, i, {j} if (x,’*’,’-’));
end
Solution
: There are many solutions. One of them is as follows (the positions of the coins
are marked by a star):
1
2
3
4
1
*
*
2
*
*
-
Question
3
*
*
*
*
4
*
*
-
(Answer see )
1. Could the problem also be solved, if we wanted to have a number of coins which are
divisible by 3 on each row and each column? How should the problem by changed?
Solve it!
2. How many coins should at least be taken away from the 16 positions in order to
make the number of coins in each row and each column divisible by 3? Modify the
problem and solve it. Is there more than one solution? Find all possible
K. Generate
a graphical representation of the solution using LPL.
3. Is there a board of any dimension
i > 4
placing
10
coins in such a way that the
number of coins in each row and each column is divisible by 3?
Answer
(Question see )
1. No, there is no solution. To run the model, change the two corresponding constraints
as follows:
sum{j} x=3*N;
sum{i} x=3*M;
2. Removing 4 coins, leaving 12 coins on the square grid, solves the problem. It is easy
to see that removing one coin from each row in a dierent column gives a solution
(in each row and column we then have 3 coins which is divisible by 3.
To formulate it as a model, we introduce a new variable
z
for the number of coins
to be removed, which is then minimized. The complete formulation of this model is
1
as follows (see math21a ):
model math21a "Evens coin Puzzle (II)";
set i,j := [1..4] "rows/columns";
binary variable x{i,j};
integer n{i}; m{j}; z;
constraint
TOTAL: sum{i,j} x = #i^2-z;
CROW{i}: sum{j} x = 3*n;
CCOL{j}: sum{i} x = 3*m;
minimize obj: z;
1 http://lpl.unifr.ch/lpl/Solver.jsp?name=/math21a
2
Draw.Scale(50,50);
for{i|i<#i} do Draw.Line(i,0,i,#i,0); end;
for{j|j<#j} do Draw.Line(0,j,#j,j,0); end;
for{i,j|x} do Draw.Circle(i-.5,j-.5,.4); end;
Draw.Text(’z=’&z,0,#i+.4);
end
A solution with a dierent value of
z
is to remove 7 coins (z
= 7),
leaving 9 coins
within the grid board. To nd this solution, we need to add a lower bound
Finally, adding a lower bound of
z ≥ 8
will remove all 16 coins.
z ≥ 5.
This is also a
solution, since zero is divisible by 3.
3. No, there is not!
i=[1..5]
then to
A naive way to solve the problem is to augment the set to
i=[1..6],
then to
i=[1..7]
etc.
and to modify the two
last constraints to
CROW{i}: sum{j} x = 3*N;
CCOL{j}: sum{i} x = 3*M;
Solving each time, we see that there is no solution. But this approach would not
solve our problem in general, because we need to solve it an innite number of times
to be sure. It is easy to see why this is not possible: Placing 10 coins onto a board
can only be done by putting 3 coins in 3 dierent rows. In this case, we are left
with a single coin, which cannot be placed.
References
[1] T. Hürlimann. Reference Manual for the LPL Modelling Language, most recent version.
www.virtual-optima.com.
[2] B.A. Kordemsky.
[3] Clare
Nolan.
The Moscow Puzzles
. Charles Scribner's Sons, 1972.
http://www.chlond.demon.co.uk/academic/puzzles.
html.
3
© Copyright 2026 Paperzz