Jadu07 / CodeFlex

Write Code for the Issues from Issues Tab and Push the Code.
MIT License
1 stars 11 forks source link

Implement a Recursive Function for Tower of Hanoi #10

Closed Jadu07 closed 1 week ago

Jadu07 commented 1 week ago

Issue Title: Write a recursive function to solve the Tower of Hanoi problem

Description: The Tower of Hanoi is a mathematical puzzle where you have three rods and n disks of different sizes. The goal is to move all the disks from the first rod to the third rod while obeying the following rules:

Only one disk can be moved at a time. A disk can only be placed on top of a larger disk. Implement a recursive function to solve the Tower of Hanoi problem.

tower_of_hanoi(3, 'A', 'C', 'B')

Output:

Move disk 1 from A to C

Move disk 2 from A to B

Move disk 1 from C to B

Move disk 3 from A to C

Move disk 1 from B to A

Move disk 2 from B to C

Move disk 1 from A to C

shaswat-satyam commented 1 week ago

Can you assign this issue to me?