6-4 tower Problems

Source: Internet
Author: User

Move all plates from Stakes 1 to stakes 3. The rules are as follows:

1. Only one plate can be moved at a time, and only one plate can be moved from the top.

2. Any plate can be moved to any wooden pile.

3. The plate size must increase sequentially from top to bottom.

Solution:
Mathematical induction, that is, the disk operation process when plate n = 1, n = 2, n = 3.

You can sum up a mathematical formula or a general handling process.

Using mathematical formulas, you can obtain the number of times. This is the number of handling times compared to the honest migration. Is a shortcut. The final result is that there is a lack of the yugong mountain migration process.

Therefore, the general handling process can display the specific handling process and obtain the results from the process. This is the difference between algorithms, that is, computer science and mathematics.

General handling process:

Step 1 move n-1-1 plates above from stake 1 to stake 2.

Step2. move the plate from stake 1 to stake 3.

Step 3 move n-1 plates of stake 2 to stake 3.
 

Is there a way to stuff an elephant in the refrigerator?

Is the Code a bit confusing?

Line 1 is the first step, that is, moving the n-1 plates above from the pile 1 to the pile 2.

Hanoi (dishs-1,Peg1, Peg3,Peg2);/* Step 1 */

Row 3 is the third step, that is, moving n-1 plates of pile 2 to the pile 3.

Hanoi (dishs-1,Peg2, Peg1,Peg3);/* Step 3 */

Is it easier to remember the code without understanding the code?

If the Quanta problem mutates:
 

If there are n plates and n columns, find the minimum number of moves, the maximum number of moves, and specify the number of moves. Can you write?

Yes. Starting from the essence of the tower. The essence of the tower is a process: calculate the number of moves of the Fixed Disk and fixed column, and export the number of moves of N plates and fixed columns from it, export the number of moves of n columns and fixed plates from them. Then, we can export the number of moves of N plates and n columns. As for the moving process of the specified number of moves, it is a bit of a bitter taste.

As we can see, the essence of the tower is somewhat macro mathematical induction.

The above is purely a nonsense. Just entertain me.
 

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.