Who said algorithms cannot be funny? The funny "chicken, rabbit, and Cage" algorithm has been released.

Source: Internet
Author: User

The chicken and rabbit are in the same cage.AlgorithmDesign Issues. Many people use this question to explain the application of "circular statements" and "exhaustive methods.

Here, I turn to a super-powerful and super-funny "Chicken and rabbit cage" algorithm:

Original post address: http://www.lzhi.org/views/509008

[Algorithm description]

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

This is an efficient algorithm!

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.