CHALLENGE: Guess the number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

CHALLENGE: Guess the number

All languages are welcome! Patrik and Susan play the game "Guess a Number". Patrik envisioned a natural number from 1 to n. Susan is trying to guess this number, for this she calls some sets of natural numbers. Patrik began to cheat. On each of Susan's questions, he chooses such a variant of answer YES or NO, so that the set of possible conceived numbers remains as much as possible. For example, if Patrik conceived a number from 1 to 5, and Susan asked about numbers 1 and 2, Patrik will answer NO, and if Susan asks about 1, 2, 3, then Patrik will answer YES. If, however, Susan in her question lists exactly half of the planned numbers, then Patrik from the harmfulness always answers NO. Finally, Patrik responds to all the previous questions of Susan and his answers to them, that is, the set of possible conceived numbers decreases. The first line contains the largest number that Patrik could have thought of. Each next line contains another question for Susan: a set of numbers separated by spaces. The last line of input contains one word HELP. For each question of Susan, take Patrik's answer to this question. After that, output through the space, in ascending order, all the numbers that Patrik could have asked after answering all the questions of Susan. For example: Input data: 10 1 2 3 4 5 2 4 6 8 10 HELP Output data: NO YES 6 8 10

8th Nov 2017, 11:45 PM
Ilia Fedorov
Ilia Fedorov - avatar
4 Answers
8th Nov 2017, 11:42 PM
Ilia Fedorov
Ilia Fedorov - avatar
+ 5
@Yash Thatte absolutly!
10th Nov 2017, 3:07 PM
Ilia Fedorov
Ilia Fedorov - avatar
+ 4
@vcc u nailed it man!😂😂😂 really it's quite confusing
10th Nov 2017, 6:11 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 3
looks more like "guess the challenge"
9th Nov 2017, 8:43 PM
VcC
VcC - avatar