# Brainstorming Puzzles Set 7 – A Knight, Knave & Spy | A Knight, Knave, Spy & Judge

Bad reasoning as well as good reasoning is possible and this fact is the foundation of the practical side of logic.

– Charles Sanders Peirce

Algorithmic thinking is really important as it enhances your thinking skills and can be nurtured with practice. (Refer the previous tutorial to know more about Algorithmic Thinking and try the puzzles before moving on to the solutions.)

### Solutions for the previous problems

#### Puzzle 6.1 Solution – The Mystery Lock

Explanation: From Hint4 we know 7,3 and 8 are not in the code.
We know one number is correct but is correctly placed as given in Hint1 and wrongly placed as given in Hint2, therefore 6 can’t be in the code.
Since 6 and 8 can’t be in the code 2, we can conclude that 2 is the third digit of the code as given in Hint1.
From the code given in Hint3, two numbers are correct but wrongly placed. Since 6 can’t be in the code and we have already placed 2, 0 must be the first digit as the digits are wrongly placed and we already have 2 as the third digit.
Now, we need to find only the second digit. In hint2, one digit is correct but wrongly placed. Obviously, 1 can’t be that digit because we need the second digit and 1 is present at the second digit. So the second digit must be 4. Therefore, the code is 042

#### Puzzle 6.2 Solution – The Witty Prisoners

Correct Answer: 99 prisoners can be saved with 100% rate of survival and 1 prisoner would have a 50% rate of survival.

Explanation:

Step 1: They will decide that the last person will say “White” if he sees an odd number of white caps otherwise he’ll say “Black”.

Step 2: The second last person will count the number of white hats in front of him. If the number of white hats in front of him are odd and the last person had said the word “White”, he’ll be sure that his hat must be black, otherwise, it must be white.

Step 3: Similarly, the third last person will count the number of white hats in front of him and find out which hat he’s wearing. In this way, the last person has 50% chance of survival where as the remaining 99 people would have a 100% rate of survival.

Solving these puzzles is fun, isn’t it? So, wear your logic caps and get ready for your next brain workout:

### Quiz 7.1  – A Knight, A Knave and A Spy

There are three people (Vasu, Ram and Shyam). One among these is a knight, another one a knave, and the third one a spy.

The knight never tells a lie, the knave never tells the truth, and the spy can either tell the truth or he can lie.

Vasu says: “Shyam is a knave.”
Ram says: “Vasu is a knight.”
Shyam says: “I am the spy.”

Can you find out who is the knight, the knave, and the spy?

Solution Added – Solution of A knight, a knave and a spy

### Quiz 7.2 – A Knight, a Knave, a Spy and a Judge

There are three people (Vasu, Ram and Shyam). One among these is a knight, another one a knave, and the third one a spy.

The knight never tells a lie, the knave never tells the truth, and the spy can either tell the truth or he can lie.

All three of them are brought before a judge whose task is to identify the spy.

Vasu says: “I am not a spy.”
Ram says: “I am a spy.”
Now Shyam is, in fact, the spy. The judge asks him: “Is Ram really a spy?”

What should Shyam give as an answer so that he doesn’t convict himself as a spy?