For illustration only, we show the names of the possible murderers, locations and weapons. The names are not required to solve the task. Murderer Location Weapon
- Professor Plum
- Miss Scarlet
- Colonel Mustard
- Mrs. White
- Reverend Green
- Mrs. Peacock
- Ballroom
- Kitchen
- Conservatory
- Dining Room
- Billiard Room
- Library
- Lounge
- Hall
- Study
- Cellar
- Lead pipe
- Dagger
- Candlestick
- Revolver
- Rope
- Spanner
Jill repeatedly tries to guess the correct combination of murderer, location and weapon. Each guess is called a theory. She asks her assistant Jack to confirm or to refute each theory in turn. When Jack confirms a theory, Jill is done. When Jack refutes a theory, he reports to Jill that one of the murderer, location or weapon is wrong.
You are to implement the procedure Solve that plays Jill's role. The grader will call Solve many times, each time with a new case to be solved. Solve must repeatedly call Theory(M,L,W), which is implemented by the grader. M, L and W are numbers denoting a particular combination of murderer, location and weapon. Theory(M,L,W) returns 0 if the theory is correct. If the theory is wrong, a value of 1, 2 or 3 is returned. 1 indicates that the murderer is wrong; 2 indicates that the location is wrong; 3 indicates that the weapon is wrong. If more than one is wrong, Jack picks one arbitrarily between the wrong ones (not necessarily in a deterministic way). When Theory(M,L,W) returns 0, Solve should return.
As example, assume that Miss Scarlet committed the murder (Murderer 2) in the conservatory (Location 3) using a revolver (Weapon 4). When procedure Solve makes the following calls to function Theory, the results in the second column could be returned.
Call Returned value Explanation Theory(1, 1, 1) 1, or 2, or 3 All three are wrong Theory(3, 3, 3) 1, or 3 Only the location is correct Theory(5, 3, 4) 1 Only the murderer is wrong Theory(2, 3, 4) 0 All are correct