From fc0238051fd9e282e27d0c0fb853673f7c5e8da4 Mon Sep 17 00:00:00 2001 From: Nihir Gupta <72348470+nihirgupta@users.noreply.github.com> Date: Fri, 30 Oct 2020 08:17:03 +0530 Subject: [PATCH] Create Towerofhanoi.py --- Towerofhanoi.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Towerofhanoi.py diff --git a/Towerofhanoi.py b/Towerofhanoi.py new file mode 100644 index 00000000..1bb6cd6c --- /dev/null +++ b/Towerofhanoi.py @@ -0,0 +1,10 @@ +def movetower(height, fromtower, totower, withtower): + if height == 1: + print(fromtower + '-->' + totower) + return True + print('Executing 1, height of tower: {}'.format(height)) + movetower(height-1, fromtower,withtower,totower) + print(fromtower + '-->' + totower) + print('Executing 2, height of tower: {}'.format(height)) + movetower(height-1, withtower, totower, fromtower) +print(movetower(3,'a','c','b'))