Java abstraction-Teachers' birthday-logical thinking-Interesting interview questions-, java Abstraction
(-1) Written inFront
I 've been to Beijing and arranged for a java test. I forgot some special details, and I have never thought of any bad things, however, connections are not often disconnected at ordinary times, but it is useless to memorize them. After a while, you will still forget that the only way is to do more things and link theory with practice, on the contrary, I felt very interesting about this question. I also saw a lot of explanations on the Internet and thought it was all lacking. below is my answer.
(0) detailed explanation
Set a teacher's birthday to M month N. tell student a (student a knows the month when the teacher was born) and student B (Student B knows the day when the teacher was born ). the following dates are available :,
One of them is the teacher's birthday.
Current conversations between student A and Student B:
Student A: If I don't know, you certainly don't know.
Student B: I don't know. Now I know.
Student A: Now I know.
Q: What is the teacher's birthday?
First sentence of
First, let's look at the features of the data. The data is composed of months and dates. A knows the month, and the data contains the months, A cannot determine the teacher's birthday Based on the month information he knows. A knows that B cannot predict the correct month through the date.
What a knows is that there are 4, 8, and 10 dates in March.
What a knows is that there are June days
What a knows is that there are days in
What a knows is that the July date is
We found that day 7 and day 2 were the only ones, which means that if Party A knew June, then Party B knew the day 7, and then assumed the birth day, A won't say you don't know, so what a knows is not June. Similarly, what a knows is not December.
The first sentence of B
According to the first sentence of A, the remaining data is as follows:
What a knows is that there are 4, 8, and 10 dates in March.
What a knows is that there are days in
The first half of Party B's sentence is ambiguous. In the first case, Party B believes that Party A can launch its birthday through the month, so the date of Party B is 2 or 7, which is inconsistent with the conclusion drawn in the first sentence of Party. This is the second case. At this time, Party B inferred the above conclusion from Party A's words and determined the month of Party A based on his own date. Obviously, 10 is incorrect. If it is 10, the month of A is not unique. The data is as follows:
What a knows is that there are March days
What a knows is that there is 1 in December September.
In this case, it seems that, and are all possible, because B knows that any corresponding month in, 8 is unique.
A's second sentence
This sentence pushed the answer to September 1, because for Jia, if he knew March, the teacher's birthday would be March 4 or March 8, if he knew the year September, only the year September 1 was the answer.