subject

This assignment is an extra credit assignment, optional. You can use the Standard Library Template's functions and data types for implementing the Stacks.

You will need to implement 3 stacks: A, B, C

Each disc is represented by a number and a string of x's

1. Smallest disc is represented by the number 1 and one x centered in a field of 7 (3 blanks, 1 x, 3 blanks)

2. Middle disc is represented by the number 3 and three x's centered in a field of 7 (2 blanks, 3 x's, 2 blanks)

3. Largest disc is represented by the numbe4 5 and 5 x's centered in a field of 7 (1 blank, 5 x's and 1 blank)

Give instructions. Ask player to enter letter of source and destination stack. Remove the top from source stack and place it on the destination stack, display the 3 stacks on console. Repeat until all disks are on stack C. Don’t move if player breaks rule 3 -- display “Can’t Cheat!”. Detect when player wins, display “Won in” # “moves”. If player won in minimal # of moves, display “Can’t do better than that!”Starting the game the puzzle starts with printing this.

Display the towers A, B, C with their content at the end of each move:

1 x
3 xxx
5
A B C
What is your move? (give first the source stack (A, B, or C) and the Destination Stack, separated by 1 Space):

The answer is given in color graphically on the challenge problem page.
If player enters:
A C
You display the following

3 xxx
5 1 x
A B C

OR, you can print the following

3 xxx 1 x
5
A B C

For the next step, if the player asks to move A to B
A B
you sill print:

5 3 xxx 1 x
A B C

Make sure to take care of giving the appropriate feedback if they try to do an illegal move, and when they win, print the # of moves accomplished and if they did it in the minimal number of moves (See description of Challenge) and print "Can't do better than that!". Print out a tracing duplicating the minimal solution for 3 disks, with the appropriate messages and an example with an illegal move. The printout should have the discs (x's) centered above the peg variable. number of blanks between pegs can vary.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 22.06.2019 22:40
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
question
Computers and Technology, 23.06.2019 12:10
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
You know the right answer?
This assignment is an extra credit assignment, optional. You can use the Standard Library Template...
Questions
question
English, 24.12.2020 07:00
question
Mathematics, 24.12.2020 07:00
question
Mathematics, 24.12.2020 07:00
question
Mathematics, 24.12.2020 07:10
question
Mathematics, 24.12.2020 07:10
Questions on the website: 13722363