File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ This repository contains examples of various algorithms written on different pro
22
22
| [ Merge Sort] ( https://en.wikipedia.org/wiki/Merge_sort ) | [ :octocat:] ( merge_sort/clang ) | [ :octocat:] ( merge_sort/cpp ) | [ :octocat:] ( merge_sort/java ) | [ :octocat:] ( merge_sort/Python ) | |
23
23
| [ Insertion Sort] ( https://en.wikipedia.org/wiki/Insertion_sort ) | | [ :octocat:] ( insertion_sort/Cpp ) | [ :octocat:] ( insertion_sort/java ) | | [ :octocat:] ( insertion_sort/javascript ) |
24
24
| [ Counting Sort] ( https://en.wikipedia.org/wiki/Counting_sort ) | [ :octocat:] ( counting_sort/clang ) | [ :octocat:] ( counting_sort/cpp ) | [ :octocat:] ( counting_sort/java ) | [ :octocat:] ( counting_sort/Python ) | |
25
+ | [ Tower of Hanoi] ( https://en.wikipedia.org/wiki/Tower_of_Hanoi ) | [ :octocat:] ( towers_of_hanoi/clang ) | | | [ :octocat:] ( towers_of_hanoi/Python ) | |
25
26
26
27
## Implemented Data Structures
27
28
Original file line number Diff line number Diff line change
1
+ def towerOfHanoi (numberOfDisks , fromRod , toRod , auxRod ):
2
+ if numberOfDisks == 1 :
3
+ print ("Move {} from {} to {}" .format (numberOfDisks ,fromRod ,toRod ))
4
+ return
5
+ towerOfHanoi (numberOfDisks - 1 ,fromRod ,auxRod ,toRod )
6
+ print ("Move {} from {} to {}" .format (numberOfDisks ,fromRod ,toRod ))
7
+ towerOfHanoi (numberOfDisks - 1 ,auxRod ,toRod ,fromRod )
8
+
9
+ if __name__ == "__main__" :
10
+ n = int (input ("Enter number of disks: " ))
11
+ towerOfHanoi (n ,'A' ,'C' ,'B' )
You can’t perform that action at this time.
0 commit comments