# My Master Piece Logic Puzzle Mystery

Six suspects for a bank robbery line up in front of you, with different nationalities, activities, occupations, suit colours and items. They all look nondescript to you, but you know someone holds a gun, who is most likely the true perpetrator. Who holds the gun?

1. The 4th person from the left has Wine.
2. The Swedish person has the Pen.
3. The Doctor is not the 3rd person from the left.
4. The Chinese person who has an Axe is by the side of the French person.
5. The British person who plays Tennis is by the side of the person in the Black suit.
6. The person in the Blue suit is next to the person who does Painting.
7. The person in the White suit who has a Cigar is with the person in the Green suit.
8. The person in the Black suit is exactly between the Doctor and the person with Gold.
9. The Engineer is not by the side of the person in the Yellow suit.
10. The Russian person in the Green suit is at one of the odd positions.
11. The Barber is at one end of the row with the person who does Boxing.
12. The Lawyer plays Chess.
13. The person in the Red suit does not have a Pen.
14. The 2nd person from the right listens to Music.
15. The Teacher is somewhere right to the person in the Blue suit.
16. The German person at the right end does not have Gold.
17. The Priest who does Hunting does not have a Cigar.

Like all relatives of the Zebra Puzzle we can instantly solve the problem using Prolog (the code below is adapted from Markus Triska's The Power of Prolog) – there's no tag:

:- use_module(library(clpfd)).next_to(X, Y) :- abs(X-Y) #= 1.far_from(X, Y) :- abs(X-Y) #\= 1.between(B, A, C) :- abs(A-B) #= 1, abs(B-C) #= 1, A #\= C.solution(PO, PN, PI, PS, PA, Gun, Vs) :-    Table   = [Occs, Nations, Items, Suits, Activs],    Occs    = [Engineer, Doctor, Lawyer, Teacher, Priest, Barber],    NO      = [engineer, doctor, lawyer, teacher, priest, barber],    Nations = [China, France, Sweden, Britain, Russia, Germany],    NN      = [china, france, sweden, britain, russia, germany],    Items   = [Axe, Cigar, Pen, Gold, Wine, Gun],    NI      = [axe, cigar, pen, gold, wine, gun],    Suits   = [White, Black, Yellow, Green, Blue, Red],    NS      = [white, black, yellow, green, blue, red],    Activs  = [Music, Chess, Boxing, Tennis, Painting, Hunting],    NA      = [music, chess, boxing, tennis, painting, hunting],    pairs_keys_values(PO, Occs, NO),    pairs_keys_values(PN, Nations, NN),    pairs_keys_values(PI, Items, NI),    pairs_keys_values(PS, Suits, NS),    pairs_keys_values(PA, Activs, NA),    maplist(all_distinct, Table),    append(Table, Vs),    Vs ins 1..6,    Wine #= 4, % 1    Sweden #= Pen, % 2    Doctor #\= 3, % 3    China #= Axe, % 4    next_to(China, France), % 4    Britain #= Tennis, % 5    next_to(Britain, Black), % 5    next_to(Blue, Painting), % 6    White #= Cigar, % 7    next_to(White, Green), % 7    between(Black, Doctor, Gold), % 8    far_from(Engineer, Yellow), % 9    Russia #= Green, % 10    Russia mod 2 #= 1, % 10    next_to(Barber, Boxing), % 11    Barber in (1 \/ 6), % 11    Lawyer #= Chess, % 12    Red #\= Pen, % 13    Music #= 5, % 14    Teacher #> Blue, % 15    Germany #\= Gold, % 16    Priest #= Hunting, % 17    Priest #\= Cigar. % 17

Put the above into a file and run solution(PO, PN, PI, PS, PA, Gun, Vs), label(Vs).

This gives the unique solution

Occupation | Barber   | Engineer | Priest  | Doctor  | Teacher | LawyerNation     | China    | France   | Sweden  | Britain | Russia  | GermanyItem       | Axe      | Gold     | Pen     | Wine    | Gun     | CigarSuit       | Red      | Blue     | Black   | Yellow  | Green   | WhiteActivity   | Painting | Boxing   | Hunting | Tennis  | Music   | Chess

So the Russian has the gun.

• Yes, that is indeed the answer. I think the real beauty is to manually solve the puzzle although I knew there are computer codes already made to calculate the answer. By the way thanks for confirming that this is the only solution and my puzzle has no mistake. Oct 19, 2022 at 9:54

This is my solution, including step by step process.

• To start with, numbers 1 to 6 are arranged left to right.

• Per instructions {1}, {14} and {16}, wine is at slot 4, music is at slot 5, and German is at slot 6.

• Per instruction {11} the barber is at one end of the row next to boxing. This means barber,boxing must either be at respective slots 1,2 or 6,5. Because slot 5 already has a hobby (music), boxing cannot go there and therefore barber (which must be at its side) cannot go at slot 6. So barber is at slot 1 and boxing at slot 2.

• The doctor cannot be at slot 1 because of the barber.

• The doctor cannot be at slot 3 because of instruction {3}.

• The person in the black suit cannot be at slot 2, because instruction {8} tells us the doctor is adjacent, yet we have already decided the doctor cannot be at slot 1 or 3.

• The British person cannot be at slot 1, because instruction {5} puts them together with the person in the black suit, who would have to be at slot 2, which we have decided is impossible.

• Per instruction {5} the British person plays Tennis. They cannot be at slots 2 (boxing), 5 (music), or 6 (German) because those hobbies and nationalities are already known.

• Note that we have already pinned the British person to either slot 3 or 4.

• Suppose the British person is at slot 3. The Russian person would be in one of the remaining two odd numbered slots because of instruction {10}.

• Let's consider possibility (a): Russian slot is 1, and possibility (b): Russian slot is 5.

• Possibility (b) is false because the French and Chinese people, which must be next to each other due to instruction {4} are forced into the only remaining adjacent slots, 1 and 2 (in either order, it doesn't matter). Then the Swedish person is forced into slot 4 because it is the only remaining slot (remember the German person is situated at slot 6). However the Swedish person has the pen, due to instruction {2}, and there is already wine at slot {4}. This is a contradiction.

• Possibility (a) is false because the Russian person at slot 1 has a green suit due to instruction {10} and is next to the person in white suit due to instruction {7}. Instruction {7} also specifies the person in white suit has a cigar. These findings place the person in white suit and the cigar at slot 2. Because the Russian person is in slot 1, the French and Chinese people, which must be next to each other due to instruction {4} are forced into the only remaining adjacent slots, 4 and 5 (in either order, it doesn't matter). This forces the Swedish person into slot 2, the only remaining slot. However the Swedish person has the pen due to instruction {2}, and we have already identified a cigar at slot 2. This is a contradiction.

• Since possibilities (a) and (b) both lead to contradictions, we are forced to conclude that the British person is not at slot 3, and must be at slot 4, the only remaining option. Instruction {5} also places Tennis at slot 4 now.

• We already know the person in a black suit is next to the British person, so they are at slot 3 or 5. Instruction {8} tells us the person in black suit is exactly between the doctor and the gold, so the gold is at slot 2, 4, or 6. There is wine at slot 4 so the gold cannot be at slot 4. Instruction {16} tells us the gold is not in slot 6, at the right end. Therefore the gold is at slot 2 and the person in black is at slot 3. Instruction {8} tells us the doctor is at slot 4, being on the other side of the person in black, from the gold.

• According to instruction {10} the Russian person has a green suit and cannot be in slots 2, 4 or 6 because those are even numbers. They cannot be in slot 3 because the person in black suit is already there. They cannot be in slot 1 because according to instruction {7}, the person in green suit is next to the person in white suit with a cigar, which would place a cigar in slot 2, which is not allowed because there is already gold there. Therefore the Russian person and the green suit are in slot 5, the only remaining possibility.

• The person in a white suit with a cigar must be in slot 6 because they are next to the person in a green suit, and there is wine in slot 4.

• The priest who per instruction {17} goes hunting and does not have a cigar, cannot be in slot 1 because there is a barber there, cannot be in slot 2 because boxing is there, cannot be in slot 4 because there is a doctor playing tennis, cannot be in slot 5 because music is there, and cannot be in slot 6 because the cigar is there and that's just against the rules. Therefore the priest who goes hunting is in slot 3.

• The lawyer who per instruction {12} plays chess, cannot be in slots 1-5 due to various occupations and hobbies already filling the slots. Therefore he is in slot 6.

• Painting goes in the only remaining hobby slot at position 1. Because instruction {6} says the person in the blue suit is adjacent, they go to slot 2. Because instruction {15} says the teacher is right of the person in blue and the only unfilled occupation slot to the right of blue is slot 5, the teacher goes in slot 5.

• The engineer goes in the only unfilled occupation slot at position 2. Instruction {9} stipulates that the yellow suit cannot be next to the engineer, which rules out slot 1, so that goes in the only other possible suit slot at position 4.

• The red suit goes in the only remaining suit slot at position 1. The Swedish person, who according to instruction 2 has a pen, cannot go into slot 1 because of instruction {13}, and so goes in the only remaining slot without a nationality or item, at position 3.

• According to instruction {4} the Chinese person has an axe so they go in the only remaining slot without a nationality or item at position 1. The French person goes next to them into slot 2.

• This leaves the gun, which goes into slot 5. The Russian teacher who likes music, with the green suit, has the gun.

Here is a somewhat messy diagram (produced using yEd) showing my workings in their final state. Though this is not important for the answer, it helps to show the solving process was legitimate. At first I was just grouping cells and dragging groups about like a jigsaw puzzle, this was before I worked out the more formal process.

The rows are in the same order as Parcly Taxel's answer because I compared my own answer against theirs.

• I really appreciate that you solved this puzzle which I created by myself in around 9-10 hours because it really takes some quality time to solve it. Did you find this puzzle hard, interesting, etc? I will really appreciate it if you can give a small review about it. Nov 7, 2022 at 8:49
• This was perfect for my ability level. Thank you. I don't get on with cryptic puzzles but this was pure logic based. At first I underestimated this, after 5 mins I realised I couldn't solve it in my head, then I was confident a diagram would make it easy, and then it didn't, so I started putting the nodes into tetris-like blocks and shuffling them to fit. Black lines vertical, red lines not. I only put the answer in text form later, but next time I would try that first. In total I spent several hours, similar to you. How did you make it? Did I solve it in the same order that you expected? Nov 7, 2022 at 13:57
• I really appreciate your review. Yes, your steps were almost the same compared to mine. To make this puzzle I first tried to make and check different combinations of hints which do not contradict each other. After making the logical hints and testing them, I changed the order of the hints so that it becomes hard for people to see which hints should be used step by step. I made logical puzzles in my childhood. Nov 7, 2022 at 14:46
• There is another puzzle (Snakes, Ladders, and Magic Dice) in my profile that you would really like to solve. I created that puzzle recently and it is fun and purely logic-based, especially for your ability. Trust me, you would really like it. Below is the link to the puzzle. Please check it and do give a review :). Thank you. puzzling.stackexchange.com/questions/118486/… Nov 7, 2022 at 14:48