Write a Python program that solves the Towers of Hanoi puzzle. Your program should ask the user for the number of disks to be moved then it should list the moves that need to be done for a complete solution. Here is output from a sample run. How many pegs do you want to start with? --> 4 Move a disk from peg e to peg 1. Move a disk from peg e to peg 2. Move a disk from peg 1 to peg 2. Move a disk from peg e to peg 1. Move a disk from peg 2 to peg e. Move a disk from peg 2 to peg 1. Move a disk from peg e to peg 1. Move a disk from peg 0 to peg 2. Move a disk from peg 1 to peg 2. Move a disk from peg 1 to peg e. Move a disk from peg 2 to peg e. Move a disk from peg 1 to peg 2. Move a disk from peg e to peg 1. Move a disk from peg e to peg 2. Move a disk from peg 1 to peg 2. Your program must conform to the following specifications! 1) Represent the three pegs and disks as a three element list called board, where boardſij is the number of disks currently on peg i. Thus, the initial position would have board = [n, 0, 0]. 2) Have a function named move that is passed the board, the index of the peg a disk is to be moved from, and the index of the peg the disk is to be moved to then transfers the top disk betweem the given pegs and prints the move. 3) Have a function named getOther that is passed the indices of two pegs and returns the index of the other peg
Write a Python program that solves the Towers of Hanoi puzzle. Your program should ask the user for the number of disks to be moved then it should list the moves that need to be done for a complete solution. Here is output from a sample run. How many pegs do you want to start with? --> 4 Move a disk from peg e to peg 1. Move a disk from peg e to peg 2. Move a disk from peg 1 to peg 2. Move a disk from peg e to peg 1. Move a disk from peg 2 to peg e. Move a disk from peg 2 to peg 1. Move a disk from peg e to peg 1. Move a disk from peg 0 to peg 2. Move a disk from peg 1 to peg 2. Move a disk from peg 1 to peg e. Move a disk from peg 2 to peg e. Move a disk from peg 1 to peg 2. Move a disk from peg e to peg 1. Move a disk from peg e to peg 2. Move a disk from peg 1 to peg 2. Your program must conform to the following specifications! 1) Represent the three pegs and disks as a three element list called board, where boardſij is the number of disks currently on peg i. Thus, the initial position would have board = [n, 0, 0]. 2) Have a function named move that is passed the board, the index of the peg a disk is to be moved from, and the index of the peg the disk is to be moved to then transfers the top disk betweem the given pegs and prints the move. 3) Have a function named getOther that is passed the indices of two pegs and returns the index of the other peg
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY