Interview Questions: Can I use a program to answer the instructor's birthday analysis process?

Source: Internet
Author: User

Question:
Mr. Zhang and Mr. Xiaoqiang are both students of Mr. Zhang. Their birthdate is m month N. Both of them know that Miss Zhang's birthdate is one of the following 10 groups. Mr. Zhang told James about M, mr. Zhang told Xiaoqiang about the N value and asked them what day he had on his birthday.

March 4 March 5
June 4
September 1
December 1 December 2

James said: If I don't know, I'm sure I don't know either.
Xiaoqiang said: I didn't know either, but now I know.
James said: Oh, I know.

 

Based on the above conversation, determine the day of Miss Zhang's birthday. Please tell us which day is the answer. The following is my analysis and deduction process.

Analysis: At first glance, I don't know where to start. The condition is a three-sentence dialogue. What should we do if we encounter such a problem? First, don't worry, and then analyze it with one condition and one condition.
1. James said: If I don't know, I certainly don't know.
With this condition, we can see if a month can be ruled out, because James knows the month. If James gets 3 months, Xiao Qiang has three options: 3.4, 3.5 or 3.8. Let's look at the day part of the three dates, which are repeated in and 8. It means that James's conditions are met (if I don't know, xiaoqiang certainly does not know); similarly, looking at the month, there are two dates on the 4 and 7, and there is only one day for all dates in China and Japan, this indicates that July does not meet James's conditions and can be ruled out. The two dates of July are also duplicated, indicating that July may be used, there are no duplicates in December 2, which means that December can also be ruled out. 2. Xiaoqiang said: I didn't know, but now I know.
I didn't know Xiao Qiang, but now I know it. Through our analysis above, James's conditions can be ruled out in July and July, we will push the push in the remaining March and September dates. March 4 March 5
The dates of January 1, include:, and, and there are two of the dates of May 5. Therefore, we can exclude the dates of January 1, and, because if Xiaoqiang knew the number is 5, he could not know whether it was March 5 or September 5. 3. James said: Oh, then I know.
The remaining date is: January 1, March 4, March 8
But now James said that he knew it. It means that his condition month must be 9. If it is 3, he cannot determine whether it is 4 or 8, so the last answer is September 1.

You have not answered correctly.

Postscript:
Can I use a computer to create a mathematical model for such a question? How? This essay is intended to give you an example.ProgramThe solution is different.

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.