← Back to challenges

No Sh*t Sherlock

PythonHardstringsformatting

Instructions

On a crime scene, there are many pieces of evidence that point to a particular person having the murder weapon and motive to kill poor old Tom (although not poor at all).

Create a function that takes phrases/words as clues and forms a sentence formatted to have the murder's name, verb, "Tom as", Reason.

SnWeaponVerb to be usedReason
1PoisonPoisonedOnly X could have such high-grade poison.
2KnifeButcheredOnly X was in the kitchen.
3BatSwattedOnly X is a baseball player.
4GunShotOnly X had a gun.
5BriefcaseSmackedOnly X was after Tom's money.

Examples

sherlock("Mr.Red", "Knife") ➞ "Mr. Red butchered Tom as only he was in the kitchen."

sherlock("Ms.Blue", "Poison") ➞ "Ms. Blue poisoned Tom as only she could have such high-grade poison."

sherlock("Mr.Red", "Bat") ➞ "Mr. Red swatted Tom as only he was a baseball player."

Notes

  • Ms/Mr gives you the gender of the murderer.
  • Feel free to remove the dictionary if you want.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.