Answer for Prog Trivia
The answer involves the mathematical concept. It is the beauty of maths. The user must be left with the least number, that is 1. If it is more than 1, then the user can tell some other number so that the computer is left with 1. Actually assume that the first no given by the computer be x.
Now, consider
Computer : x 6 5
User : 3 4 1
In this example listen that the user has to pick 1. Because there is no other option for him.
Similarly the computer must give the number so that the sum of the previous number given by the user and the number that is going to be given by the computer must be 9. Because it is the maximum number. Now we have to find the x. The total should not exceed 25.
x+some multiple of 9 + 1(the last no which the user necessarily has to select)= 25
now x+9n=24.
when we put n=2(the max value that can be taken by n so that 9n does not exceed 24)
we will get x to be 6.
So the computer has to give the first number as 6 and the corresponding numbers must be (9-the previous no given by the user) .
This can be implemented by simple while and if conditions in C or in C++.
If this answer is confusing please post. I will explain
