From d942af887abc5b4ecce324dfac1808e663a1700c Mon Sep 17 00:00:00 2001 From: Usdhhaarvma <114903242+Usdhhaarvma@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:46:33 +0530 Subject: [PATCH] Create Tower of Hanoi solution --- C/Tower of Hanoi solution | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 C/Tower of Hanoi solution diff --git a/C/Tower of Hanoi solution b/C/Tower of Hanoi solution new file mode 100644 index 0000000..7b4317c --- /dev/null +++ b/C/Tower of Hanoi solution @@ -0,0 +1,10 @@ +def TowerOfHanoi(n , source, destination, auxiliary): + if n==1: + print ("Move disk 1 from source",source,"to destination",destination) + return + TowerOfHanoi(n-1, source, auxiliary, destination) + print ("Move disk",n,"from source",source,"to destination",destination) + TowerOfHanoi(n-1, auxiliary, destination, source) + +n = 4 +TowerOfHanoi(n,'A','B','C')