diff --git a/StringLenght b/StringLenght new file mode 100644 index 0000000..5a87d0a --- /dev/null +++ b/StringLenght @@ -0,0 +1,14 @@ + +test_list = [ 1, 4, 5, 7, 8 ] + +print ("The list is : " + str(test_list)) + + +counter = 0 +for i in test_list: + + + counter = counter + 1 + + +print ("Length of list using naive method is : " + str(counter)) diff --git a/TowerofHanoi.py b/TowerofHanoi.py new file mode 100644 index 0000000..f4c3335 --- /dev/null +++ b/TowerofHanoi.py @@ -0,0 +1,16 @@ +filter_none +edit +play_arrow + +brightness_5 + +def TowerOfHanoi(n , from_rod, to_rod, aux_rod): + if n == 1: + print "Move disk 1 from rod",from_rod,"to rod",to_rod + return + TowerOfHanoi(n-1, from_rod, aux_rod, to_rod) + print "Move disk",n,"from rod",from_rod,"to rod",to_rod + TowerOfHanoi(n-1, aux_rod, to_rod, from_rod) + +n = 4 +TowerOfHanoi(n, \'A\', \'C\', \'B\')