Posted on:

09 Sept 2023

1

Else Commands Understanding

 else:
        
        towers_of_hanoi(A,C,B,n-1)

        towers_of_hanoi(A,B,C,1)

        towers_of_hanoi(B,A,C,n-1)

What are these commands doing? I do understand how tower of hanoi works on paper. But I am not understanding this syntax. I need thoery of these recusion commands. like what will  towers_of_hanoi(A,C,B,n-1) do???. It will remove items from list A to C??? as per:
if n == 1:
        disk = A.pop()
        C.append(disk)
        count +=1  

Moreover, How will items from A move to B?? We havent written any code for that????   

0 answers ( 0 marked as helpful)

Submit an answer