← Previous Contents    Next →  

Puzzles

Introduction to puzzles

Types of puzzles, by skill used to solve them:

Puzzles often have the following features which distinguishes them from for example mathematics:

Some types of puzzles have counterparts in mathematics with serious real-world applications, for instance related to the field of optimisation. Some have even produced entire fields of mathematics, e.g. Hamilton and Euler cycles, which were the beginnings of graph theory.

We are mostly interested in logical puzzles, with just a little bit of mathematics. The method for solving can be summarised as:

Identifying the constraints sometimes requires some lateral thinking. Once the constraints have been identified, deducing the solution can be done by hand or by computer.

We look at some examples of puzzles, identify any needed constraints and solve the puzzle. You should try to solve the puzzles before looking at the solutions. There is no need to work through all of them, pick a few that looks interesting.

The Census taker

A census taker knocks on a door and a parent opens. The parent says "we are five in this family, me, my partner and our three children. Me an my partner are both $40$, and the product of my childrens ages is $72$. The sum of their ages is the number on our house" The census taker claims not to have enough information. "Oh, and my eldest child is home from school today due to a skiing accident one week ago." The census taker writes down the ages of the children and leaves.

Answer:

The prime factorisation of $72$ is $2\cdot 2\cdot 2\cdot 3\cdot 3$. This gives the following table of possible ages and their sum $$ \begin{pmatrix} 1 & 1 & 72 & 74 \\ 1 & 2 & 36 & 79 \\ 1 & 3 & 24 & 28 \\ 1 & 4 & 18 & 23 \\ 1 & 6 & 12 & 19\\ 1 & 8 & 9 & 18\\ 2 & 2 & 18 & 22\\ 2 & 3 & 12 & 17\\ 2 & 4 & 9 & 15\\ 2 & 6 & 6 & 14\\ 3 & 3 & 8 & 14\\ 3 & 4 & 6 & 13\\ \end{pmatrix} $$ We do not know the number of the house, but the census taker does. And the information that the census taker cannot deduce the ages the ages tells us that the sum of the ages is not unique. So we eliminate, and have the possible solutions: $$ \begin{pmatrix} 2 & 6 & 6 & 14\\ 3 & 3 & 8 & 14\\ \end{pmatrix} $$ After being told that there is an eldest child, we can deduce that $2+6+6$ is not the solution, and so the ages are $3$, $3$ and $8$. We have to assume that twins are considered to have the same age for a solution to be possible.

The $81$ coins problem

You have $81$ coins, all identical in shape, and all identical in weight except one which is a counterfeit and weighs less or more than the other coins. You can only find out which coin is the counterfeit by weighing on a scale. Show how to find out which is the counterfeit coin by weighing four times.

Answer:

Divide into $3$ groups of $27$ coins. Measure twice to identify the group with the counterfeit coin. You now also know if the counterfeit coin weighs less or more than the other coins. Divide the group with the counterfeit into $3$ groups of $3$ each and weigh two of them once. You have now identified which group has the counterfeit coin. Divide the group of $3$ with the counterfeit into $3$ individual coins. Weigh once to find the counterfeit.

The bridge and torch problem

Four people come to a river in the night. There is a narrow bridge which will only allow two people at a time. The four people only have one torch between them, and so the torch has to be brought back and forth over the bridge. The four people move at different speeds, person A uses 1 minute, person B uses 2 minutes, person C uses 5 minutes and person D uses 8 minutes. When two people cross together they will always move at the slower person's speed.
What is the least amount of time needed for the four people to cross the river?

Answer:

The greedy solution of sending $A$ back and forth uses $2+1+5+1+8=17$ minutes is not the fastest. The fastest is obtained by sending $C$ and $D$ over together and $B$ back to get $A$, $2+1+8+2+2=15$ minutes.

The proof that this is the shortest solution is a little bit more involved. Here is one explanation:

