Some Logic Puzzles


Hi folks!!  Here are some Logic puzzles to solve and sharpen your mind. All of these needs only basic Computer and Discrete Logics to solve and It helps you in improving your Logical Reasoning, Aptitude, Algorithmic thinking and problem-solving skills. It is ordered according to levels so that reader can approach in order. I have solved few questions and remaining similar questions are left to readers to try. Those are common and famous puzzles solutions and explanations can easily be found in web and books.

LEVEL-1

Each inhabitant of a remote village always tells the truth or always lies. A villager will give only a “Yes” or a “No” response to a question a tourist asks. Suppose you are a tourist visiting this area and come to a fork in the road. One branch leads to the ruins you want to visit; the other branch leads deep into the jungle. A villager is standing at the fork in the road. What one question can you ask the villager to determine which branch to take?

The question is “If I were to ask you whether the right branch leads to the ruins, would you answer, yes?”

If the ruins are that direction, a truthful villager will say yes (because they would say yes to the hypothetical question) and a liar will say yes (because in fact they would say no to the hypothetical question).

If the ruins are NOT in that direction, the truthful villager will say no (because they would say no to the hypothetical) and the liar will say no (because they would say yes to the hypothetical).

LEVEL-2

An explorer is captured by a group of cannibals. There are two types of cannibals—those who always tell the truth and those who always lie. The cannibals will barbecue the explorer unless he can determine whether a particular cannibal always lies or always tells the truth. He is allowed to ask the cannibal exactly one question.


a)  Explain why the question “Are you a liar?” does not work.

If you ask the Truth Teller "are you a Liar?"
The Truth Teller will say "No".
Because he is telling the truth. He is not a Lair.

And if you ask the Liar, "are you a liar?"

The Lair will also say "No".
Because he is lying. He is a Liar.

If they both say no, you can't tell who is lying and who is telling the truth.

b)  Find a question that the explorer can use to determine whether the cannibal always lies or always tells the truth.

There can be two questions asked.

i)     i) Are you a cannibal?
"Are you a cannibal?" works because the Truth Teller will tell you "Yes" because he is telling the truth, he is a cannibal.
And the Lair will tell you "No". But you know they are all cannibal. So you know he is lying.

ii)  ii) Am I an explorer?
"Am I an explorer?" works, because the Truth Teller will say "Yes".
And the liar will say "no". But you know he is lying, because he is a cannibal not an explorer.

Still you can ask a Clever Question: Is it true that 2+2 = 4? or any trivial question and Truth teller says "Yes" for it while Liar tells "No" for it.

LEVEL-3

When three professors are seated in a restaurant, the hostess asks them: “Does everyone want coffee?” The first professor says: “I do not know.” The second professor then says: “I do not know.” Finally, the third professor says: “No, not everyone wants coffee.” The hostess comes back and gives coffee to the professors who want it. How did she figure out who wanted coffee?

If the first professor did not want coffee, then he would know that the answer to the hostess’s question was “no.” Therefore the hostess and the remaining professors know that the first professor did want coffee. Similarly, the second professor must want coffee. When the third professor said “no,” the hostess knows that the third professor does not want coffee.

Give a try: When planning a party, you want to know whom to invite. Among the people you would like to invite are three touchy friends. You know that if Jasmine attends, she will become unhappy if Samir is there, Samir will attend only if Kanti will be there, and Kanti will not attend unless Jasmine also does. Which combinations of these three friends can you invite so as not to make someone unhappy?

SOLUTION: Kanti and Jasmine; Jasmine alone; No one

LEVEL-4

In [Sm78] Smullyan posed many puzzles about an island that has two kinds of inhabitants, knights, who always tell the truth, and their opposites, knaves, who always lie. You encounter two people A and B. What are A and B if A says “B is a knight” and B says “The two of us are opposite types?”

