Open Eureka-Viraj opened 3 years ago
Tower of
My Approach : Take an example for 2 disks : Let rod 1 = 'A', rod 2 = 'B', rod 3 = 'C'.
Step 1 : Shift first disk from 'A' to 'B'. Step 2 : Shift second disk from 'A' to 'C'. Step 3 : Shift first disk from 'B' to 'C'.
The pattern here is : Shift 'n-1' disks from 'A' to 'B'. Shift last disk from 'A' to 'C'. Shift 'n-1' disks from 'B' to 'C'.
for better understanding look at this image
issue fixed #496
Thanks for opening this pull request! Please be sure that you have checked out our contributing guidelines.
Please star this repository to show your support. In the meantime I am reviewing your code.
Tower of
My Approach : Take an example for 2 disks : Let rod 1 = 'A', rod 2 = 'B', rod 3 = 'C'.
Step 1 : Shift first disk from 'A' to 'B'. Step 2 : Shift second disk from 'A' to 'C'. Step 3 : Shift first disk from 'B' to 'C'.
The pattern here is : Shift 'n-1' disks from 'A' to 'B'. Shift last disk from 'A' to 'C'. Shift 'n-1' disks from 'B' to 'C'.
for better understanding look at this image
issue fixed #496