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

  • Home
  • SEARCH
  • 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 8800507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:36:23+00:00 2026-06-14T00:36:23+00:00

My task is to write some code that finds the shortest sequence of moves

  • 0

My task is to write some code that finds the shortest sequence of moves that takes a given starting stack to a given goal stack. I am given an original list of books, portraying how the stack starts out, and a goal list of books, showing the goal order I need them in. The problem lies in that standard sorting algorithms won’t work, as the ordering of the books is based off of a person’s preference, not of any particular logic.

The system that the question wants you to use is as follows: pull a book out from anywhere in the stack, one at a time, and put it on top of the stack. So if you had books X, Y and Z, you could choose to pull out Y, making the order Y, X, Z.

Initial:

'1984 - George Orwell'
'Moby Dick - Herman Melville'
'To Kill A Mockingbird - Harper Lee'
'Atlas Shrugged - Ayn Rand'
'The Black Cat - Edgar Allen Poe'

Goal:

'Atlas Shrugged - Ayn Rand'
'To Kill A Mockingbird - Harper Lee'
'1984 - George Orwell'
'Moby Dick - Herman Melville'
'The Black Cat - Edgar Allen Poe' 

This is homework. However, I am not looking for people to do it for me, as that would defeat the purpose of the assignment. I’m just looking for some ideas or tips to get started, as I don’t know where to begin.

Note: I was going to tag this as homework however the tag explicitly says not to, so I haven’t. If this is wrong, please correct me.

  • 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-14T00:36:24+00:00Added an answer on June 14, 2026 at 12:36 am

    Ok, the main problem is that you can only put onto the top, but you can choose any book. You wanted hints, not the method, so here are some:

    1. As you can only put on top always start looking at the bottom as its hardest do reach
    2. You obviously never need to pull any book already in the right place
    3. You need to pull all books which now are under a book that is above the book in the correct order
    4. If you stack books onto the top you should put them there in the correct order
    5. To transform A B G F C E D to alphabetical order you would optimally pull E, then F, then G if you always attach to the end.

    I hope this got you started and I have not been to explicit.

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

Sidebar

Related Questions

I have been assigned wit the task to write a program that takes a
I need to write some code that deals with generating and manipulating multivariable polynomials.
I have inherited some code which involves a scheduled task that writes data (obtained
I'm starting to write some code using C++ and I have this simple class
I wrote a Python script that does some task to generate, and then keep
I wrote a window service that performs some task using the threads.Now i am
I'm trying to write some code to automatically configure a bunch of scheduled tasks
I need to write some code to stress-test RS232 communication using rxtx ( note
I am writing a simple python code for a very task which some of
I wrote some code at SQL Server Integration Services Script Task. And I used

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.