We will need at least $5+1+8+1=15$ minutes if $C$ and $D$ go separately across the bridge. So there will be no solution less than $15$ minutes in this case. If $C$ and $D$ go together over on the first round, that round will take at least $5+8+5=18$ minutes, which gives no solutions less than $15$ minutes. If $C$ and $D$ go together over on the last round, we know that either $C$ or $D$ will have returned in the previous round, and so again at least $5+8+5=18$ minutes will pass. So we can conclude that $C$ and $D$ go together on the second round. So the first round must be $AB$ and with either $A$ or $B$ returning. So after the first round we have either $ACD$ on the near side with $B$ on the far side, or $BCD$ on the near side and $A$ on the far side, with $1+2=3$ or $2+2=4$ minutes, respectively, spent. After the first half of the second round we have $A$ or $B$ on the near side, with $3+8=11$ or $4+8=12$ minutes, respectively, spent. Someone has to go back to get the last person on the near side. Sending $C$ or $D$ will automatically lead to more than $15$ minutes spent. So $B$ or $A$ has to go. In the first case we send $B$ back to get $A$ with a total of $11+2+2=15$ minutes. In the second case we send $A$ back to get $B$ with a total of $12+1+2=15$ minutes.

Fox, Chicken and a bag of corn

A farmer has purchased a fox, a chicken and a bag of corn. On the way home they have to cross a river using a boat. The boat can only take the farmer and one of the purchased items. If left unattended, the fox will eat the chicken and the chicken will eat the bag of corn. How can the farmer get the items across the river?

Answer:

The farmer takes the chicken over, then brings the corn over taking the chicken back to prevent those two being left alone. The chicken is left on the bank while the fox is brung over. Finally the farmer brings the chicken.

Opening and closing doors

You are in a hallway with $256$ closed doors numbered $1$ to $256$. First you walk down the hallway starting at door $1$ and open all doors. Then you walk down the hallway starting at door $2$ close every second door. Then you walk down to door $3$ and either open or close every third door. You open the door if it is closed and you close the door if it is open. Then you walk down the hallway and open/close every fourth door, starting with door $4$. Again, you open a closed door and you close open doors. You continue like this for all the doors. When you finish, which doors are open?

Answer:

We can count how many times door $n$ switches state. The number of times is equal to the number of factors in $n$. If the number of factors is odd then the door is left open, if the number of factors is even, then the door is left closed. If $n$ is factored as, $$n=p_1^{n_1}\cdots p_k^n{n_k}$$ then we can count the number of factors as $$(n_1+1))(n_2+1)\cdots (n_k+1)$$ For this number to be odd we need each $n_i$ to be an even number. In other words, the door is open if and only if $n$ is a square. The squares are $$1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,\text{ and }256$$

The King's logicians

The King has called $100$ equally able and brilliant logicians to his court in order to decide which of them is to be his advisor. Each logician is blindfolded and a blue or a white hat is placed on their head. The blindfolds are removed and they are allowed to each others hats. They are not able to look at their own hats or communicate in any way. The king informs them that at least one of the hats is a blue, and that the first person to deduce that their hat is blue will be his advisor. They are only allowed to speak up at certain announced points of time at intervals of one hour. The first hour passes and no-one speaks. The second hour passes and no-one speaks. This continues for several hours. Then suddenly one of the advisors exclaims: "My hat is blue". How did the logician come to this conclusion?

Answer:

They all know that at least one of the hats is blue. As no-one speaks after one hour, they can all conclude that there is at least two blue hats. If not, one of them would see only white hats and be able to conclude that his/her own hat is blue. As no-one speaks after two hours, they can all conclude that there is at least three blue hats, if not two of them would see only $1$ blue hat and be able to conclude that their own hat is blue. So it continues. After some time however (say $k$ steps), some of of them sees only $k-1$ hats, and the first to do so will be the advisor.

The missing dollar

Three people check into a hotel. The bill amounts to $30$ dollars, so the guests pay $10$ in advance. Later that day, the hotel manager realises that a mistake was made and that the bill should actually be $25$. The manager goes to the room to pay back $5$. It becomes clear that $5$ cannot be divided by $3$, so the manager decides to return $1$ to each of the guests an keep $2$ as a tip for himself. Each guest gets $1$ back and so each of them has only payed $9$ for the room. Together with the $2$ the manager kept for a tip, the total is now $3\times 9 + 2=29$. But the original amount payed was $30$. What hapened to the missing dollar?

Answer:

The problem here is that the tip $2$ is added twice in the sum $27+2$. If we look at the numbers more carefully, we see that $25$ is left for the hotel bill, and $9+9+9=27=25+2$, so the tip of $2$ is already included in the payment $9+9+9$. So there is really nothing to solve here.

Greedy logician pirates

$5$ pirates have a treasure of $100$ coins. They need to decide on a way to divide the coins between them. Being democratically inclined they agree on the following scheme:

The oldest pirate will come up with a scheme to divide the coins. They will then vote on it. If $50\%$ or more of the pirates agree then that will be how they divide the coins. If not, the oldest pirate will be thrown overboard, and the second oldest pirate will come up with a scheme to vote on. They will continue until a scheme passes the vote.

Given that the pirates are also greedy logicians - how will they divide the money?

Lets name the pirates $A,B,C,D,E$ in decreasing order of age. Case 1. If two pirates are left over, then $D$ will suggest a $100/0$ split and succeed by $50$ per cent vote. Case 2. If three pirates are left over, then $C$ will suggest a $99/0/1$ split. Pirate $E$ will agree, as the alternative would be Case 1. So $C$'s suggestion will pass by $2/3$ vote. Case 3. If four pirates are left over, then $B$ will suggest $99/0/1/0$. Pirate $D$ will agree, as the alternative would be Case 2, where $D$ gets nothing. The suggestion passes with $50$ per cent. Case 4: If five pirates are left over, then $A$ will suggest $98/0/1/0/1$. Pirates $C$ and $E$ will agree, since the alternative would be Case 3, where they get nothing. To conclude, the split will be $98/0/1/0/1$.

A Bag of Marbles

You have a bag with $101$ marbles, where $50$ of them are white and $51$ are blue. You pick random marbles from the bag, two at a time. If the two marbles are white, you put them aside. If the two marbles are blue, you put them aside and put two white marbles back in the bag. If the two marbles are different you put a white marble into the bag and leave the blue marble aside. What is the probability that the last marble left in the bag is white?

Answer:

Using the word "probability" here is misdirection. No probability calculations are needed. When we start the number of white marbles is divisible by $2$. Each time we remove two marbles, the number of white marbles in the bag remains the same, goes up by $2$ or down by $2$. So the number of white marbles is always divisible by $2$. We will eventually run out of marbles, and so the last marble left in the bag must be blue. Hence the probability of having a white marble is zero.

Knights, knaves and spies

A knights and knaves puzzle contains the statements of $2$ or more people, and it is our task to deduce who is a knave (always lies) and who is a knight (always tells the truth). Any combination of knights and knaves are usually allowed, and there is one unique solution.

On the homepage of the University of Hong-Kong Philosophy department you will find a list of $382$ computer generated knights and knaves puzzles.

In a knights, knaves and spies puzzle, we have in addition the spies who sometimes lie and sometimes tell the truth. Again we are meant to identify the three people. To limit the size of the problem, there is the additional constraint that there is exactly one of each type.

Both these types of puzzles are easily solved by creating a truth table of the statements and eliminating contradictions. Let's look at an example knights and knaves puzzle

We create the table of the possible solutions combined with the statements made: $$\begin{matrix}A & B & & a & b \\ 0 & 0 & & 1 & 0 \\ 0 & 1 & & 0 & 0 \\ 1 & 0 & & 1 & 0 \\ 1 & 1 & & 0 & 1 \\ \end{matrix}$$ The only line without contradiction is line $3$, which tells us that $A$ is a knight and $B$ is a knave.

Here $A$ refers to the possible value for $A$ (0=knave, 1=knight) and $a$ is the statement that $A$ makes. The puzzle can be made more challenging by introducing more people or by obfuscating the statements. For example

Let's look at a knights, knaves and spies puzzle as well

We make a table of all six possibilites (x = spy) $$\begin{matrix}A & B & C & a & b & c \\ 0 & 1 & x & 0 & 1 & 1 \\ 1 & 0 & x & 0 & 0 & 0 \\ 0 & x & 1 & 1 & 0 & 1 \\ 1 & x & 0 & 0 & 0 & 0 \\ x & 0 & 1 & 1 & 0 & 0 \\ x & 1 & 0 & 0 & 1 & 1 \\ \end{matrix}$$ We cannot form contradictions with $x$, nevertheless the first line is the only line without contradiction. So $A$ is a knave, $B$ is a knight and $C$ is a spy.

← Previous Contents    Next →