Fun mathematics-Chicken rabbit cage Algorithm

Source: Internet
Author: User


In fact, many people have considered such a similar question:

The chickens and rabbits are in the same cage, with 15 heads and 40 feet. How many chickens and rabbits are there?

When I was in elementary school, some children would count like this. If there was one chicken, there would be 14 rabbits, and there would be 58 legs, so there are 13 rabbits and 56 legs ...... And so on until there are 10 chickens, 5 rabbits, and 40 legs. This is a stupid way. From a chicken to a chicken, it should be counted at least 10 times. If a child is lucky, from a rabbit to a rabbit, five times to find the answer.

This is the most stupid way.AlgorithmIt is only suitable for calculation of small numbers. If there are hundreds of chickens and rabbits, it is necessary to exhaust the children.

In middle school, students who have learned algebra will surely think of first column of equations and immediately write down on paper:

  1. Set chicken to X and rabbit to y.
  2. X + y = 15
  3. 2x + 4y = 40
  4. Y = 15-x
  5. 2x + 4 * (15-x) = 40
  6. 2x + 60-4x = 40
  7. 60-2x = 40
  8. 2x = 20
  9. X = 10
  10. Y = 5
  11. Returns x = 10, y = 5.

This is the thinking of ordinary people. Even if the solution is based on a binary equation, it takes about 10 steps. On the surface, it is not easy, but it can basically solve all similar problems.

There are also tips for solving equations. There is a quick solution on the Internet:

  1. X + y = 15 ....... (1)
  2. 2x + 4y = 40 ....... (2)
  3. Take the multiplication of two sides of (1) as follows: 2x + 2y = 30 ....... (3)
  4. Then (2)-(3) Get: 2y = 10 that is, y = 5
  5. So X + 5 = 15 --> X = 10

This method can save several steps.

Today, I saw a very interesting solution on the Internet. It was so funny and efficient.
Algorithm:

    1. Assuming that chickens and rabbits are well trained
    2. Blow a whistle and they raise one foot (40-15 = 25)
    3. Blow another whistle and they raise one more foot (25-15 = 10)
    4. At this moment, the chicken is sitting on the ground, and the rabbit is still standing with two feet.
    5. Therefore, rabbits have 10/2 = 5, and chickens have 15-5 = 10.

This is an efficient algorithm!

Seeing this question reminds me of my childhood fun. In a few years, I can use this interesting mathematical question to test my daughter. Haha! No, this year I will be able to test my nephew and niece who are studying at home.

If the post-80 online users are free in the future, they will really collect some interesting knowledge to show off to the next generation, so as to cultivate their interest in learning.

 

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.