• 171

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.



There has been a murder in the village!
As the local detective, it’s up to you to find out who was the killer.
You’ve asked everyone where they were at the time of the crime, and who they were with.

All innocent people (aka "villagers") will tell you the truth, only the killer will lie.
If everybody is telling the truth, then that must mean that you were the killer!
Can you determine who the killer was?

Some clues:
- The killer can claim to have been anywhere, with anyone.
- The villagers (non-killers) haven’t seen the killer.
- The villagers (non-killers) were not in the same location as the killer.
- If someone claims to have been alone, that also gives you information.
- If everyone has a good alibi, you were the killer.
- If the killer claims to be alone, the claim can be proven to be false.

Example case #1:
Paul: I was in the school with Benjamin.
Benjamin: I was in the workshop with Raul.
Raul: I was in the workshop with Benjamin.

Paul did it!

Benjamin and Raul gave each other alibi’s,
So it must have been Paul who is lying.

Example case #2:
Patty: I was in the church with Bill.
Bill: I was in the church, alone.

Patty did it!

If neither were the killer, they would both say there were in the church together.
If Patty was the killer, Bill would be truthful that he was alone in the church.
If Bill was the killer, Patty would be lying that Bill was in the church, but villagers don't lie.
So the only valid option is that Patty must have been the killer.
Line 1: An integer N for the number of suspects in the village.
Next N lines:
Name: I was in the Location with Name0 and Name1 ... and NameY.
Name: I was in the Location, alone.
Line 1: Name did it!
Line 1: It was me!
2 ≤ N ≤ 10
There are no ambiguous cases, there is only one solution to each test case.
Tom: I was in the church with Bob.
Jane: I was in the garden with Joyce.
Bob: I was in the church with Tom.
Joyce: I was in the garden with Jane.
It was me!

A higher resolution is required to access the IDE