From c44bbd0b01fa98106b4a101fef05167160cc9e5a Mon Sep 17 00:00:00 2001 From: tushar ulhare Date: Wed, 23 Oct 2019 13:12:29 +0530 Subject: [PATCH 1/2] create String length programm --- StringLenght | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 StringLenght 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)) From bc155e192256f8ca3ddf526c62e60aa7087704cf Mon Sep 17 00:00:00 2001 From: tushar ulhare Date: Thu, 24 Oct 2019 11:16:07 +0530 Subject: [PATCH 2/2] Create TowerogHanoi.py Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: 1) Only one disk can be moved at a time. 2) Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack. 3) No disk may be placed on top of a smaller disk. --- TowerofHanoi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 TowerofHanoi.py 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\')