Your program must conform to the following specifications! 1) Represent the three pegs and disks as a three element list called board_, where_board_[ i 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. 4) And most importantly, a function named solveTOH that is passed the board, the number of pegs, the from peg, and the to peg which performs the recursion and calls move. 5) Your main program shoudl prompt the user for the number of disks, set up the board, and call solveTOH. Here are some function headers to get you started.
Your program must conform to the following specifications! 1) Represent the three pegs and disks as a three element list called board_, where_board_[ i 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. 4) And most importantly, a function named solveTOH that is passed the board, the number of pegs, the from peg, and the to peg which performs the recursion and calls move. 5) Your main program shoudl prompt the user for the number of disks, set up the board, and call solveTOH. Here are some function headers to get you started.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
Step 1
Step by step
Solved in 2 steps with 3 images
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education