Saturday, October 27, 2018

The unreliable guards

Here is a new puzzle variety inspired by the Forgetful Forest, Tigers and Treasure, and others by Raymond Smullyan.

Here is the setup of the puzzle:

Two guards are standing outside the entrance to a cave, guarding the treasure within. The treasure is one of copper, silver, gold, platinum, diamonds, or rubies.  
Guard 1 lies when guarding copper, silver, or gold and tells the truth when guarding other treasure. Guard 2, on the other hand, lies when guarding platinum, diamonds, or rubies, but tells the truth when guarding other treasure. 
In this land, copper is worth less than silver, which is worth less than gold, which is worth less than platinum, which is worth less than diamonds, which is worth less than rubies.

This is very similar to the Forgetful Forest, where the Lion and Unicorn each lie on particular days of the week, or in Tigers and Treasure where the inscriptions on the doors will be true only when leading to particular contents.

Just as with those puzzles, you are given clues, something like:
You meet the guards at the entrance to the treasure cave, and they make these statements: 
Guard 1 says: The treasure is more valuable than copper.
Guard 2 says: The treasure is either diamonds or rubies. 
If you determine the contents of the cave, the guards will let you pass and you can claim the treasure.
If you think you can solve this particular puzzle, try it now right here. The interactive page for this puzzle type will set you up with 838 puzzles of this variety. It presents you with a list of the treasure types, and you can select the one you think is the correct answer.

In this case, if Guard 1 says "the treasure is more valuable than copper" we can narrow down the list of possible treasures by considering two cases. In the first case, Guard 1 is telling the truth - so we know the treasure cannot be copper, silver or gold (their lying treasures); this leaves platinum, diamonds, or rubies, all of which are more valuable than copper, so the treasure could be any one of them. In the second case, Guard 1 is lying, so the treasure could be copper, silver, or gold; however, if the treasure was silver or gold, then Guard 1's statement would be true, contradicting the fact that Guard 1 is lying. So, if Guard 1 is lying, the treasure is copper, and if Guard 1 is telling the truth, the treasure is platinum, diamonds, or rubies.

Guard 1's statements provide us with a list of possible treasures: copper, platinum, diamonds, or rubies. Guard 2's statement, "the treasure is either diamonds or rubies," should narrow things down. If Guard 2 is lying then the treasure must be platinum, diamonds, or rubies (their lying treasures). However, if they are lying their statement "the treasure is either diamonds or rubies" cannot be true, so the treasure must be platinum. Looking at Guard 2's statement, there is no way it can be true because both diamonds and rubies are on Guard 2's "lying list." So Guard 2 is lying, and the only option for the treasure is platinum.

We could have solved the puzzle looking at Guard 2's statement alone: the treasure must be platinum. Because platinum is also in Guard 1's list, we can be confident that the puzzle is well-formed and that the clues are not contradicting each other.

The set of puzzles that were generated has a 'solution space' that looks like this:

The distribution shape is due to the ordering of the value of treasure types, and that we included clues that had the phrases "more valuable than" and "less valuable than" - this gave us more treasure that sat in the middle of the value range, while the ones at the ends happened less frequently. Gold and platinum satisfy the phrases "more/less valuable than x" with a greater frequency than rubies or copper.


Give these puzzles a try here. There is a Jupyter notebook here that shows how the puzzles were generated, full source for the puzzle page is here.

Illustration from Sarah Amelia Scull,
"Greek Mythology Systematized" (1880).