From 922d81265287e95128a75a8a9ff000d222683fd6 Mon Sep 17 00:00:00 2001 From: Kunal Mehta <55488271+KunalMehta205@users.noreply.github.com> Date: Wed, 12 Oct 2022 23:10:51 +0530 Subject: [PATCH 1/3] Update question1.py --- Python-Developer/question1.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Python-Developer/question1.py b/Python-Developer/question1.py index e44cbb8..f057920 100644 --- a/Python-Developer/question1.py +++ b/Python-Developer/question1.py @@ -1,7 +1,12 @@ def select_max(array): # write your function here # do NOT use the built-in max() function - pass + max_value = array[0] + + for i in array: + if i>max_value: + max_value = i + return max_value if __name__ == "__main__": From 724d691059e490dd7fb9126454d03bbdbe04c0f4 Mon Sep 17 00:00:00 2001 From: Kunal Mehta <55488271+KunalMehta205@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:50:51 +0530 Subject: [PATCH 2/3] Update question_3.py --- Python-Developer/question_3.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Python-Developer/question_3.py b/Python-Developer/question_3.py index 8f41597..7057464 100644 --- a/Python-Developer/question_3.py +++ b/Python-Developer/question_3.py @@ -1,6 +1,20 @@ +def minRecursive(threshold, points): + if len(points)==1: + return 0 + if len(points)==2: + return 1 + if len(points)>=3: + return minRecursive(threshold-points[0], points[2:len(points)]) + 1 + def minimum_points(threshold, points): # write your code here - pass + if len(points) <=0: + return 0 + #since array is sorted, we check the difference between the max and min points and compare with the threshold, if less perform all the problems + if points[len(points)-1] - points[0] < threshold: + return len(points) + else: + return minRecursive(threshold, points) +1 if __name__ == "__main__": From 15654ce9dfe061daaffc6da2833b4e556ad44e40 Mon Sep 17 00:00:00 2001 From: Kunal Mehta <55488271+KunalMehta205@users.noreply.github.com> Date: Thu, 13 Oct 2022 01:46:29 +0530 Subject: [PATCH 3/3] Update question2.py --- Python-Developer/question2.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Python-Developer/question2.py b/Python-Developer/question2.py index c084ca5..edbe990 100644 --- a/Python-Developer/question2.py +++ b/Python-Developer/question2.py @@ -5,9 +5,27 @@ def center_zeros(array): # write your function here # center means the floor(x / 2) where floor means rounding a float (decimal number) down to the nearest integer # i.e. floor(1) = 1, floor(1.5) = 1, floor(1.75) = 1, floor(2) = 2 - pass + count_zero = 0 + for i in array: + if i==0: + count_zero+=1 + + mid = floor(int(len(array)/2)) + li= [] + + for i in range(0,(mid-count_zero)+1): + if array[i]!=0: + li.append(array[i]) + + for i in range(count_zero): + li.append(0) + + for i in range(mid-1,len(array)): + if array[i]!=0: + li.append(array[i]) + return li if __name__ == "__main__": # write your debug code here - pass \ No newline at end of file + pass