(Refer: https://en.wikipedia.org/wiki/Knights_and_Knavesa)

(Refer: What is the Name of this Book? The Riddle of Dracula and Other Logical puzzles by Raymond Smullyan)

Let p and q be the statements that A is a knight and B is a knight, respectively, so that ¬p and ¬q are the statements that A is a knave and B is a knave, respectively.

We first consider the possibility that A is a knight; this is the statement that p is true. If A is a knight, then he is telling the truth when he says that B is a knight, so that q is true, and A and B are the same type. However, if B is a knight, then B’s statement that A and B are of opposite types, the statement (p ¬q) (¬p q), would have to be true, which it is not, because A and B are both knights. Consequently, we can conclude that A is not a knight, that is, that p is false.

If A is a knave, then because everything a knave says is false, A’s statement that B is a knight, that is, that q is true, is a lie. This means that q is false and B is also a knave. Furthermore, if B is a knave, then B’s statement that A and B are opposite types is a lie, which is consistent with both A and B being knaves.

We can conclude that both A and B are knaves.

LEVEL-5

The following questions relate to inhabitants of the island of knights and knaves created by Smullyan, where knights always tell the truth and knaves always lie. You encounter two people, A and B. Determine, if possible, what A and B are if they address you in the ways described. If you cannot determine what these two people are, can you draw any conclusions?

1. A says “At least one of us is a knave” and B says nothing.

A is a knight and B is a knave. (Consider A is a knave then it’s statement “At least one of us is a knave” is false which means both are Knight. So, A can’t be Knave. Consider B is a knave then it’s statement “At least one of us is a knave” to be true B should be Knave. Hence A is a Knight and B is a Knave)

2. A says “I am a knave or B is a knight” and B says nothing.

A is a knight and B is a knight. (Consider A is Knave, then for OR statement to be false both components should be false which means A is Knight and B is Knave which contradicts and A can’t be Knave. Consider A is Knight and its statement to be true either of components of OR statements is to be true ie B is a Knight. Hence A is a knight and B is a knight.)

3. A says “We are both knaves” and B says nothing.

A is a knave and B is a knight. (Consider A is a Knight then its statement should be true and it should be Knave which contradicts and A can’t be Knight. Consider A is a Knave and for its statement to be false B can be Knight. Hence A is a knave and B is a knight.)

Give a try:

1. A says “The two of us are both knights” and B says “A is a knave.”

2. Both A and B say “I am a knight.”

LEVEL-6

The following puzzles can also be solved similar to experimentation we followed in previous part.

The below questions relate to inhabitants of an island on which there are three kinds of people: knights who always tell the truth, knaves who always lie, and spies (called normals by Smullyan [Sm78]) who can either lie or tell the truth. You encounter three people, A, B, and C. You know one of these people is a knight, one is a knave, and one is a spy. Each of the three people knows the type of person each of other two is. For each of these situations, if possible, determine whether there is a unique solution and determine who the knave, knight, and spy are. When there is no unique solution, list all possible solutions or state that there are no solutions.

1.    A says “I am the knight,” B says “I am the knave,” and C says “B is the knight.”

A is the knight, B is the spy, C is the knave.

2.    A says “I am the knight,” B says “A is telling the truth,” and C says “I am the spy.”

A is the knight, B is the spy, C is the knave.

3.    A says “I am the knight,” B says “I am the knight,” and C says “I am the knight.”

Any of the three can be the knight, any can be the spy, any can be the knave.

4.     A says “I am not the spy,” B says “I am not the spy,” and C says “I am not the spy.”

No solutions

Give a try:

1.    A says “C is the knave,” B says, “A is the knight,” and C says “I am the spy.”

2.    A says “I am the knave,” B says “I am the knave,” and C says “I am the knave.”

3.    A says “I am the knight,” B says, “A is not the knave,” and C says “B is not the knave.”

4.    A says “I am not the spy,” B says “I am not the spy,” and C says “A is the spy.”

LEVEL-7

The following can be solved by translating statements into logical expressions and reasoning from these expressions using Mathematic Logics.

1. Steve would like to determine the relative salaries of three co-workers using two facts. First, he knows that if Fred is not the highest paid of the three, then Janice is. Second, he knows that if Janice is not the lowest paid, then Maggie is paid the most. Is it possible to determine the relative salaries of Fred, Maggie, and Janice from what Steve knows? If so, who is paid the most and who the least?

In order of decreasing salary: Fred, Maggie, Janice

2. A detective has interviewed four witnesses to a crime. From the stories of the witnesses the detective has concluded that if the butler is telling the truth, then so is the cook; the cook and the gardener cannot both be telling the truth; the gardener and the handyman are not both lying; and if the handyman is telling the truth, then the cook is lying. For each of the four witnesses, can the detective determine whether that person is telling the truth or lying?

The detective can determine that the butler and cook are lying but cannot determine whether the gardener is telling the truth or whether the handyman is telling the truth.

 3. Suppose there are signs on the doors to two rooms. The sign on the first door reads “In this room there is a lady, and in the other one there is a tiger”; and the sign on the second door reads “In one of these rooms, there is a lady, and in one of them there is a tiger.” Suppose that you know that one of these signs is true and the other is false. Behind which door is the lady?

The Japanese man owns the zebra, and the Norwegian drinks water.

4. Freedonia has fifty senators. Each senator is either honest or corrupt. Suppose you know that at least one of the Freedonian senators is honest and that, given any two Freedonian senators, at least one is corrupt. Based on these facts, can you determine how many Freedonian senators are honest and how many are corrupt? If so, what is the answer?

One honest, 49 corrupt


Give a Try:

1. The police have three suspects for the murder of Mr. Cooper: Mr. Smith, Mr. Jones, and Mr.Williams. Smith, Jones, and Williams each declare that they did not kill Cooper. Smith also states that Cooper was a friend of Jones and that Williams disliked him. Jones also states that he did not know Cooper and that he was out of town the day Cooper was killed. Williams also states that he saw both Smith and Jones with Cooper the day of the killing and that either Smith or Jones must have killed him. Can you determine who the murderer was if

a) one of the three men is guilty, the two innocent men are telling the truth, but the statements of the guilty man may or may not be true?

