Problem Statement
Your task is, given Kate's questions and Aaron's answers over the course of a single round, return the number Aaron
thought of, or one of the two
In more detail:
- the answers are in the same order as the questions
- Kate's questions are presented as a list of numbers separated by spaces. For example, if Kate asks: "Is this number more than 5?", this question is translated to the form: "Is this number from the set {6, 7, 8}?" and the input String would list the set in ascending order: "6 7 8"
- Aaron's answer is always either "YES" or "NO"
- return "CONTRADICTION" when the answers contradict the fact that Aaron lies not more than once (see examples)
- return "NOT ENOUGH INFO" when Aaron's number is not uniquely determined, and there is no contradiction
- in all other cases return the number Aaron thought of
Definition
- Class:
- NumberGuess
- Method:
- answer
- Parameters:
- String[], String[]
- Returns:
- String
- Method signature:
- String answer(String[] questions, String[] answers)
- (be sure your method is public)
Constraints
- questions has between 1 and 10 elements inclusive
- answers must contain the same number of elements as questions
- each element of questions has between 1 and 15 characters inclusive
- each element of questions consists of digits between 1 and 8 inclusive and spaces
- each element of questions starts and ends with a digit
- each element of questions doesn't have two spaces or two digits in a row
- digits in an element of questions are distinct and in ascending order
- each element of answers is either "YES" or "NO"
Examples
{"1 2 3"}
{"YES"}
Returns: "NOT ENOUGH INFO"
{"1 2 3","1 2 3","1 2 3","1 2 3"}
{"YES","NO","YES","NO"}
Returns: "CONTRADICTION"
{"1","1"}
{"YES","YES"}
Returns: "1"
{"1 2 3 4","1 2","1","1 3"}
{"YES","YES","YES","YES"}
Returns: "1"
{"1 2 3 4","1 2","1"}
{"YES","YES","YES"}
Returns: "NOT ENOUGH INFO"
as Aaron could have thought of 1 and given all true answers or he could have thought of 2, and lied on the last answer
{"1 2 3 4","1 2","1","1"}
{"YES","YES","YES","NO"}
Returns: "NOT ENOUGH INFO"
{"1 2 3 4","5","4","1 2 3"}
{"YES","YES","NO","NO"}
Returns: "5"
{"1 2 3 4","1 2","1","1","2 3"}
{"YES","YES","YES","NO","YES"}
Returns: "2"
{"1 2 3 4 5 6 7 8", "1 2 3 4 5 6 7", "1 2 3 4 5 6", "1 2 3 4 5", "1 2 3 4", "1 2 3", "1 2", "1"}
{"YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES"}
Returns: "NOT ENOUGH INFO"
{"1 2 3 4 5 6 7 8", "1 2 3 4 5 6 7", "1 2 3 4 5 6", "1 2 3 4 5", "1 2 3 4", "1 2 3", "1 2", "1", "2"}
{"YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES"}
Returns: "NOT ENOUGH INFO"
{"1 2 3 4 5 6 7 8", "1 2 3 4 5 6 7", "1 2 3 4 5 6", "1 2 3 4 5", "1 2 3 4", "1 2 3", "1 2", "1", "2", "2"}
{"YES", "YES", "YES", "YES", "YES", "YES", "YES", "YES","YES","YES"}
Returns: "2"
{"8","7","6","5","4","3","2","1"}
{"NO","NO","NO","NO","NO","NO","NO","NO"}
Returns: "NOT ENOUGH INFO"
{"8","7","6","5","4","3","2","1","4 5 6"}
{"NO","NO","NO","YES","NO","NO","NO","NO","NO"}
Returns: "5"
{"8","7","6","5","4","3","2","1","4 5 6"}
{"YES","NO","NO","NO","NO","NO","NO","NO","NO"}
Returns: "8"
{"8","7","6","5","4","3","2","4 5 6"}
{"NO","NO","NO","YES","NO","NO","NO","NO"}
Returns: "NOT ENOUGH INFO"
{"8","7","6","5","4","3","2","4 5 6"}
{"YES","NO","NO","NO","NO","NO","NO","NO"}
Returns: "NOT ENOUGH INFO"
{"8","5","2 7","2 6 8","5 7","3 7","4 8","5","4","3 4 5"}
{"YES","NO","NO","NO","NO","NO","NO","NO","NO","NO"}
Returns: "1"
Well, half of this is random garbage....
{ "1 2 3 4 5 7 8", "1 2 3 4 5 7 8", "1 2 3 4 7 8", "1 2 3 4 5 7 8" }
{ "NO", "NO", "YES", "NO" }
Returns: "6"
{ "1 2 3 4 5 6 7 8", "1", "1", "1", "1", "1", "1" }
{ "NO", "YES", "YES", "YES", "YES", "NO", "NO" }
Returns: "CONTRADICTION"
{ "1 2 3 4 6 7 8", "1 2 3 4 6 7 8" }
{ "NO", "NO" }
Returns: "5"
{ "1 2", "1 2", "3 4" }
{ "YES", "YES", "YES" }
Returns: "NOT ENOUGH INFO"
{"1"}
{"YES"}
Returns: "NOT ENOUGH INFO"