Question: ower of Hanoi: ( 1 0 Points ) Program the Tower of Hanoi puzzle. You must use a , b , c as your peg

ower of Hanoi: (10 Points)
Program the Tower of Hanoi puzzle. You must use a, b, c as your peg names. Your output should
be a bunch of move statements like move a to b(which means moving the top disk from peg a
to peg b). You can use Prolog's write predicate to output a string or a variable to the screen. The
nl predicate outputs a newline to screen.
Note: The goal predicate will take the form:
hanoi(X, a, c, b).
where X is a variable (the number of discs)
Sample Run:
?- hanoi(3,a,c,b).
Move a to c.
Move a to b.
Move c to b.
Move a to c.
Move b to a.
Move b to c.
Move a to c.
File Name: hanoi.pl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!