b) innocent men do not lie?

2. Five friends have access to a chat room. Is it possible to determine who is chatting if the following information is known? Either Kevin or Heather, or both, are chatting. Either Randy orVijay, but not both, are chatting. If Abby is chatting, so is Randy. Vijay and Kevin are either both chatting or neither is. If Heather is chatting, then so are Abby and Kevin.

3. Four friends have been identified as suspects for an unauthorized access into a computer system. They have made statements to the investigating authorities. Alice said “Carlos did it.” John said “I did not do it.” Carlos said “Diana did it.” Diana said “Carlos lied when he said that I did it.”

a) If the authorities also know that exactly one of the four suspects is telling the truth, who did it? Explain your reasoning.

b) If the authorities also know that exactly one is lying, who did it?

SOMETHING MORE INTERESTING

[Hint: Make a table where the rows represent the men and columns represent the colour of their houses, their jobs, their pets, and their favourite drinks and use logical reasoning to determine the correct entries in the table.]

This is a famous logic puzzle, attributed to Albert Einstein, and known as the zebra puzzle. ๐Ÿ‘‡๐Ÿป. Wikipedia says that only 2% of the world population is able to solve it.

Five men with different nationalities and with different jobs live in consecutive houses on a street. These houses are painted different colours. The men have different pets and have different favourite drinks. Determine who owns a zebra and whose favourite drink is mineral water (which is one of the favourite drinks) given these clues:

  1. The Englishman lives in the red house.
  2. The Spaniard owns a dog.
  3. The Japanese man is a painter.
  4. The Italian drinks tea.
  5. The Norwegian lives in the first house on the left.
  6. The green house is immediately to the right of the white one.
  7. The photographer breeds snails.
  8. The diplomat lives in the yellow house.
  9. Milk is drunk in the middle house.
  10. The owner of the green house drinks coffee.
  11. The Norwegian’s house is next to the blue one.
  12. The violinist drinks orange juice.
  13. The fox is in a house next to that of the physician.
  14. The horse is in a house next to that of the diplomat.

Answers can be found on the web. There are many similar problems in the name of Zebra Puzzle and everything have to be solved by similar approach.

(Refer: Discrete mathematics and its applications by Kenneth H. Rosen)


Thanks for reading, You can post your valuabe queries, opinions, feedbacks, suggestions, errors and corrections in the comment session.

Comments

Popular posts from this blog

Components of a Research Paper

Data Preprocessing

Artificial Intelligence - An Overview by Dharaneish