diff --git a/Contributor.md b/Contributor.md index d066caf..710d322 100644 --- a/Contributor.md +++ b/Contributor.md @@ -6,3 +6,4 @@ - [VishnuThokala](https://github.com/VishnuThokala) - [Shaurya026](https://github.com/Shaurya026) - [Jeevesh-Joshi](https://github.com/Jeevesh-Joshi) +- [harishtaa](https://github.com/harishtaa) \ No newline at end of file diff --git a/TowerOfHanoi.py b/TowerOfHanoi.py new file mode 100644 index 0000000..e3f76e4 --- /dev/null +++ b/TowerOfHanoi.py @@ -0,0 +1,12 @@ +def TowerOfHanoi(Disks, source, temp, destination): + if(Disks == 1): + print("Move Disk 1 From {} to {}".format(source, destination)) + return + TowerOfHanoi(Disks - 1, source, destination, temp) + print("Move Disk {} From {} to {}".format(Disks, source, destination)) + TowerOfHanoi(Disks - 1, temp, source, destination) + +Disks = int(input("Enter Number of Disks: ")) + +# Source : A, Intermediate : B, Destination : C +TowerOfHanoi(Disks, 'A', 'B', 'C') \ No newline at end of file