Problem Statement
Your goal is to write a class to try to deduce the cards which are set aside. You will be given a
"<guesser> <suspect guessed> <location guessed> <weapon guessed> <responder> <response>"
<guesser> will be a digit between 1 and 3, inclusive, representing the person making the guess. You are player 1, so if <guesser> is 1, it means that you made the guess. <suspect guessed>, <location guessed>, and <weapon guessed> will all be single digits representing which suspect, location and weapon were guessed. <responder> will be a single digit between 0 and 3, inclusive, representing the player who responded to the guess. <responder> will not be the same as <guesser>. If <responder> is 0, it means that none of the non-guessing players had any of the cards associated with the guess. If <responder> is 1, it means that you are the one who responded, and <response> will be an element of cards, representing which card you showed to the guesser. If <guesser> is 1, then you are the one who guessed, and if <responder> is not 0, then <response> will represent the card that player <responder> showed you. If you are the guesser and no one responded, or if you are neither the responder nor the guesser, then <response> will be "N0" (the number zero, not the letter oh), meaning that the response was either hidden from you or did not exist.
You are to determine the set of cards that could be secret cards. This set will always contain at least one suspect, one location, and one weapon. You should return a sorted
Definition
- Class:
- Clue
- Method:
- whodunit
- Parameters:
- String[], String[]
- Returns:
- String[]
- Method signature:
- String[] whodunit(String[] cards, String[] guesses)
- (be sure your method is public)
Notes
- You are player 1, the player to your left is player 2, and the player to his or her left is player 3, who is to your right.
- Players do not necessarily make guesses in any particular order. So, a single player may make more than 1 guess in a row.
Constraints
- cards will contain exactly 6 distinct elements, formatted as described in the problem statement.
- guesses will contain between 0 and 50 elements, inclusive, formatted as described in the problem statement.
- There will always be at least one way to divide the cards not in cards between the secret cards, player 2's cards, and player 3's cards that is consistent with guesses.
- Each element of guesses will be formatted as described above.
- If
is 1, then either will be 0 and will be N0, or will not be 0 and will represent one of the three cards guessed. - If neither
nor is 1, then will be N0. - If
is 1, then will be an element of cards and will be one of the three cards guessed. - If
is not 1, then will not be an element of cards. will not equal
Examples
{"S1","S2","S4","S3","S5","W5"}
{"1 1 1 1 0 N0"}
Returns: { "L1", "S6", "W1" }
In this example, you make a single guess of S1, W1, L1. No one is able to respond (
= 0), which means that neither of the other two players has S1, W1, or L1. Thus those three cards must all be either secret cards or your cards. W1 and L1 are not your cards, and are thus secret cards. Furthermore, since you have five of the six suspect cards, the only other possible suspect card that could be a secret card is S6. {"L3","S2","S4","S3","S5","W5"}
{"2 1 1 1 0 N0"}
Returns: { "L1", "L2", "L4", "L5", "L6", "L7", "L8", "L9", "S1", "S6", "W1", "W2", "W3", "W4", "W6" }
This is a similar guess as the one in example 0, only with a different guesser. You have no idea which cards the guesser has, so the guess doesn't really tell you anything, and any card not in your hand can be a secret card.
{"W4","W1","L5","L9","S3","L2"}
{"2 3 8 4 1 W4", "1 3 8 3 3 W3"}
Returns: { "L8", "S1", "S2", "S4", "S5", "S6", "W2", "W5", "W6" }
From the first guess, we know that player 3 doesn't have S3, L8, or W4. Similarly, from the second guess, we know that player 2 doesn't have S3, L8, or W3. We also know that player 3 has W3, since he showed it to us. First, we can deduce that the secret location must be L8, since neither of the other players have it, and we don't have it. Next, the secret weapon has to be W2, W5, or W6, since we know who has the other weapons. The only thing we know about suspects is the secret card isn't S3, since we have that.
{"W4","W1","L5","L9","S3","L2"}
{"1 3 5 4 0 N0"}
Returns: { "L1", "L3", "L4", "L6", "L7", "L8", "S1", "S2", "S4", "S5", "S6", "W2", "W3", "W5", "W6" }
Guessing three of your own cards will never give you any new information.
{"W4","W1","L5","L9","S3","L2"}
{}
Returns: { "L1", "L3", "L4", "L6", "L7", "L8", "S1", "S2", "S4", "S5", "S6", "W2", "W3", "W5", "W6" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0", "3 6 5 4 1 L5", "1 6 1 3 2 W3", "2 3 5 1 3 N0", "3 5 7 1 1 S5", "1 6 1 1 3 L1", "2 1 2 5 3 N0", "3 4 6 5 1 W5", "1 3 3 4 2 W4", "2 6 4 1 3 N0", "3 4 3 6 1 W6", "1 4 6 1 2 S4", "2 2 5 6 3 N0", "3 6 7 4 1 L7", "1 6 4 1 3 L4", "2 6 5 1 1 L5", "3 4 3 1 2 N0", "1 6 2 1 3 L2", "2 6 3 1 0 N0", "3 6 3 1 0 N0"}
Returns: { "L3", "S6", "W1" }
{"L6","L9","S4","W2","W3","W4"}
{}
Returns: { "L1", "L2", "L3", "L4", "L5", "L7", "L8", "S1", "S2", "S3", "S5", "S6", "W1", "W5", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1"}
Returns: { "L3", "L5", "L6", "L7", "L8", "L9", "S4", "S5", "S6", "W1", "W2", "W3", "W4", "W5", "W6" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5"}
Returns: { "L1", "L2", "L3", "L4", "L6", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2", "W3", "W4" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3"}
Returns: { "L2", "L3", "L4", "L5", "L7", "L8", "S1", "S2", "S3", "S5", "S6", "W1", "W5", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3"}
Returns: { "L3", "L6", "L7", "L8", "L9", "S4", "S5", "S6", "W1", "W2", "W3", "W4", "W5", "W6" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5"}
Returns: { "L1", "L2", "L3", "L4", "L6", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2", "W4" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3","1 3 5 1 2 S3","2 5 7 1 3 N0","3 6 1 1 2 N0"}
Returns: { "L2", "L3", "L4", "L5", "L7", "L8", "S1", "S2", "S5", "S6", "W1", "W5", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3","1 5 7 1 2 S5","2 6 1 1 1 L1","3 1 2 5 1 S1"}
Returns: { "L3", "L6", "L7", "L8", "L9", "S4", "S6", "W1", "W2", "W4", "W5", "W6" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5","1 6 1 1 3 L1","2 1 2 5 3 N0","3 4 6 5 1 W5"}
Returns: { "L2", "L3", "L4", "L6", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2", "W4" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3","1 3 5 1 2 S3","2 5 7 1 3 N0","3 6 1 1 2 N0","1 1 2 5 2 S1","2 4 6 5 3 N0","3 3 3 4 1 W4"}
Returns: { "L2", "L3", "L4", "L5", "L7", "L8", "S2", "S5", "S6", "W1", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3","1 5 7 1 2 S5","2 6 1 1 1 L1","3 1 2 5 1 S1","1 4 6 5 2 W5","2 3 3 4 3 N0","3 6 4 1 1 L4"}
Returns: { "L3", "L6", "L7", "L8", "L9", "S4", "S6", "W1", "W2", "W4", "W6" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5","1 6 1 1 3 L1","2 1 2 5 3 N0","3 4 6 5 1 W5","1 3 3 4 2 W4","2 6 4 1 3 N0","3 4 3 6 1 W6"}
Returns: { "L2", "L3", "L4", "L6", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3","1 3 5 1 2 S3","2 5 7 1 3 N0","3 6 1 1 2 N0","1 1 2 5 2 S1","2 4 6 5 3 N0","3 3 3 4 1 W4","1 6 4 1 2 L4","2 4 3 6 3 N0","3 4 6 1 1 S4"}
Returns: { "L2", "L3", "L5", "L7", "L8", "S2", "S5", "S6", "W1", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3","1 5 7 1 2 S5","2 6 1 1 1 L1","3 1 2 5 1 S1","1 4 6 5 2 W5","2 3 3 4 3 N0","3 6 4 1 1 L4","1 4 3 6 2 W6","2 4 6 1 3 N0","3 2 5 6 1 S2"}
Returns: { "L3", "L6", "L7", "L8", "L9", "S4", "S6", "W1", "W2", "W4" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5","1 6 1 1 3 L1","2 1 2 5 3 N0","3 4 6 5 1 W5","1 3 3 4 2 W4","2 6 4 1 3 N0","3 4 3 6 1 W6","1 4 6 1 2 S4","2 2 5 6 3 N0","3 6 7 4 1 L7"}
Returns: { "L2", "L3", "L4", "L6", "L9", "S1", "S3", "S6", "W1", "W2" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3","1 3 5 1 2 S3","2 5 7 1 3 N0","3 6 1 1 2 N0","1 1 2 5 2 S1","2 4 6 5 3 N0","3 3 3 4 1 W4","1 6 4 1 2 L4","2 4 3 6 3 N0","3 4 6 1 1 S4","1 2 5 6 2 S2","2 6 7 4 3 N0","3 6 4 1 2 N0"}
Returns: { "L2", "L3", "L5", "L7", "L8", "S5", "S6", "W1", "W6" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3","1 5 7 1 2 S5","2 6 1 1 1 L1","3 1 2 5 1 S1","1 4 6 5 2 W5","2 3 3 4 3 N0","3 6 4 1 1 L4","1 4 3 6 2 W6","2 4 6 1 3 N0","3 2 5 6 1 S2","1 6 7 4 2 L7","2 6 4 1 1 L4","3 6 5 1 2 N0"}
Returns: { "L3", "L6", "L8", "L9", "S4", "S6", "W1", "W2", "W4" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5","1 6 1 1 3 L1","2 1 2 5 3 N0","3 4 6 5 1 W5","1 3 3 4 2 W4","2 6 4 1 3 N0","3 4 3 6 1 W6","1 4 6 1 2 S4","2 2 5 6 3 N0","3 6 7 4 1 L7","1 6 4 1 3 L4","2 6 5 1 1 L5","3 4 3 1 2 N0"}
Returns: { "L2", "L3", "L6", "L9", "S6", "W1" }
{"L6","L9","S4","W2","W3","W4"}
{"1 6 1 6 2 L1","2 6 5 4 3 N0","3 6 1 3 1 W3","1 3 5 1 2 S3","2 5 7 1 3 N0","3 6 1 1 2 N0","1 1 2 5 2 S1","2 4 6 5 3 N0","3 3 3 4 1 W4","1 6 4 1 2 L4","2 4 3 6 3 N0","3 4 6 1 1 S4","1 2 5 6 2 S2","2 6 7 4 3 N0","3 6 4 1 2 N0","1 6 5 1 3 L5","2 4 3 1 1 S4","3 6 2 1 2 N0"}
Returns: { "L3", "S5", "S6", "W1" }
{"L1","L2","L4","S1","S2","S3"}
{"3 6 1 6 1 L1","1 6 5 4 2 L5","2 6 1 3 3 N0","3 3 5 1 1 S3","1 5 7 1 2 S5","2 6 1 1 1 L1","3 1 2 5 1 S1","1 4 6 5 2 W5","2 3 3 4 3 N0","3 6 4 1 1 L4","1 4 3 6 2 W6","2 4 6 1 3 N0","3 2 5 6 1 S2","1 6 7 4 2 L7","2 6 4 1 1 L4","3 6 5 1 2 N0","1 4 3 1 3 S4","2 6 2 1 1 L2","3 6 3 1 0 N0"}
Returns: { "L3", "L6", "L8", "L9", "S6", "W1" }
{"L5","L7","L8","S5","W5","W6"}
{"2 6 1 6 3 N0","3 6 5 4 1 L5","1 6 1 3 2 W3","2 3 5 1 3 N0","3 5 7 1 1 S5","1 6 1 1 3 L1","2 1 2 5 3 N0","3 4 6 5 1 W5","1 3 3 4 2 W4","2 6 4 1 3 N0","3 4 3 6 1 W6","1 4 6 1 2 S4","2 2 5 6 3 N0","3 6 7 4 1 L7","1 6 4 1 3 L4","2 6 5 1 1 L5","3 4 3 1 2 N0","1 6 2 1 3 L2","2 6 3 1 0 N0","3 6 3 1 0 N0"}
Returns: { "L3", "S6", "W1" }
{ "L1", "L2", "S1", "L3", "L4", "W1" }
{ "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 6 6 6 3 N0", "2 5 5 5 3 N0" }
Returns: { "L5", "L6", "L7", "L8", "L9", "S2", "S3", "S4", "S5", "S6", "W2", "W3", "W4", "W5", "W6" }
{ "W5", "S5", "L5", "L6", "L7", "L8" }
{"2 1 1 1 0 N0","2 2 2 2 0 N0","3 3 3 3 0 N0","3 4 4 4 0 N0"}
Returns: { "L1", "L2", "L3", "L4", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2", "W3", "W4", "W6" }
{ "W5", "S5", "L5", "L6", "L7", "L8" }
{"2 1 1 1 0 N0","2 2 2 2 0 N0","3 3 3 3 0 N0","3 4 4 4 0 N0", "2 1 1 2 0 N0", "2 1 2 1 0 N0", "2 1 2 2 0 N0", "2 2 1 1 0 N0", "2 2 1 2 0 N0", "2 2 2 1 0 N0"}
Returns: { "L1", "L2", "L3", "L4", "L9", "S1", "S2", "S3", "S4", "S6", "W1", "W2", "W3", "W4", "W6" }
{"L1","L2","L4","S5","S6","W3"}
{"3 6 1 4 1 L1","3 2 2 4 1 L2","3 5 4 3 1 S5","3 5 4 3 1 W3","3 1 1 1 1 L1","3 6 2 4 1 S6","3 5 4 3 1 L4","3 5 3 3 1 W3","3 6 4 4 1 L4","3 5 1 3 1 L1","3 1 1 4 1 L1","3 5 1 1 1 L1","3 1 2 3 1 W3","3 2 1 4 1 L1","3 6 2 3 1 S6","3 6 1 3 1 W3","3 6 2 4 1 L2","3 2 4 4 1 L4","3 5 2 1 1 L2","3 1 5 3 1 W3","3 5 2 3 1 W3","3 6 1 3 1 S6","3 5 1 3 1 W3","3 6 4 3 1 L4","3 6 5 4 1 S6","3 6 2 3 1 W3","3 5 1 1 1 S5","3 6 3 3 1 S6","3 5 4 1 1 S5","3 6 1 4 1 S6","3 1 2 3 1 L2","3 6 3 4 1 S6","3 5 2 3 1 S5","3 2 2 1 1 L2","3 6 4 3 1 S6","3 6 2 3 1 L2","3 5 2 3 1 L2","3 5 1 3 1 S5","3 5 5 3 1 S5","3 1 1 3 1 L1","3 2 4 1 1 L4","3 1 1 3 1 W3","3 6 5 3 1 S6","3 5 5 1 1 S5","3 6 4 4 1 S6","3 5 3 1 1 S5","3 1 2 1 1 L2","3 1 2 4 1 L2","3 6 4 3 1 W3","1 1 3 1 0 N0"}
Returns: { "L3", "S1", "W1" }
{"L1","L2","L4","S5","S6","W3"}
{"3 6 1 4 1 L1","3 2 2 4 1 L2","3 5 4 3 1 S5","3 5 4 3 1 W3","3 1 1 1 1 L1","3 6 2 4 1 S6","3 5 4 3 1 L4","3 5 3 3 1 W3","3 6 4 4 1 L4","3 5 1 3 1 L1","3 1 1 4 1 L1","3 5 1 1 1 L1","3 1 2 3 1 W3","3 2 1 4 1 L1","3 6 2 3 1 S6","3 6 1 3 1 W3","3 6 2 4 1 L2","3 2 4 4 1 L4","3 5 2 1 1 L2","3 1 5 3 1 W3","3 5 2 3 1 W3","3 6 1 3 1 S6","3 5 1 3 1 W3","3 6 4 3 1 L4","3 6 5 4 1 S6","3 6 2 3 1 W3","3 5 1 1 1 S5","3 6 3 3 1 S6","3 5 4 1 1 S5","3 6 1 4 1 S6","3 1 2 3 1 L2","3 6 3 4 1 S6","3 5 2 3 1 S5","3 2 2 1 1 L2","3 6 4 3 1 S6","3 6 2 3 1 L2","3 5 2 3 1 L2","3 5 1 3 1 S5","3 5 5 3 1 S5","3 1 1 3 1 L1","3 2 4 1 1 L4","3 1 1 3 1 W3","3 6 5 3 1 S6","3 5 5 1 1 S5","3 6 4 4 1 S6","3 5 3 1 1 S5","3 1 2 1 1 L2","3 1 2 4 1 L2","3 6 4 3 1 W3","3 6 1 3 1 L1"}
Returns: { "L3", "L5", "L6", "L7", "L8", "L9", "S1", "S2", "S3", "S4", "W1", "W2", "W4", "W5", "W6" }
{"S6","W6","L6","L7","L8","L9"}
{"2 1 1 5 3 N0","2 1 2 5 3 N0","2 1 3 5 3 N0","2 1 4 5 3 N0", "2 2 1 5 3 N0","2 2 2 5 3 N0","2 2 3 5 3 N0","2 2 4 5 3 N0", "2 3 1 5 3 N0","2 3 2 5 3 N0","2 3 3 5 3 N0","2 3 4 5 3 N0", "2 4 1 5 3 N0","2 4 2 5 3 N0","2 4 3 5 3 N0","2 4 4 5 3 N0", "1 5 5 5 3 S5","1 5 5 5 3 L5" }
Returns: { "L1", "L2", "L3", "L4", "S1", "S2", "S3", "S4", "W1", "W2", "W3", "W4" }
{ "L4", "L5", "L6", "L7", "L8", "L9" }
{ "2 1 1 1 3 N0", "2 1 1 2 3 N0", "2 1 1 3 3 N0", "2 1 1 4 3 N0", "2 1 1 5 3 N0", "2 1 1 6 3 N0", "2 2 1 1 3 N0", "2 2 1 2 3 N0", "2 2 1 3 3 N0", "2 2 1 4 3 N0", "2 2 1 5 3 N0", "2 2 1 6 3 N0", "2 3 1 1 3 N0", "2 3 1 2 3 N0", "2 3 1 3 3 N0", "2 3 1 4 3 N0", "2 3 1 5 3 N0", "2 3 1 6 3 N0", "2 4 1 1 3 N0", "2 4 1 2 3 N0", "2 4 1 3 3 N0", "2 4 1 4 3 N0", "2 4 1 5 3 N0", "2 4 1 6 3 N0", "2 5 1 1 3 N0", "2 5 1 2 3 N0", "2 5 1 3 3 N0", "2 5 1 4 3 N0", "2 5 1 5 3 N0", "2 5 1 6 3 N0", "2 6 1 1 3 N0", "2 6 1 2 3 N0", "2 6 1 3 3 N0", "2 6 1 4 3 N0", "2 6 1 5 3 N0", "2 6 1 6 3 N0" }
Returns: { "L2", "L3", "S1", "S2", "S3", "S4", "S5", "S6", "W1", "W2", "W3", "W4", "W5", "W6" }