Algorithm series (16) using the exhaustive method to solve the result of guessing game

Source: Internet
Author: User

First, the introduction

Poverty is a common idea to solve the problem, when the problem can not be solved, you may consider in the scope of the problem to be allowed to the extent that all possible results, and then according to the correct results of the rule of judgment to verify the results, to find the correct results. The solution of solving the problem by using the exhaustive method is more suitable for computer for this kind of physical life they have no complaints, this article on the common two guessing the results of the topic as an example, introduce how to solve such problems through computer programs, by the way introduce the common algorithm structure and the implementation of the method.

Second, guessing the results of the game analysis process

First look at a problem, there are five athletes (a, B, C, D, E to participate in the games, respectively, 100 meters, 200 meters, high jump, long jump and shot put champion, now there are four other people (A, B, C, D) The results of the competition are described, respectively:

A said: "B won the shot put champion, Ding won the high jump champion"

B said: "A won the 100-meter champion, E won the long jump champion"

C said: "To win the long jump champion, Ding won the 200-meter champion"

D said: "B won the high jump champion, E won the shot put champion"

A, B, C and D four each person's description of a sentence, wrong, now according to the description of these four people to guess what five athletes each won the title of what project?

Now to analyze this problem, five athletes won 5 titles, the correct results need 5 description, now the topic gives four people 8 description, some of them are contradictory error description, so need to the correctness of these descriptions to assume that the process is in fact a poor-lifting process. Each person has two descriptions, the correctness of which is assumed to be two hypothetical results, four people have 24 = 16 of the combination of hypothetical results, the following table is the full description of these 16 hypothetical result combinations:

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.