Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8164667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:22:06+00:00 2026-06-06T19:22:06+00:00

Given D discs, P poles, and the initial starting positions for the disks, and

  • 0

Given D discs, P poles, and the initial starting positions for the disks, and the required final destination for the poles, how can we write a generic solution to the problem?

For example,

Given D=6 and P=4, and the initial starting position looks like this:

5     1
6 2 4 3

Where the number represents the disk’s radius, the poles are numbered 1-4 left-right, and we want to stack all the disks on pole 1.

How do we choose the next move?

The solution is (worked out by hand):

3 1
4 3
4 1
2 1
3 1

(format: <from-pole> <to-pole>)

The first move is obvious, move the “4” on top of the “5” because that its required position in the final solution.

Next, we probably want to move the next largest number, which would be the “3”. But first we have to unbury it, which means we should move the “1” next. But how do we decide where to place it?

That’s as far as I’ve gotten. I could write a recursive algorithm that tries all possible places, but I’m not sure if that’s optimal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:22:07+00:00Added an answer on June 6, 2026 at 7:22 pm

    We can’t.

    More precisely, as http://en.wikipedia.org/wiki/Tower_of_Hanoi#Four_pegs_and_beyond says, for 4+ pegs, proving what the optimal solution is is an open problem. There is a known very good algorithm, that is widely believed to be optimal, for the simple case where the pile of disks is on one peg and you want to transfer the whole pile to another. However we do not have an algorithm, or even a known heuristic, for an arbitrary starting position.

    If we did have a proposed algorithm, then the open problem would presumably be much easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following string: s = 'abcdefg*' How can I match it or any
Given that Solid State Disks (SSDs) are decreasing in price and soon will become
can any expert help me out to solve a problem of burning a dvd
The Towers of Hanoi problem is a classic problem for recursion. You are given
Given that the web application doesn't have su privileges, I'd like to execute a
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
Given an NSMutableArray of dynamic CGPoint s, what is the fastest and most efficient
Given a certain date, I want to set the value of a cell with
given a Python class hierarchy, say class Base: def method1 def method2 def method3
Given a MySQL table of real estate data, I would like to generate a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.