Fun Math: A number game that can lie

Source: Internet
Author: User

It is also the peak of a year's job search. A variety of strange smart questions are also testing the IQ of students. Some of these questions make people die in large numbers... Recently, some people asked a lie-related guess digital game and asked "Yuan Fang, what do you think about this ?", I want to blow a salt soda to him. Now, let's get down to the truth.

Problem description:

Players A and B agree on positive integer n first, and then a wants a positive integer x in his mind, where X is between 1 and N, and B guesses the number X in his mind by asking questions. B has only one format of question: first list some numbers and then ask "X" if they are in these numbers (of course, B can also ask: is X in a certain range ), B can ask questions multiple times. A can answer "yes" or "no ". A can lie occasionally, but a cannot lie twice in a row. Q: Can B obtain the number in a's mind through inquiry, or provide a set to ensure that the number X in A's mind falls within the subinterval? If yes, give a policy; if not, describe the reason.

Answer:

At first glance, this problem is really tricky. I don't know where to start. In the next case, it is a good choice to first solve simple special cases and then gradually draw a general conclusion. Therefore, we can consider the simplest case. Suppose n = 2, then the number a thinks is either 1 or 2. What should we do in this case?

Since a cannot lie consecutively, if a asks the same question twice consecutively and gives the same answer twice, we can guess the answer. For example, if B asks "x = 2?" twice in a row ?", If a gives the answer "yes", a must tell the truth twice, so x = 2. If a answers "no", then the two "no" statements are true, therefore, it is concluded that X is not equal to 2, x = 1.

However, a cannot give an answer. B asks two consecutive questions. "X = 2? ", A answers" whether ". We can only determine whether a fake talk is made once. We cannot determine which fake talk is made, so we cannot obtain any useful information. On this basis, if you ask "x = 1 ?", A can give an answer based on whether the last time the truth was told or false. If the last time the truth was said, you only need to ensure that the truth is true, but we do not know whether he is telling the truth, therefore, useful information is still not available. If you tell the truth last time, you can answer the truth in this case. If you continue to ask, "x = 1? ", A said" yes "last time. This time it said" no ", the last time it said" no ", this time it said" yes ", we don't know when he is lying in any way. Therefore, if there are only two values, B cannot guess X by asking questions.

The above process can be seen from the following simple example, assuming x = 2.

(1) "x = 2? "" Is "" X = 2? "" No "" X = 2? "" Is "... (Alternate answers )...." X = 1? "" Yes/No "(tell the truth last time, this time casually)" x = 1? "" No/yes"

(2) "x = 2? "" No "" X = 2? "" Is "" X = 2? "" No "... (Alternate answers )..." X = 1? "" No "(the last time it was said false, this time it must be said true)" x = 1? "" Is"

Because 1 and 2 are called, if I continue to ask "x = 2? ", You only need to switch the policy of answering 1 and 2 in (1) (2) above.

I'm a split line ---------------------------------------------------------------------

N = 2 cannot be determined, so what will happen if n = 3? A can only think of a certain number in 123. Similarly, since a cannot lie twice in a row, we can repeatedly ask a question for more than two times. If a's answer is the same, it is necessary to obtain information.

For example, "x = 3? ", A's answer method can only be" yes "" no "or" no.

(1) If a answers "yes" and immediately determines that both are true, x = 3.

(2) If a answers "No no", it is immediately concluded that both are true, so X is not equal to 3, and 3 can be ruled out.

(3) If a answers "no", continue to ask "x = 2 ?" A can only answer "yes/no", which is discussed in detail: (3A) If a answers "yes ". That is, "x = 3 ?" "Yes" "X = 2 ?" "Yes ". Because there is at least one truth in the two, and neither can be true (x cannot be equal to 2 or 3), there must be one truth and one false. In this way, we can conclude that X is equal to 2 or 3, so we can exclude 1. (3B) If a answers "no", that is, "x = 3 ?" "Yes" "X = 2 ?" "No ". At this time, if X = 2, it can be concluded that both of them are false. Therefore, we can conclude that X is not equal to 2, that is, we can exclude 2.

(4) If a answers "yes", continue to ask "x = 3 ?", If the answer is "no", it will be handled by situation (2). If the answer is "yes", it will be handled by situation (3.

Therefore, through the above question strategy, we can always exclude one of the numbers. In most cases, we cannot obtain more information, except for the case (1.

I'm a split line -------------------------------------------------------------------------

Now let's start to consider the original question. What if n is large? We can divide N into three equal points (not necessarily equal, as far as possible). In this way, we can replace 123 in the above policy with set 123, for example, "is X in the third set? ", In this way, we can eliminate all the numbers of 1/3 every time until the remaining two numbers are finally attributed to the first small problem, and it is impossible to get a definite number.

The discussion has ended, but some people have said that matrix67 has already discussed this issue and there are more general conclusions. If you are interested, click here.

 

<Note>BloggerPython27This blogArticleCopyright. For more information, see the source,You have any suggestions for solving the problem. Please feel free to comment on them.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.