Create an algortihm using python.
• Move each bar from tower A to tower C. You can only move one bar at a time. You are not allowed to place the larger disk onto a smaller disk.
LINK PHOTO:
https://www.google.com/search?q=tower+of+hanoi+image&source=lnms&tbm=isch&sa=X&ved=2ahUKEwi6veGsgMPwAhVVFogKHVD6D2IQ_AUoAXoECAEQAw&biw=1366&bih=657#imgrc=W_DnmKgBwq_XxM
tower(disk, A, B, C)
IF disk is equal 1, THEN
move disk from A to C
ELSE
tower(disk - 1, A, C, B)
move disk from A to C
tower(disk - 1, B, A, C)
END IF
END
Comments
Leave a comment