From 2473032642c70b9c0a2b44879d1966b6483f65e3 Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Fri, 11 Jan 2019 16:53:08 +0530 Subject: [PATCH 01/10] initial commit --- ...e most occurence of an element in an array | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Find the most occurence of an element in an array diff --git a/Find the most occurence of an element in an array b/Find the most occurence of an element in an array new file mode 100644 index 0000000..e09f6da --- /dev/null +++ b/Find the most occurence of an element in an array @@ -0,0 +1,49 @@ +def count_the_digits(a): #To Count the no of digits + counti = 0 + while(a[counti:]): + counti += 1 + return counti + +def built_dictionary(array): # To Built a dictionary + d = {} #creating a empty dictionary + count = 0 + for i in array: + count = 1 + if i in d: + d[i] = d[i] + 1 + else: + d[i] = count + #print (d) + return d + +def find_largest_value(values): # To find the max of dictionary values + values_count = count_the_digits(values) + one = values[0] + two = values[1] + if (one > two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +def find_key_from_dictionary(dictionary,max_element): # To find key from the value in an dictionary + for k,v in dictionary.items(): + if (v == max_element): + key = k + return key + +def finding_most_occureence_of_an_element(array): # the main function + dictionary = built_dictionary(array) + values = list(dictionary.values()) # converting the dictonary value to a list + max_element = find_largest_value(values) + key = find_key_from_dictionary(dictionary,max_element) + print ("the number {0} appears {1} times".format(max_element,key)) + +array = [1,2,5,3,2,4,5,5,5] +finding_most_occurence_of_an_element(array) + From cdb0342ef21ce525ea3ff2702a487ab54f0f683a Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Fri, 11 Jan 2019 17:04:49 +0530 Subject: [PATCH 02/10] Solution for Problem 2 --- Check whether the given element is present or not | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Check whether the given element is present or not diff --git a/Check whether the given element is present or not b/Check whether the given element is present or not new file mode 100644 index 0000000..8fb0bad --- /dev/null +++ b/Check whether the given element is present or not @@ -0,0 +1,12 @@ +#to find the element whether it is present or not +def find_element(array,search_element): + for i in array: + flag = False + if (i==search_element): + flag = True + break + return flag + +array = [3,5,7,9,0,3] +search_element = 3 +print(find_element(array,search_element)) From 672dfb364b7259aa5ee3c2b1a2f391a8a8acaa5d Mon Sep 17 00:00:00 2001 From: Sureya Pragaash G Date: Sat, 12 Jan 2019 20:18:29 +0530 Subject: [PATCH 03/10] initial commit --- ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 333 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin 0 -> 516 bytes ...ind_min_element_in_an_array.cpython-37.pyc | Bin 0 -> 518 bytes ...stnumberoccurencesinanarray.cpython-37.pyc | Bin 0 -> 750 bytes ...ences_of_max_element.cpython-37-PYTEST.pyc | Bin 0 -> 167 bytes ...x_numbers_occurences.cpython-37-PYTEST.pyc | Bin 0 -> 1121 bytes .../find_min_element_in_an_array.py | 20 ++++++++ .../find_smallest_number_occurences.py | 20 ++++++++ .../test_min_numbers_occurences.py | 13 ++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 333 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin 0 -> 516 bytes ...stnumberoccurencesinanarray.cpython-37.pyc | Bin 0 -> 750 bytes ...ences_of_max_element.cpython-37-PYTEST.pyc | Bin 0 -> 167 bytes ...x_numbers_occurences.cpython-37-PYTEST.pyc | Bin 0 -> 1121 bytes .../find_largest_number_occurences.py | 20 ++++++++ .../find_max_element_in_an_array.py | 20 ++++++++ .../test_max_numbers_occurences.py | 13 ++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 340 bytes ..._array_elements_same_or_not.cpython-37.pyc | Bin 0 -> 691 bytes ...eck_two_array_values.cpython-37-PYTEST.pyc | Bin 0 -> 583 bytes ..._whether_two_array_elements_same_or_not.py | 28 ++++++++++++ .../test_check_two_array_values.py | 36 +++++++++++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 321 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin 0 -> 567 bytes .../test_find_max.cpython-37-PYTEST.pyc | Bin 0 -> 1089 bytes ..._element_in_an_array.cpython-37-PYTEST.pyc | Bin 0 -> 1200 bytes .../find_max_element_in_an_array.py | 20 ++++++++ find_max_element_in_a_array/test_find_max.py | 14 ++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 321 bytes ...find_mean_of_array_elements.cpython-37.pyc | Bin 0 -> 496 bytes .../find_sum_of_an_array.cpython-37.pyc | Bin 0 -> 489 bytes ...an_of_array_elements.cpython-37-PYTEST.pyc | Bin 0 -> 1110 bytes .../find_mean_of_array_elements.py | 13 ++++++ .../find_sum_of_an_array.py | 22 +++++++++ .../test_find_mean_of_array_elements.py | 13 ++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 321 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin 0 -> 567 bytes ...ind_min_element_in_an_array.cpython-37.pyc | Bin 0 -> 568 bytes .../test_find_max.cpython-37-PYTEST.pyc | Bin 0 -> 1089 bytes ..._element_in_an_array.cpython-37-PYTEST.pyc | Bin 0 -> 1200 bytes .../test_find_min.cpython-37-PYTEST.pyc | Bin 0 -> 1090 bytes .../find_min_element_in_an_array.py | 20 ++++++++ find_min_element_in_a_array/test_find_min.py | 13 ++++++ ...urence_of_an_element.cpython-37-PYTEST.pyc | Bin 0 -> 530 bytes .../find_most_occurence_of_an_element.py | 43 ++++++++++++++++++ .../find_sum_of_an_array.py | 22 +++++++++ .../test_find_sum_of_an_array_elements.py | 13 ++++++ ...findthelargestnumberoccurencesinanarray.py | 20 ++++++++ ...t_of_an_array_without_using_len_functin.py | 11 +++++ ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 330 bytes .../printing_array_index_with_number.py | 16 +++++++ .../return_a_copy_of_an_array.py | 11 +++++ .../test_return_copy_of_an_array.py | 15 ++++++ 59 files changed, 502 insertions(+) create mode 100644 Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc create mode 100644 Find_occurences_of_Smallest_number_in_an_array/find_min_element_in_an_array.py create mode 100644 Find_occurences_of_Smallest_number_in_an_array/find_smallest_number_occurences.py create mode 100644 Find_occurences_of_Smallest_number_in_an_array/test_min_numbers_occurences.py create mode 100644 Find_occurences_of_largest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 Find_occurences_of_largest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 Find_occurences_of_largest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc create mode 100644 Find_occurences_of_largest_number_in_an_array/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc create mode 100644 Find_occurences_of_largest_number_in_an_array/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc create mode 100644 Find_occurences_of_largest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc create mode 100644 Find_occurences_of_largest_number_in_an_array/find_largest_number_occurences.py create mode 100644 Find_occurences_of_largest_number_in_an_array/find_max_element_in_an_array.py create mode 100644 Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py create mode 100644 checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 checking_whether_two_array_element_same_or_not/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 checking_whether_two_array_element_same_or_not/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc create mode 100644 checking_whether_two_array_element_same_or_not/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc create mode 100644 checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py create mode 100644 checking_whether_two_array_element_same_or_not/test_check_two_array_values.py create mode 100644 find_max_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 find_max_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 find_max_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc create mode 100644 find_max_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc create mode 100644 find_max_element_in_a_array/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc create mode 100644 find_max_element_in_a_array/find_max_element_in_an_array.py create mode 100644 find_max_element_in_a_array/test_find_max.py create mode 100644 find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 find_mean_of_array_elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 find_mean_of_array_elements/__pycache__/find_mean_of_array_elements.cpython-37.pyc create mode 100644 find_mean_of_array_elements/__pycache__/find_sum_of_an_array.cpython-37.pyc create mode 100644 find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc create mode 100644 find_mean_of_array_elements/find_mean_of_array_elements.py create mode 100644 find_mean_of_array_elements/find_sum_of_an_array.py create mode 100644 find_mean_of_array_elements/test_find_mean_of_array_elements.py create mode 100644 find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 find_min_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 find_min_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc create mode 100644 find_min_element_in_a_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc create mode 100644 find_min_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc create mode 100644 find_min_element_in_a_array/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc create mode 100644 find_min_element_in_a_array/__pycache__/test_find_min.cpython-37-PYTEST.pyc create mode 100644 find_min_element_in_a_array/find_min_element_in_an_array.py create mode 100644 find_min_element_in_a_array/test_find_min.py create mode 100644 find_most_occurence_an_element.py/__pycache__/test_find_most_occurence_of_an_element.cpython-37-PYTEST.pyc create mode 100644 find_most_occurence_an_element.py/find_most_occurence_of_an_element.py create mode 100644 find_sum_of_array_elements/find_sum_of_an_array.py create mode 100644 find_sum_of_array_elements/test_find_sum_of_an_array_elements.py create mode 100644 find_the_largest_occurences_in_an_array/findthelargestnumberoccurencesinanarray.py create mode 100644 print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py create mode 100644 print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 print_array_index_with_numbers_in_it/printing_array_index_with_number.py create mode 100644 return_a_copy_of_an_array/return_a_copy_of_an_array.py create mode 100644 return_a_copy_of_an_array/test_return_copy_of_an_array.py diff --git a/Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py b/Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/Find_occurences_of_Smallest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/Find_occurences_of_Smallest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..76be8996601ca17763d9ae9a73d6779df11e7cef GIT binary patch literal 333 zcmYLDy-EW?5T4nXBS>PcU}blW*hxf060uBU5eNs%vAcJ-aPH~;kOUI2&sp6y5oySU>GQr2R=NJJBi*Ea6z;8WdP zWM|{7&_;4!DPHHcRL=88h+vfw%5iOYPHt_!&TdJkP04Fz%8FFQUyCobubSX_a6bZG w1S7mQrw{A4-yM!;-GBga4-at2Y(jjNVweAa_09U!YX_J2jSRKA>Sp8U7jrmF-v9sr literal 0 HcmV?d00001 diff --git a/Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc b/Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46ff007094647847c96a4ea20bd6bd490f0992c7 GIT binary patch literal 516 zcmYjOJx{|h5IujSDy3Zz0}Sl#f)GMNMF=54j9nN&QG^v@w?rfkI1Vk6v++Y<b?V0^ugqb&;X;fue(8jdl`bp#2LWDtU+l08F6B)NbQ z|HKYV65){;K&^_ zR}NgT36A5;WVx@o3nbl#I(XQ<#E#dW7%%=|Mr$r+6J zCw5?xl0X<8Oon-kX|E6*ybuqsq(+ov2sK5f$jnpE?!at#T64`ktGQ%#^t9n4Pwtqx z^x&f*c#fLM&%Wk9l5`j9=wbT;J7NCBgwdZZ1iK^J?3`v=X8K0tO5fZ%QO-o7MPf{{ z5cAC4mX#Bg{S}B=rBj#bCQ8dnyHTgiHObzl)_59biZV?rqjail7Ju~0T=Y4r_Fk&b_e;rSL2*!TX;YL#2oTIj9Xf)Hj zVa3Mtf@`7W7gh+J=oG!w13lE4-qXWbS|lbl(j;rX<{b0hvV7EI4K}V2BMQ})sIO4l zb2OT-1gdoGEBEXhUnN&hz4Xb2gcHxae8fDz5OCy$7BARJcp1I?_~0G$0ukgGIM(UO zkwJ(Jv59bxJJ14d4>w~coj`dLVVtG`VbGdTyiInL%tTs z8*#i`i*D{6y2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUm-45F$R_~X_8Zsf@%hQgrA4WE$*INhnR)SvKvYzeSQ%3Sk^?J7Qjnh(pPN__pPG}J bo0?amS5SG2!zMRBr8Fni4rE&~5HkP(rU))m literal 0 HcmV?d00001 diff --git a/Find_occurences_of_Smallest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc b/Find_occurences_of_Smallest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f31b931b8702c95ffcdfddff65b505ee6682063f GIT binary patch literal 1121 zcmZWp%We}f6tz8%Owu$!L8z?g2GQA6X(&iV4Jxl4>H@loBAMyfX-Az$WP3zYO;`Y* z!J=UWe3BPzSmhVG;@Z=OAV%YB`}+9$`kpiMVs*9k{nzer4lJ_CGs2uNXwYCT^PmqHeuqMT4tvo-Y^-@qOb^;iXtE22;VG(+ z+%&rty1*5h;RN4BQ>+NgoeIzJXZ#7yox({F(LFdk??h5^p*9|Djwjop)Q;&~-P#{d z6qkxdLN}?5MqKc*(4FTNofP?NAqt^y(@`O^NKt+^PNO_huo9BN3hbtJ;BGysVZ9$n zG$7NBY1^~CPSM^7M;<&%#OH_OSrA^ zM7Qdr4n@gLQDh4Y!Y*>r8tNd?gxR8MK1@sswrW3Nz_6(oRGJ)nP!|WPbyd45sc=P3 z$<(PF`Av}vhk2DV!pt}R5t+HHq1+2^hE9F?7S_Q(!(s@dh8g9AHCV7fD2pI~_-GL@ z0z|-?UkPyJvKCvZT+5fI0zfn?Z^4&i`D!1`9msfYE;KhcotvA4_>%PdAwFL-9Ckyw z(eGP2dq8Kv&tg7SoM}IbRT-rrF%)+PV0!Z+M`e<#B$wJx3qVM{PUT5arp!X=aatTj zDb1sd3m4)DBX(i<3w`a`1jG&Fx(Q}ka@)(2d$c@xY}Hqr0Cwqi9fqq?PcU}blW*hxf060uBU5eNs%vAcJ-aPH~;kOUI2&sp6y5oySU>GQr2R=NJJBi*Ea6z;8WdP zWM|{7&_;4!DPHHcRL=88h+vfw%5iOYPHt_!&TdJkP04Fz%8FFQUyCobubSX_a6bZG w1S7mQrw{A4-yM!;-GBga4-at2Y(jjNVweAa_09U!YX_J2jSRKA>Sp8U7jrmF-v9sr literal 0 HcmV?d00001 diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc b/Find_occurences_of_largest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46ff007094647847c96a4ea20bd6bd490f0992c7 GIT binary patch literal 516 zcmYjOJx{|h5IujSDy3Zz0}Sl#f)GMNMF=54j9nN&QG^v@w?rfkI1Vk6v++Y<b?V0^ugqb&;X;fue(8jdl`bp#2LWDtU+l08F6B)NbQ z|HKYV65){;K&^_ zR}NgT36A5;WVx@o3nbl#I(XQ<#E#dW7%%Ju~0T=Y4r_Fk&b_e;rSL2*!TX;YL#2oTIj9Xf)Hj zVa3Mtf@`7W7gh+J=oG!w13lE4-qXWbS|lbl(j;rX<{b0hvV7EI4K}V2BMQ})sIO4l zb2OT-1gdoGEBEXhUnN&hz4Xb2gcHxae8fDz5OCy$7BARJcp1I?_~0G$0ukgGIM(UO zkwJ(Jv59bxJJ14d4>w~coj`dLVVtG`VbGdTyiInL%tTs z8*#i`i*D{6y2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUm-45F$R_~X_8Zsf@%hQgrA4WE$*INhnR)SvKvYzeSQ%3Sk^?J7Qjnh(pPN__pPG}J bo0?amS5SG2!zMRBr8Fni4rE&~5HkP(rU))m literal 0 HcmV?d00001 diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc b/Find_occurences_of_largest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f31b931b8702c95ffcdfddff65b505ee6682063f GIT binary patch literal 1121 zcmZWp%We}f6tz8%Owu$!L8z?g2GQA6X(&iV4Jxl4>H@loBAMyfX-Az$WP3zYO;`Y* z!J=UWe3BPzSmhVG;@Z=OAV%YB`}+9$`kpiMVs*9k{nzer4lJ_CGs2uNXwYCT^PmqHeuqMT4tvo-Y^-@qOb^;iXtE22;VG(+ z+%&rty1*5h;RN4BQ>+NgoeIzJXZ#7yox({F(LFdk??h5^p*9|Djwjop)Q;&~-P#{d z6qkxdLN}?5MqKc*(4FTNofP?NAqt^y(@`O^NKt+^PNO_huo9BN3hbtJ;BGysVZ9$n zG$7NBY1^~CPSM^7M;<&%#OH_OSrA^ zM7Qdr4n@gLQDh4Y!Y*>r8tNd?gxR8MK1@sswrW3Nz_6(oRGJ)nP!|WPbyd45sc=P3 z$<(PF`Av}vhk2DV!pt}R5t+HHq1+2^hE9F?7S_Q(!(s@dh8g9AHCV7fD2pI~_-GL@ z0z|-?UkPyJvKCvZT+5fI0zfn?Z^4&i`D!1`9msfYE;KhcotvA4_>%PdAwFL-9Ckyw z(eGP2dq8Kv&tg7SoM}IbRT-rrF%)+PV0!Z+M`e<#B$wJx3qVM{PUT5arp!X=aatTj zDb1sd3m4)DBX(i<3w`a`1jG&Fx(Q}ka@)(2d$c@xY}Hqr0Cwqi9fqq? two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +#values = [5,2,4,7,3,5] +#print(find_largest_value(values)) \ No newline at end of file diff --git a/Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py b/Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py new file mode 100644 index 0000000..f242d69 --- /dev/null +++ b/Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py @@ -0,0 +1,13 @@ +import findthelargestnumberoccurencesinanarray +def assertTrue(): + assert True + +def arrayreturn2(): + #arrange + array = [3,9,2,7,9] + excepted = 2 + #act + actual = findthelargestnumberoccurencesinanarray.find_largest_numbers_occurences(array) + #assert + assert excepted == actual + \ No newline at end of file diff --git a/checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py b/checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/checking_whether_two_array_element_same_or_not/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/checking_whether_two_array_element_same_or_not/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..39e9846a6b1cff29de897bc867892d0c267a6357 GIT binary patch literal 340 zcmYLDu}T9$5S`hWBS>PcU}bkru#N5+-|amce}c`#~Db#LO;aPZ}AVV zwaPD8IeR8J@ZP+gc{8)uqtQNaynalQFV5fLu?xZCict-jBuIRN8Ax#taW6wIg$SM= z5jR5Y_0z>$pkCp*{50>s~?<3MHk4(3YG^D5Ov@ONCi!*Y0}dRF>HUwrBp_5W;Ac!$c$d^>?8!2xj&wKV}#s=;P(>foZ_xe5EM~R zl9VW_*jJK*;!3DUjZ{1rDaB~(PsB9Wps8jz^acRyF333PQG=XMX)w5A+}Mx2!Ce~! z1ua#yWoWr0-@%g~(2BtW^dc{Ow4nBr7wzckz*9e3Fgx+Y)2GBkK+L{VtmP&O8t*Zq z*bCCqFZ&;f=Zazev*IoD4DTb(EnwHPKH!Hj?Vg_%Mipi*OKs-4lhsUSMrPJ#*K$?3 zylR|m>NP>m8Z&i;>BO{Zj2p*YG%yd>_NWu6rms3aE3-MWay?z7dmGY0_wb*SqcnQp z+!7n+@>9KiIXO6<4E3S+D%UR8R=QQSzMC%fQX41hY^h~srK#Kl{r}v0le~X<-8~-k z{}!w{_OG8I5a7d?Kmsv(3G6{cIZ)URF|*sq>BC_AFjYHvp}G$bsNX^u3mb+#Fl{)s j5ke;}ZDHK-ryKAnq~cf0N;RcE33YYQjUj%r3%l?OHzBZ_ literal 0 HcmV?d00001 diff --git a/checking_whether_two_array_element_same_or_not/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc b/checking_whether_two_array_element_same_or_not/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4001a39a16f4a268c33a89246fc16c4bf4c465f7 GIT binary patch literal 583 zcmZ`#J#X7E5Ist=EvvPM76_0nO92}w47Xc~B1qeG^^z>uQduj7S z;;}$}5!X)r106c$C5V%JkdH3EsejE&f`+uj=7XbLfv0o0K&N5Q=7Z za@PR?xfgas`_c`&iIcdu5cU#r31jas_rPp!(Jsr?;rPU%rVNSL!UojHc4@d18`z0d z9Klv-hjVu$cH)=#$$DE>u#B^-AH!HFBz^K~RMl_B%D8s(OmJS+8kLqYnZ8u<0tqWJ z!w*e$S{9#)N-{6yqNF_55^t(3E@I6uV<&vZ-LfT~wn*^928#1*$UO9s!h-;UeO9&`zHYd z2oF4X0YjiZXJg;^Usq|S(?Xf&*5y7smhHromW2nI5UwfJX!`pr(|f!ls}R0!%{=K| f9olaUG~*wD&ost=pO?uh!!yB|>N5Cj*>@fQd@85U literal 0 HcmV?d00001 diff --git a/checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py b/checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py new file mode 100644 index 0000000..9134c91 --- /dev/null +++ b/checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py @@ -0,0 +1,28 @@ +#15. Write a function that takes two unsorted integer arrays as input and +# returns True if the two arrays are the same. +import Finding_lenght_of_an_array_without_using_len_functin +def check_array_elements(array1,array2): + index = 0 + flag = False + check = 0 + lenght_of_array1 = Finding_lenght_of_an_array_without_using_len_functin.count(array1) + lenght_of_array2 = Finding_lenght_of_an_array_without_using_len_functin.count(array2) + if (lenght_of_array1 == lenght_of_array2): + lenght = lenght_of_array1 + while(index!=lenght): + if ( array1[index] == array2[index] ): + check = 1 + else: + check = 0 + break + index += 1 + + if check == 1 : + flag = True + + + return flag + +array1 = [2,8,1,4,5,2] +array2 = [2,9,1,4,5] +print(check_array_elements(array1,array2)) \ No newline at end of file diff --git a/checking_whether_two_array_element_same_or_not/test_check_two_array_values.py b/checking_whether_two_array_element_same_or_not/test_check_two_array_values.py new file mode 100644 index 0000000..bb9828d --- /dev/null +++ b/checking_whether_two_array_element_same_or_not/test_check_two_array_values.py @@ -0,0 +1,36 @@ +import check_whether_two_array_elements_same_or_not + +def assertTrue(): + assert True + +def test_array1_array2retutnFalse(): + #arrange + array1 = [2,8,1,4,5] + array2 = [2,9,1,4,5] + excepted = False + #act + actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + #assert + assert excepted == actual + + +def test_array1_array2retutnTrue(): + #arrange + array1 = [2,9,1,4,5] + array2 = [2,9,1,4,5] + excepted = True + #act + actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + #assert + assert excepted == actual + + +def test_array1_array2retutn1False(): + #arrange + array1 = [2,9,1,4,5,2] + array2 = [2,9,1,4,5] + excepted = False + #act + actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + #assert + assert excepted == actual \ No newline at end of file diff --git a/find_max_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py b/find_max_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/find_max_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/find_max_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/find_max_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f3591918c4ab513d3e875a882bc01eb1fb3591ff GIT binary patch literal 321 zcmZ?b<>g`kf`)~bF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?B3-Ov3@l^PGV@a6a}z7#Q*%;tQ}asVGxOpT;}eUD5-Vfe zfO466>G3(KdFdG?@%d@-i9kt^RD5}6Nk)EYNqlKBR6%@NX{#Uh(9!wnjCi?@iR{0^hd6|I8t3{#;g9$P|< z+t4zqj4BT-@N?mI18ap9fww~QR$lK08StFDp8BdJzsJv~pQd|<(>Zx6Vw5S((pawwvRs?K z&OM#z!^KT}+bu40w=lI=oo#x<`W*qVKK8mVV*&;CaX{Sw-H^DIBydT)5(zdEq;@1+ ln&?C>{gWs!Tw#5883Qt>HX@YCc~{Q{0|a^h!X$+ literal 0 HcmV?d00001 diff --git a/find_max_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc b/find_max_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff7eefb966f78ea0777763f9b5aa7dda4e6e6c81 GIT binary patch literal 1089 zcmY*Z%We}f6tz8*$s~QyrUFrkMTLaa*;HvLpdy0GYugQ7MG=D=J0%exWPw^|VnslCSOSW8cR)$?KJs`p>`n-G`Kre`Mifus(pHpMnuY z(1diTn_22HLP_d(DzrQaI)Pxq`%XGl;fo5)p`h!3a7b z1<~7h+mK6IkSQI|dt^clgS}VKDg8#jLfi>Nf*1Y6ql;CpwNz&7(e`k>8)@s|_*(rRmx2)&xZ-mxPg<1b(Y|ETt3_^Hzlm~ zo2V*edewUSyxZLG_6M1WQ+^)HM5Zz`@gR#igj9UoboM`|QJth)|| zP@njuK~{;X!EWB505%xSHRum41jW{1Qw2QOU9|;)^A* zT=yG4CQ%G z4viEx;5{?qNyL!UW(Q2`7TtT1M(18sw-0U_eTxYo1F7gV+-btq2`b`@CnKpa54#@s zc#^~@jb5G(xsrAnsXrbK5;MrO4U!xX+TM@#r+kzM2aQjX{Fo(+ z;NI724Snli7S*)7sHVq@nYx15VgIV%_dDtn+ik)hhC7nmntpgqllpLdF+LX!z$9&jhzy@yNT=#G}Y!( z_!%6M3lbMj{2E_5} zk`ujyt1~jDIhoKdy+cMcV=#AeI-y_bHRK&ZCfLzEKDk=sT1%B}KiKIH_X2Gk>|9el z>JKxivxqBGi8Sv>CHu;(y|n0VFMX?2PnpfA(^Co0B6-=5dCD`01T0*E)lso=qnH%1 z{hvgY;iNb3-aKnH4qKgWDx!p6MlzO(OtYw)MjTQqK5W_SO96mE#BP6RZdp`us1r4i z4suZiL#Rt!QYULfRbVzJ&4US^z>@Y027)48NVK5m9uVUKUE~uTGo)|Ca+As3$h0CDh7s5*s_kE4_cUsUFZON(HDxV8uw0iq(R z-x-w26)U2ayS8MdtOAH?UYeK8u_aqQo?^|XSp2Dr25&RPdk6G}HJbsws$(r1f!=O5 zZCUrBtiHT#%YG(>@pwBM@Hk*t>P84=|348N1R9+O!HT)Jl>UPK@cz=^tTtiYMq{qd zQAD44Jdg?xX*QxZkK+i{)b1sHuB54J89ivoPOIC*5XSQsBxna!EvL0phE8>lpTf+=(z z3}NfkWi{r5u1-k}m9+)lplbYoXIHnuVYZ^;>FgE{0A9qdl3!Felcq9vnexnMSqYym tC3B|prLh^&Y7 two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +values = [5,2,4,7,3,5] +print(find_largest_value(values)) \ No newline at end of file diff --git a/find_max_element_in_a_array/test_find_max.py b/find_max_element_in_a_array/test_find_max.py new file mode 100644 index 0000000..cd79911 --- /dev/null +++ b/find_max_element_in_a_array/test_find_max.py @@ -0,0 +1,14 @@ + +import find_max_element_in_an_array + +def test_AssertTrue(): + assert True + +def test_arrayretutn7(): + #arrange + values = [5,2,4,7,3,5] + excepted = 7 + #act + actual = find_max_element_in_an_array.find_largest_value(values) + #assert + assert excepted == actual \ No newline at end of file diff --git a/find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py b/find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/find_mean_of_array_elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/find_mean_of_array_elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7e22f146d9faf0c91fac49641ab71a273f863355 GIT binary patch literal 321 zcmZ?b<>g`kf`)~bF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(%$(OU^INE6FSZnFS_(MY>qU7+A)nW#*;C=cXp+#pkERCl(bYR>r61q~@mPl@!Og z0p&9D(&KYd^U^a)zzXu9YRWT9GV)7H;!BI63gXjB^O8$4^YjWTZ?S?c16ftf0VEh0 oSs3{kd6yRb!-tSENdNQqN9PEntW8bv-GanZt^zsTpF$Ecmb~8kvxDqcc z;>uIL>Zq;?W_~2Jr@0mz*Z?5^iG{r_=CW~u+O2tr0{tGnJVS8o4QlodYjAwO;x*L# zl&wWAPyxoFXilc7QL?OZSxjYYWNdA`YW$?AjB73*F_@Z}%(R)!-62Ijr*2+UPFCff zAg7f{TxvqE@pmc$WuqgNE>orDGR`X9c)5eKyFXFAu$ zmH)-g7pvwtiL<22Vy7hubm;9Q&7hAX084+crPgdY0TH%c0%}$0TROEAZ<&@prtudx cHLfl30D2S(Zt_A^nZBj;_ND*=9(0c37i?>N>i_@% literal 0 HcmV?d00001 diff --git a/find_mean_of_array_elements/__pycache__/find_sum_of_an_array.cpython-37.pyc b/find_mean_of_array_elements/__pycache__/find_sum_of_an_array.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9d0aa971739ee85f8128d1c10bb7615d2e3f95c GIT binary patch literal 489 zcmYjN!AiqG5S`ggYA9_FMbLr=@s^A9q*O#iJ@?{4D1{KZsTP~mZc=Drds08dqra4+ zp85-(e7nKgS>9wOv-|eFy=gY$Aj8vw#bT! zwp=d#^zJT(-QI9K$yAgkaTd+SQLJ^mijrxPCRveJvwV@dQC3Y)Usk2>$b3-c0TQvt zEp7;1L%mh*q1h@wLsO8USEz>r0m$XCk%ph8?iv977DhTZa^8j;;oN9zMBA4L z+1(L(rSGH;+S4R^d@6PYmJ*6f-m$8!Qf-wsfV_o796+?kb#7p}SwE}{xaR+zs>(8y R!DTvAi)nJ@oLfD?-Y*P_U6}v? literal 0 HcmV?d00001 diff --git a/find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc b/find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ba97b3bb100805d9fa12a3a3a50f7e454a01cb5c GIT binary patch literal 1110 zcmaJ>OK%e~5VpOKY|=K+R3HkMUXZ$%Dh(}C5rOjPwFl@ainMHFCq&&xWILj%HXMMT z!J+95ev)s9Q*NAlV#ZsdaH%Da?eRDEc)oA<_1aqP*VRGyAtmHDS!xXChtSniFr09j zkPfvYOC3fiN!^Y|%N@VtbH<%-q*LK8_h1Y-eNRGv4zc98hZY;2=|O)3T{XdQIwb{B z+Ze6MB`wH|4(WX|rJBLoDd>!TrC;FQDcl4ny2mFM^;jt(_15F<(PTGN#=*fgwZqXw z3#Fr2nrfutzK~)hP5qTc5A*Cu%3PX_sGrL;){!_LC2sqqonx&4X@#nDHnTaTeu$xJky7NF*W^nO0qU`z?T-(Zt-bpfaZuITj9O@vywWyg73rxV)>?ce(#cE-l2Od<#hg#iKZpsQ;uroGw3P)XOcIog+;q)mF z(BEe>mshoW>CMQQuinAFkM)&Zm{o9=F<#}h1wvZ{1H@;GfEgfaeC0a>hFreN*9zCN z<>>$r)xuk_?(@Fo%J zrI)9pSPHX>dN>^q6Ftn7@sk`7$~=hF$9$Y{3ylUzei|oH7N7yDLhr3oO)G;SmfLX$#|W!Boq3seIPVRh=V8Vf);AIK_7XA`_( z)dc@Cm-oP7Hly;>*eL}LirO3S9vRIADSE7s;M1& literal 0 HcmV?d00001 diff --git a/find_mean_of_array_elements/find_mean_of_array_elements.py b/find_mean_of_array_elements/find_mean_of_array_elements.py new file mode 100644 index 0000000..e4cbabf --- /dev/null +++ b/find_mean_of_array_elements/find_mean_of_array_elements.py @@ -0,0 +1,13 @@ +#8. Given an unsorted integer array A, find the mean. + +import find_sum_of_an_array +import Finding_lenght_of_an_array_without_using_len_functin + +def calculate_mean(array): + sum = find_sum_of_an_array.count(array) + divide_value = Finding_lenght_of_an_array_without_using_len_functin.count(array) + mean = sum / divide_value + return mean + +array = [4,2,6,7,3] +print(calculate_mean(array)) diff --git a/find_mean_of_array_elements/find_sum_of_an_array.py b/find_mean_of_array_elements/find_sum_of_an_array.py new file mode 100644 index 0000000..56158af --- /dev/null +++ b/find_mean_of_array_elements/find_sum_of_an_array.py @@ -0,0 +1,22 @@ +#Given an unsorted integer array A, find the sum of all the elements in A +#input = array of any size +#output = sum of all the element of the given array + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +def sum(array): + lenght_of_an_array = count(array) + sum = 0 + i = 0 + while(i!=lenght_of_an_array): + sum = sum + array[i] + i += 1 + return sum + +#array = [1,5,3,6,7,3] +#print(sum(array)) diff --git a/find_mean_of_array_elements/test_find_mean_of_array_elements.py b/find_mean_of_array_elements/test_find_mean_of_array_elements.py new file mode 100644 index 0000000..d877237 --- /dev/null +++ b/find_mean_of_array_elements/test_find_mean_of_array_elements.py @@ -0,0 +1,13 @@ +import find_mean_of_array_elements + +def test_AssertTrue(): + assert True + +def test_arrayreturn25(): + #arrange + array = [4,2,6,7,3] + excepted = 1.0 + #act + actual = find_mean_of_array_elements.calculate_mean(array) + #asert + assert excepted == actual \ No newline at end of file diff --git a/find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py b/find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/find_min_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/find_min_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f3591918c4ab513d3e875a882bc01eb1fb3591ff GIT binary patch literal 321 zcmZ?b<>g`kf`)~bF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?B3-Ov3@l^PGV@a6a}z7#Q*%;tQ}asVGxOpT;}eUD5-Vfe zfO466>G3(KdFdG?@%d@-i9kt^RD5}6Nk)EYNqlKBR6%@NX{#Uh(9!wnjCi?@iR{0^hd6|I8t3{#;g9$P|< z+t4zqj4BT-@N?mI18ap9fww~QR$lK08StFDp8BdJzsJv~pQd|<(>Zx6Vw5S((pawwvRs?K z&OM#z!^KT}+bu40w=lI=oo#x<`W*qVKK8mVV*&;CaX{Sw-H^DIBydT)5(zdEq;@1+ ln&?C>{gWs!Tw#5883Qt>HX@YCc~{Q{0|a^h!X$+ literal 0 HcmV?d00001 diff --git a/find_min_element_in_a_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc b/find_min_element_in_a_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3bebaf6b1e13f660fe7dea1117e01cb6db496a5 GIT binary patch literal 568 zcmZuuJx}965S`f%lglL%5)BmBljej@Cm|3*eCf(G6o;bdR#tWsESxp0*L+Cp3VsNb z_jj&zd!oo+pkmemiGs1_&CI^He(Uv7zuyIl=YKonZw%mn9Nr_L=76%?BG8~QhY@I| z`2&nl3oUh`S9C{c?+l$X^Uy zv|hA8p9TZg{QQ+!o!Obnjh&r)RZLZCRq9-Nr*1NTUQ}LH<(oiFD?9O-ZRDh=tREyz za-HUtDM!6!RqcAi3u_wgZ;FP`NsZZGa9_#qcg%exWPw^|VnslCSOSW8cR)$?KJs`p>`n-G`Kre`Mifus(pHpMnuY z(1diTn_22HLP_d(DzrQaI)Pxq`%XGl;fo5)p`h!3a7b z1<~7h+mK6IkSQI|dt^clgS}VKDg8#jLfi>Nf*1Y6ql;CpwNz&7(e`k>8)@s|_*(rRmx2)&xZ-mxPg<1b(Y|ETt3_^Hzlm~ zo2V*edewUSyxZLG_6M1WQ+^)HM5Zz`@gR#igj9UoboM`|QJth)|| zP@njuK~{;X!EWB505%xSHRum41jW{1Qw2QOU9|;)^A* zT=yG4CQ%G z4viEx;5{?qNyL!UW(Q2`7TtT1M(18sw-0U_eTxYo1F7gV+-btq2`b`@CnKpa54#@s zc#^~@jb5G(xsrAnsXrbK5;MrO4U!xX+TM@#r+kzM2aQjX{Fo(+ z;NI724Snli7S*)7sHVq@nYx15VgIV%_dDtn+ik)hhC7nmntpgqllpLdF+LX!z$9&jhzy@yNT=#G}Y!( z_!%6M3lbMj{2E_5} zk`ujyt1~jDIhoKdy+cMcV=#AeI-y_bHRK&ZCfLzEKDk=sT1%B}KiKIH_X2Gk>|9el z>JKxivxqBGi8Sv>CHu;(y|n0VFMX?2PnpfA(^Co0B6-=5dCD`01T0*E)lso=qnH%1 z{hvgY;iNb3-aKnH4qKgWDx!p6MlzO(OtYw)MjTQqK5W_SO96mE#BP6RZdp`us1r4i z4suZiL#Rt!QYULfRbVzJ&4US^z>@Y027)48NVK5m9uVUKUE~uTGo)|Ca+As3$h0CDh7s5*s_kE4_cUsUFZON(HDxV8uw0iq(R z-x-w26)U2ayS8MdtOAH?UYeK8u_aqQo?^|XSp2Dr25&RPdk6G}HJbsws$(r1f!=O5 zZCUrBtiHT#%YG(>@pwBM@Hk*t>P84=|348N1R9+O!HT)Jl>UPK@cz=^tTtiYMq{qd zQAD44Jdg?xX*QxZkK+i{)b1sHuB54J89ivoPOIC*5XSQsBxna!EvL0phE8>lpTf+=(z z3}NfkWi{r5u1-k}m9+)lplbYoXIHnuVYZ^;>FgE{0A9qdl3!Felcq9vnexnMSqYym tC3B|prLh^&Y7FxYzqozQReE5sc`BzVz3I=)=xT1#cNAMFfAdy%#tPQI-l z4n{_56LV#2vF1Ig$K}I~a#O;Z zzlf?rrq|84&pVBSPOqPdIPGV#Ok^rE6T^~2NX17T7kviU9gOT9=P467RzvAw-E}a8 z`ot$2WR<8I?B)#$V1v|G|I|Uo45` z!gu6UObCctQJItDIdWExrpWFTX`cFMu$C!S9novnYDM&N16gZCdb`zf1U7-dP+oN9 zz(`>O-Zev>L<~u7w81oQ(Y+sObnZuW`(W1STTB2MNJV?oo$8b)2}#t`PJave5ev@82TG literal 0 HcmV?d00001 diff --git a/find_min_element_in_a_array/find_min_element_in_an_array.py b/find_min_element_in_a_array/find_min_element_in_an_array.py new file mode 100644 index 0000000..9042c3e --- /dev/null +++ b/find_min_element_in_a_array/find_min_element_in_an_array.py @@ -0,0 +1,20 @@ + # To find the min of dictionary values +import Finding_lenght_of_an_array_without_using_len_functin +def find_smallest_value(values): + + values_count = Finding_lenght_of_an_array_without_using_len_functin.count(values) + one = values[0] + two = values[1] + if (one < two): + min = one + else: + min = two + i = 2 + while(i!=values_count): + if (values[i]j@n^s#vLGb29X%I^FRuQRR*Mitn2rMz#KpQCCM zC;x&cXA>z34$Rw~**7z9_M+G8R_|l)5CA^VS7zXCf-VjaLI_C$E~!r=H4Pw;T5gL# zXoThqxN9M~1;_eCE=&WB+H{W=`X#y;A%tWBa}WbvCE=CKVM$`L0}CPzjLkV&l4tUS za~3#Lcbv{1`@Rs2%f0N two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max +def find_key_from_dictionary(dictionary,max_element): # To find key from the value in an dictionary + for k,v in dictionary.items(): + if (v == max_element): + key = k + return key +def finding_most_occureence_of_an_element(array): # the main function + dictionary = built_dictionary(array) + values = list(dictionary.values()) # converting the dictonary value to a list + max_element = find_largest_value(values) + key = find_key_from_dictionary(dictionary,max_element) + print ("the number {0} appears {1} times".format(max_element,key)) + +array = [1,2,5,3,2,4,5,5,5] +finding_most_occureence_of_an_element(array) \ No newline at end of file diff --git a/find_sum_of_array_elements/find_sum_of_an_array.py b/find_sum_of_array_elements/find_sum_of_an_array.py new file mode 100644 index 0000000..4ad75e5 --- /dev/null +++ b/find_sum_of_array_elements/find_sum_of_an_array.py @@ -0,0 +1,22 @@ +#Given an unsorted integer array A, find the sum of all the elements in A +#input = array of any size +#output = sum of all the element of the given array + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +def sum(array): + lenght_of_an_array = count(array) + sum = 0 + i = 0 + while(i!=lenght_of_an_array): + sum = sum + array[i] + i += 1 + return sum + +array = [1,5,3,6,7,3] +print(sum(array)) diff --git a/find_sum_of_array_elements/test_find_sum_of_an_array_elements.py b/find_sum_of_array_elements/test_find_sum_of_an_array_elements.py new file mode 100644 index 0000000..8007ac0 --- /dev/null +++ b/find_sum_of_array_elements/test_find_sum_of_an_array_elements.py @@ -0,0 +1,13 @@ +import find_sum_of_an_array + +def test_AssertTrue(): + assert True + +def test_arrayreturn25(): + #arrange + array = [1,5,3,6,7,3] + excepted = 25 + #act + output = find_sum_of_an_array.sum(array) + #assert + assert excepted == output \ No newline at end of file diff --git a/find_the_largest_occurences_in_an_array/findthelargestnumberoccurencesinanarray.py b/find_the_largest_occurences_in_an_array/findthelargestnumberoccurencesinanarray.py new file mode 100644 index 0000000..ad9d93b --- /dev/null +++ b/find_the_largest_occurences_in_an_array/findthelargestnumberoccurencesinanarray.py @@ -0,0 +1,20 @@ +#12. Given an unsorted integer array A, +# find the number of times the smallest number is found in the array. +import find_max_element_in_an_array +import Finding_lenght_of_an_array_without_using_len_functin +def count_occuences(array,max): + count = 0 + i = 0 + lenght = Finding_lenght_of_an_array_without_using_len_functin.count(array) + while (i!=lenght): + if (array[i]==max): + count += 1 + i += 1 + return count + +def find_largest_numbers_occurences(array): + max = find_max_element_in_an_array.find_largest_value(array) + count = count_occuences(array,max) + return count + +#print(find_largest_numbers_occurences(array)) diff --git a/print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py b/print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f86afb16ee88b72b829e9000d3283d4f695e0c8 GIT binary patch literal 330 zcmYLDJxc>Y5S`hWBS>PcU}blW*hxf0R4mh22;pG3++LD}WH0UqCXj%I{t!!li~rzS ztNaBkXU>QN^XBc$doz2}>+J)_%X>fjsZZwhH8yglJlv zx19cjLE{FOhih1)hBtKt?wFZ6hYda@kK7gaV9P?-%8n06RgL*DDXM6Lak8s{@6p{w zcGk}p&e%Y?bNPyl)#Z|&O_-96^HJ$Mx5$L-o+rjmXja Date: Sat, 19 Jan 2019 23:37:37 +0530 Subject: [PATCH 04/10] solution for array problems --- 1.FindLenght/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 333 bytes .../test_find_lenght.cpython-37-PYTEST.pyc | Bin 0 -> 1045 bytes 1.FindLenght/test_find_lenght.py | 13 +++++ .../FindLenght.py | 0 .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 263 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin ...ind_max_element_in_an_array.cpython-37.pyc | Bin .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 473 bytes ...ind_min_element_in_an_array.cpython-37.pyc | Bin .../test_find_max.cpython-37-PYTEST.pyc | Bin ..._element_in_an_array.cpython-37-PYTEST.pyc | Bin .../test_find_min.cpython-37-PYTEST.pyc | Bin 1090 -> 1042 bytes .../find_min.py | 10 ++-- .../test_find_min.py | 5 +- .../FindLenght.py | 0 .../Max.py | 10 ++-- .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 279 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin 11.FindMax/__pycache__/Max.cpython-37.pyc | Bin 0 -> 485 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin .../test_find_max.cpython-37-PYTEST.pyc | Bin 0 -> 1044 bytes ..._element_in_an_array.cpython-37-PYTEST.pyc | Bin .../test_find_max.py | 4 +- .../FindLenght.py | 0 .../Max.py | 6 +- .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 286 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin .../__pycache__/Max.cpython-37.pyc | Bin 0 -> 423 bytes .../find_largest_number_count.cpython-37.pyc | Bin 0 -> 649 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin ...stnumberoccurencesinanarray.cpython-37.pyc | Bin ...ences_of_max_element.cpython-37-PYTEST.pyc | Bin ...largest_Number_Count.cpython-37-PYTEST.pyc | Bin 0 -> 1100 bytes ...x_numbers_occurences.cpython-37-PYTEST.pyc | Bin .../find_largest_number_count.py | 12 ++-- .../test_largest_Number_Count.py | 4 +- .../FindLenght.py | 0 .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 275 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin .../findSmallestNumberCount.cpython-37.pyc | Bin 0 -> 658 bytes ...ind_max_element_in_an_array.cpython-37.pyc | Bin .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 433 bytes ...ind_min_element_in_an_array.cpython-37.pyc | Bin ...stnumberoccurencesinanarray.cpython-37.pyc | Bin .../test_find_min.cpython-37-PYTEST.pyc | Bin 0 -> 1076 bytes ...ences_of_max_element.cpython-37-PYTEST.pyc | Bin ...x_numbers_occurences.cpython-37-PYTEST.pyc | Bin .../findSmallestNumberCount.py | 12 ++-- .../find_min.py | 4 +- .../test_find_min.py | 4 +- ...t_of_an_array_without_using_len_functin.py | 0 ...y_without_using_len_functin.cpython-37.pyc | Bin .../printing_array_index_with_number.py | 0 .../Compare_Two_Array_Elements.py | 10 ++-- .../FindLenght.py | 0 .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 275 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin ..._array_elements_same_or_not.cpython-37.pyc | Bin ...eck_two_array_values.cpython-37-PYTEST.pyc | Bin .../test_check_two_array_values.py | 8 +-- .../return_a_copy_of_an_array.py | 0 .../test_return_copy_of_an_array.py | 0 .../FindLenght.py | 0 .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 275 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 343 bytes ..._the_array_in_reverse_order.cpython-37.pyc | Bin 0 -> 612 bytes ...ray in reverse order.cpython-37-PYTEST.pyc | Bin 0 -> 623 bytes .../reverse_Array_elements.py | 13 +++++ .../FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 285 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin 0 -> 324 bytes .../return_array_in_reverse_order.py | 17 ++++++ .../return_index.py | 23 ++++++++ .../test_return_index.py | 0 .../__pycache__/isContain.cpython-37.pyc | Bin 0 -> 371 bytes .../test_isContain.cpython-37-PYTEST.pyc | Bin 0 -> 1076 bytes .../isContain.py | 2 +- 2.iscontains/test_isContain.py | 15 +++++ .../removeDuplicates.cpython-37.pyc | Bin 0 -> 437 bytes ...est_removeDuplicates.cpython-37-PYTEST.pyc | Bin 0 -> 1109 bytes 20.RemoveDuplicates/removeDuplicates.py | 13 +++++ 20.RemoveDuplicates/test_removeDuplicates.py | 13 +++++ 21.returnOddNumbers/returnOddnumbers.py | 11 ++++ 22.returnEvenNumbers/returnEvennumbers.py | 12 ++++ 23.Prime_numbers/IsPrime.py | 22 +++++++ .../__pycache__/IsPrime.cpython-37.pyc | Bin 0 -> 400 bytes 23.Prime_numbers/primeNumber.py | 9 +++ 24.Perfect_square/perfectSquare.py | 18 ++++++ 25.2ndLargestNumber/2ndLagestNumbers.py | 13 +++++ 25.2ndLargestNumber/FindLenght.py | 11 ++++ 25.2ndLargestNumber/Max.py | 20 +++++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 271 bytes .../__pycache__/Max.cpython-37.pyc | Bin 0 -> 408 bytes 25.2ndSmallestNumber/2ndSmallestNumber.py | 13 +++++ 25.2ndSmallestNumber/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 272 bytes .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 418 bytes 25.2ndSmallestNumber/find_min.py | 20 +++++++ 26.Find_kth_Largest_ele/FindLenght.py | 11 ++++ 26.Find_kth_Largest_ele/Max.py | 20 +++++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 275 bytes .../__pycache__/Max.cpython-37.pyc | Bin 0 -> 412 bytes .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 421 bytes .../find_kth_Largest_ele.py | 24 ++++++++ 26.Find_kth_Largest_ele/find_min.py | 20 +++++++ 26.Find_kth_smallest_ele/FindLenght.py | 11 ++++ 26.Find_kth_smallest_ele/Max.py | 20 +++++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 276 bytes .../__pycache__/Max.cpython-37.pyc | Bin 0 -> 413 bytes .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 422 bytes .../find_kth_smallest_ele.py | 24 ++++++++ 26.Find_kth_smallest_ele/find_min.py | 20 +++++++ 27.Count_upto_less/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 270 bytes 27.Count_upto_less/count_remodified.py | 17 ++++++ .../count_upto_less_than_equalto_value.py | 20 +++++++ 28.Count_upto_greater/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 273 bytes 28.Count_upto_greater/count_upto_greater.py | 19 ++++++ 29.swap_one_bit_right/swapRight.py | 16 ++++++ 3.getIndex/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 331 bytes 3.getIndex/getIndex.py | 17 ++++++ 30.Shiftleft/shiftLeft.py | 13 +++++ 31.shiftRightby2bits/shiftRightby2.py | 19 ++++++ 32.shiftrightleft/shiftrightleft.py | 30 ++++++++++ 33.shiftGreaterThanN/shiftGreaterN.py | 35 ++++++++++++ 35.FindUniqueElements/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 273 bytes .../builtDictionary.cpython-37.pyc | Bin 0 -> 345 bytes .../dictionaryOperations.cpython-37.pyc | Bin 0 -> 535 bytes .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 419 bytes 35.FindUniqueElements/dictionaryOperations.py | 16 ++++++ 35.FindUniqueElements/findUnique.py | 17 ++++++ 35.FindUniqueElements/find_min.py | 20 +++++++ 36.notUniques/FindLenght.py | 11 ++++ .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 265 bytes .../dictionaryOperations.cpython-37.pyc | Bin 0 -> 527 bytes .../__pycache__/find_min.cpython-37.pyc | Bin 0 -> 411 bytes 36.notUniques/dictionaryOperations.py | 16 ++++++ 36.notUniques/findNotUnique.py | 17 ++++++ 36.notUniques/find_min.py | 20 +++++++ 37.getIndexAfterRotationright/Rotateright.py | 13 +++++ .../__pycache__/Rotateright.cpython-37.pyc | Bin 0 -> 399 bytes .../getindexRight.py | 12 ++++ .../__pycache__/shiftLeft.cpython-37.pyc | Bin 0 -> 389 bytes .../getindexAterrotation.py | 13 +++++ 38.getIndexafterrotationleft/shiftLeft.py | 11 ++++ 39.getIndexafterrotationright/Rotateright.py | 13 +++++ .../__pycache__/Rotateright.cpython-37.pyc | Bin 0 -> 399 bytes .../getindexRight.py | 12 ++++ .../Find_More_than_once.py | 29 ++++++++++ .../Find_More_than_once.cpython-37.pyc | Bin 0 -> 631 bytes ...than_one_occurrences.cpython-37-PYTEST.pyc | Bin 0 -> 1134 bytes .../test_find_more_than_one_occurrences.py | 14 +++++ .../__pycache__/shiftLeft.cpython-37.pyc | Bin 0 -> 388 bytes .../getindexAterrotation.py | 13 +++++ 40.getIndexafterroationleft/shiftLeft.py | 11 ++++ ..._the_number_of_occurrence_of_an_element.py | 33 +++++++++++ 6.listIndicess/list_Indices.py | 18 ++++++ 7.sum/__pycache__/sum_elements.cpython-37.pyc | Bin 0 -> 528 bytes .../test_sum.cpython-37-PYTEST.pyc | Bin 0 -> 1036 bytes .../sum_elements.py | 0 .../test_sum.py | 4 +- 8.Find_Mean/FindLenght.py | 11 ++++ 8.Find_Mean/Find_mean.py | 14 +++++ .../Sum.py | 9 +-- .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 263 bytes .../__pycache__/Find_mean.cpython-37.pyc | Bin 0 -> 412 bytes ...y_without_using_len_functin.cpython-37.pyc | Bin 8.Find_Mean/__pycache__/Sum.cpython-37.pyc | Bin 0 -> 342 bytes ...find_mean_of_array_elements.cpython-37.pyc | Bin .../find_sum_of_an_array.cpython-37.pyc | Bin ...an_of_array_elements.cpython-37-PYTEST.pyc | Bin 0 -> 1066 bytes .../test_find_mean.py | 6 +- 9.Most_occurence.py/Equate.py | 25 ++++++++ 9.Most_occurence.py/FindLenght.py | 11 ++++ 9.Most_occurence.py/Max.py | 20 +++++++ .../__pycache__/Equate.cpython-37.pyc | Bin 0 -> 415 bytes .../__pycache__/FindLenght.cpython-37.pyc | Bin 0 -> 271 bytes .../__pycache__/Max.cpython-37.pyc | Bin 0 -> 408 bytes .../find_most_occurence.cpython-37.pyc | Bin 0 -> 992 bytes .../test_Most_occurence.cpython-37-PYTEST.pyc | Bin 0 -> 528 bytes ...urence_of_an_element.cpython-37-PYTEST.pyc | Bin 9.Most_occurence.py/find_most_occurence.py | 37 ++++++++++++ 9.Most_occurence.py/test_Most_occurence.py | 6 ++ ...e most occurence of an element in an array | 49 ---------------- .../find_largest_number_occurences.py | 20 ------- Questions.md | 54 ------------------ README.md | 15 ----- ...an_of_array_elements.cpython-37-PYTEST.pyc | Bin 1110 -> 0 bytes .../find_mean_of_array_elements.py | 13 ----- .../test_find_max.cpython-37-PYTEST.pyc | Bin 1089 -> 0 bytes .../find_most_occurence_of_an_element.py | 43 -------------- 195 files changed, 1154 insertions(+), 252 deletions(-) create mode 100644 1.FindLenght/FindLenght.py create mode 100644 1.FindLenght/__pycache__/FindLenght.cpython-37.pyc create mode 100644 1.FindLenght/__pycache__/test_find_lenght.cpython-37-PYTEST.pyc create mode 100644 1.FindLenght/test_find_lenght.py rename Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py => 10.Find_Min/FindLenght.py (100%) create mode 100644 10.Find_Min/__pycache__/FindLenght.cpython-37.pyc rename {find_max_element_in_a_array => 10.Find_Min}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) rename {find_max_element_in_a_array => 10.Find_Min}/__pycache__/find_max_element_in_an_array.cpython-37.pyc (100%) create mode 100644 10.Find_Min/__pycache__/find_min.cpython-37.pyc rename {find_min_element_in_a_array => 10.Find_Min}/__pycache__/find_min_element_in_an_array.cpython-37.pyc (100%) rename {find_max_element_in_a_array => 10.Find_Min}/__pycache__/test_find_max.cpython-37-PYTEST.pyc (100%) rename {find_max_element_in_a_array => 10.Find_Min}/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc (100%) rename {find_min_element_in_a_array => 10.Find_Min}/__pycache__/test_find_min.cpython-37-PYTEST.pyc (60%) rename find_min_element_in_a_array/find_min_element_in_an_array.py => 10.Find_Min/find_min.py (54%) rename {find_min_element_in_a_array => 10.Find_Min}/test_find_min.py (61%) rename Find_occurences_of_largest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py => 11.FindMax/FindLenght.py (100%) rename find_max_element_in_a_array/find_max_element_in_an_array.py => 11.FindMax/Max.py (54%) create mode 100644 11.FindMax/__pycache__/FindLenght.cpython-37.pyc rename {find_min_element_in_a_array => 11.FindMax}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) create mode 100644 11.FindMax/__pycache__/Max.cpython-37.pyc rename {find_min_element_in_a_array => 11.FindMax}/__pycache__/find_max_element_in_an_array.cpython-37.pyc (100%) create mode 100644 11.FindMax/__pycache__/test_find_max.cpython-37-PYTEST.pyc rename {find_min_element_in_a_array => 11.FindMax}/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc (100%) rename {find_max_element_in_a_array => 11.FindMax}/test_find_max.py (62%) rename checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py => 12.Find_largest_number_count_value/FindLenght.py (100%) rename Find_occurences_of_largest_number_in_an_array/find_max_element_in_an_array.py => 12.Find_largest_number_count_value/Max.py (65%) create mode 100644 12.Find_largest_number_count_value/__pycache__/FindLenght.cpython-37.pyc rename {Find_occurences_of_Smallest_number_in_an_array => 12.Find_largest_number_count_value}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) create mode 100644 12.Find_largest_number_count_value/__pycache__/Max.cpython-37.pyc create mode 100644 12.Find_largest_number_count_value/__pycache__/find_largest_number_count.cpython-37.pyc rename {Find_occurences_of_Smallest_number_in_an_array => 12.Find_largest_number_count_value}/__pycache__/find_max_element_in_an_array.cpython-37.pyc (100%) rename {Find_occurences_of_Smallest_number_in_an_array => 12.Find_largest_number_count_value}/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc (100%) rename {Find_occurences_of_Smallest_number_in_an_array => 12.Find_largest_number_count_value}/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc (100%) create mode 100644 12.Find_largest_number_count_value/__pycache__/test_largest_Number_Count.cpython-37-PYTEST.pyc rename {Find_occurences_of_Smallest_number_in_an_array => 12.Find_largest_number_count_value}/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc (100%) rename find_the_largest_occurences_in_an_array/findthelargestnumberoccurencesinanarray.py => 12.Find_largest_number_count_value/find_largest_number_count.py (56%) rename Find_occurences_of_Smallest_number_in_an_array/test_min_numbers_occurences.py => 12.Find_largest_number_count_value/test_largest_Number_Count.py (54%) rename find_max_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py => 13.findSmallnumberCount/FindLenght.py (100%) create mode 100644 13.findSmallnumberCount/__pycache__/FindLenght.cpython-37.pyc rename {Find_occurences_of_largest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) create mode 100644 13.findSmallnumberCount/__pycache__/findSmallestNumberCount.cpython-37.pyc rename {Find_occurences_of_largest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/find_max_element_in_an_array.cpython-37.pyc (100%) create mode 100644 13.findSmallnumberCount/__pycache__/find_min.cpython-37.pyc rename {Find_occurences_of_Smallest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/find_min_element_in_an_array.cpython-37.pyc (100%) rename {Find_occurences_of_largest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc (100%) create mode 100644 13.findSmallnumberCount/__pycache__/test_find_min.cpython-37-PYTEST.pyc rename {Find_occurences_of_largest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc (100%) rename {Find_occurences_of_largest_number_in_an_array => 13.findSmallnumberCount}/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc (100%) rename Find_occurences_of_Smallest_number_in_an_array/find_smallest_number_occurences.py => 13.findSmallnumberCount/findSmallestNumberCount.py (51%) rename Find_occurences_of_Smallest_number_in_an_array/find_min_element_in_an_array.py => 13.findSmallnumberCount/find_min.py (71%) rename Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py => 13.findSmallnumberCount/test_find_min.py (54%) rename {find_mean_of_array_elements => 14.print_array_index_with_numbers_in_it}/Finding_lenght_of_an_array_without_using_len_functin.py (100%) rename {print_array_index_with_numbers_in_it => 14.print_array_index_with_numbers_in_it}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) rename {print_array_index_with_numbers_in_it => 14.print_array_index_with_numbers_in_it}/printing_array_index_with_number.py (100%) rename checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py => 15.Compare_Two_Array_Elements/Compare_Two_Array_Elements.py (63%) rename find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py => 15.Compare_Two_Array_Elements/FindLenght.py (100%) create mode 100644 15.Compare_Two_Array_Elements/__pycache__/FindLenght.cpython-37.pyc rename {checking_whether_two_array_element_same_or_not => 15.Compare_Two_Array_Elements}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) rename {checking_whether_two_array_element_same_or_not => 15.Compare_Two_Array_Elements}/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc (100%) rename {checking_whether_two_array_element_same_or_not => 15.Compare_Two_Array_Elements}/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc (100%) rename {checking_whether_two_array_element_same_or_not => 15.Compare_Two_Array_Elements}/test_check_two_array_values.py (62%) rename {return_a_copy_of_an_array => 16.return_a_copy_of_an_array}/return_a_copy_of_an_array.py (100%) rename {return_a_copy_of_an_array => 16.return_a_copy_of_an_array}/test_return_copy_of_an_array.py (100%) rename print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py => 17.reverseArrayElements/FindLenght.py (100%) create mode 100644 17.reverseArrayElements/__pycache__/FindLenght.cpython-37.pyc create mode 100644 17.reverseArrayElements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 17.reverseArrayElements/__pycache__/prints_the_contents_of_the_array_in_reverse_order.cpython-37.pyc create mode 100644 17.reverseArrayElements/__pycache__/test_prints the contents of the array in reverse order.cpython-37-PYTEST.pyc create mode 100644 17.reverseArrayElements/reverse_Array_elements.py create mode 100644 18.returns_array_in_reverse_order/FindLenght.py create mode 100644 18.returns_array_in_reverse_order/__pycache__/FindLenght.cpython-37.pyc create mode 100644 18.returns_array_in_reverse_order/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc create mode 100644 18.returns_array_in_reverse_order/return_array_in_reverse_order.py create mode 100644 19.return_index_upto_same_array/return_index.py create mode 100644 19.return_index_upto_same_array/test_return_index.py create mode 100644 2.iscontains/__pycache__/isContain.cpython-37.pyc create mode 100644 2.iscontains/__pycache__/test_isContain.cpython-37-PYTEST.pyc rename Check whether the given element is present or not => 2.iscontains/isContain.py (85%) create mode 100644 2.iscontains/test_isContain.py create mode 100644 20.RemoveDuplicates/__pycache__/removeDuplicates.cpython-37.pyc create mode 100644 20.RemoveDuplicates/__pycache__/test_removeDuplicates.cpython-37-PYTEST.pyc create mode 100644 20.RemoveDuplicates/removeDuplicates.py create mode 100644 20.RemoveDuplicates/test_removeDuplicates.py create mode 100644 21.returnOddNumbers/returnOddnumbers.py create mode 100644 22.returnEvenNumbers/returnEvennumbers.py create mode 100644 23.Prime_numbers/IsPrime.py create mode 100644 23.Prime_numbers/__pycache__/IsPrime.cpython-37.pyc create mode 100644 23.Prime_numbers/primeNumber.py create mode 100644 24.Perfect_square/perfectSquare.py create mode 100644 25.2ndLargestNumber/2ndLagestNumbers.py create mode 100644 25.2ndLargestNumber/FindLenght.py create mode 100644 25.2ndLargestNumber/Max.py create mode 100644 25.2ndLargestNumber/__pycache__/FindLenght.cpython-37.pyc create mode 100644 25.2ndLargestNumber/__pycache__/Max.cpython-37.pyc create mode 100644 25.2ndSmallestNumber/2ndSmallestNumber.py create mode 100644 25.2ndSmallestNumber/FindLenght.py create mode 100644 25.2ndSmallestNumber/__pycache__/FindLenght.cpython-37.pyc create mode 100644 25.2ndSmallestNumber/__pycache__/find_min.cpython-37.pyc create mode 100644 25.2ndSmallestNumber/find_min.py create mode 100644 26.Find_kth_Largest_ele/FindLenght.py create mode 100644 26.Find_kth_Largest_ele/Max.py create mode 100644 26.Find_kth_Largest_ele/__pycache__/FindLenght.cpython-37.pyc create mode 100644 26.Find_kth_Largest_ele/__pycache__/Max.cpython-37.pyc create mode 100644 26.Find_kth_Largest_ele/__pycache__/find_min.cpython-37.pyc create mode 100644 26.Find_kth_Largest_ele/find_kth_Largest_ele.py create mode 100644 26.Find_kth_Largest_ele/find_min.py create mode 100644 26.Find_kth_smallest_ele/FindLenght.py create mode 100644 26.Find_kth_smallest_ele/Max.py create mode 100644 26.Find_kth_smallest_ele/__pycache__/FindLenght.cpython-37.pyc create mode 100644 26.Find_kth_smallest_ele/__pycache__/Max.cpython-37.pyc create mode 100644 26.Find_kth_smallest_ele/__pycache__/find_min.cpython-37.pyc create mode 100644 26.Find_kth_smallest_ele/find_kth_smallest_ele.py create mode 100644 26.Find_kth_smallest_ele/find_min.py create mode 100644 27.Count_upto_less/FindLenght.py create mode 100644 27.Count_upto_less/__pycache__/FindLenght.cpython-37.pyc create mode 100644 27.Count_upto_less/count_remodified.py create mode 100644 27.Count_upto_less/count_upto_less_than_equalto_value.py create mode 100644 28.Count_upto_greater/FindLenght.py create mode 100644 28.Count_upto_greater/__pycache__/FindLenght.cpython-37.pyc create mode 100644 28.Count_upto_greater/count_upto_greater.py create mode 100644 29.swap_one_bit_right/swapRight.py create mode 100644 3.getIndex/FindLenght.py create mode 100644 3.getIndex/__pycache__/FindLenght.cpython-37.pyc create mode 100644 3.getIndex/getIndex.py create mode 100644 30.Shiftleft/shiftLeft.py create mode 100644 31.shiftRightby2bits/shiftRightby2.py create mode 100644 32.shiftrightleft/shiftrightleft.py create mode 100644 33.shiftGreaterThanN/shiftGreaterN.py create mode 100644 35.FindUniqueElements/FindLenght.py create mode 100644 35.FindUniqueElements/__pycache__/FindLenght.cpython-37.pyc create mode 100644 35.FindUniqueElements/__pycache__/builtDictionary.cpython-37.pyc create mode 100644 35.FindUniqueElements/__pycache__/dictionaryOperations.cpython-37.pyc create mode 100644 35.FindUniqueElements/__pycache__/find_min.cpython-37.pyc create mode 100644 35.FindUniqueElements/dictionaryOperations.py create mode 100644 35.FindUniqueElements/findUnique.py create mode 100644 35.FindUniqueElements/find_min.py create mode 100644 36.notUniques/FindLenght.py create mode 100644 36.notUniques/__pycache__/FindLenght.cpython-37.pyc create mode 100644 36.notUniques/__pycache__/dictionaryOperations.cpython-37.pyc create mode 100644 36.notUniques/__pycache__/find_min.cpython-37.pyc create mode 100644 36.notUniques/dictionaryOperations.py create mode 100644 36.notUniques/findNotUnique.py create mode 100644 36.notUniques/find_min.py create mode 100644 37.getIndexAfterRotationright/Rotateright.py create mode 100644 37.getIndexAfterRotationright/__pycache__/Rotateright.cpython-37.pyc create mode 100644 37.getIndexAfterRotationright/getindexRight.py create mode 100644 38.getIndexafterrotationleft/__pycache__/shiftLeft.cpython-37.pyc create mode 100644 38.getIndexafterrotationleft/getindexAterrotation.py create mode 100644 38.getIndexafterrotationleft/shiftLeft.py create mode 100644 39.getIndexafterrotationright/Rotateright.py create mode 100644 39.getIndexafterrotationright/__pycache__/Rotateright.cpython-37.pyc create mode 100644 39.getIndexafterrotationright/getindexRight.py create mode 100644 4.Find_More_than_one_occurences/Find_More_than_once.py create mode 100644 4.Find_More_than_one_occurences/__pycache__/Find_More_than_once.cpython-37.pyc create mode 100644 4.Find_More_than_one_occurences/__pycache__/test_find_more_than_one_occurrences.cpython-37-PYTEST.pyc create mode 100644 4.Find_More_than_one_occurences/test_find_more_than_one_occurrences.py create mode 100644 40.getIndexafterroationleft/__pycache__/shiftLeft.cpython-37.pyc create mode 100644 40.getIndexafterroationleft/getindexAterrotation.py create mode 100644 40.getIndexafterroationleft/shiftLeft.py create mode 100644 5.Count_Occruences_of_an_element/find_the_number_of_occurrence_of_an_element.py create mode 100644 6.listIndicess/list_Indices.py create mode 100644 7.sum/__pycache__/sum_elements.cpython-37.pyc create mode 100644 7.sum/__pycache__/test_sum.cpython-37-PYTEST.pyc rename find_sum_of_array_elements/find_sum_of_an_array.py => 7.sum/sum_elements.py (100%) rename find_sum_of_array_elements/test_find_sum_of_an_array_elements.py => 7.sum/test_sum.py (70%) create mode 100644 8.Find_Mean/FindLenght.py create mode 100644 8.Find_Mean/Find_mean.py rename find_mean_of_array_elements/find_sum_of_an_array.py => 8.Find_Mean/Sum.py (71%) create mode 100644 8.Find_Mean/__pycache__/FindLenght.cpython-37.pyc create mode 100644 8.Find_Mean/__pycache__/Find_mean.cpython-37.pyc rename {find_mean_of_array_elements => 8.Find_Mean}/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc (100%) create mode 100644 8.Find_Mean/__pycache__/Sum.cpython-37.pyc rename {find_mean_of_array_elements => 8.Find_Mean}/__pycache__/find_mean_of_array_elements.cpython-37.pyc (100%) rename {find_mean_of_array_elements => 8.Find_Mean}/__pycache__/find_sum_of_an_array.cpython-37.pyc (100%) create mode 100644 8.Find_Mean/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc rename find_mean_of_array_elements/test_find_mean_of_array_elements.py => 8.Find_Mean/test_find_mean.py (56%) create mode 100644 9.Most_occurence.py/Equate.py create mode 100644 9.Most_occurence.py/FindLenght.py create mode 100644 9.Most_occurence.py/Max.py create mode 100644 9.Most_occurence.py/__pycache__/Equate.cpython-37.pyc create mode 100644 9.Most_occurence.py/__pycache__/FindLenght.cpython-37.pyc create mode 100644 9.Most_occurence.py/__pycache__/Max.cpython-37.pyc create mode 100644 9.Most_occurence.py/__pycache__/find_most_occurence.cpython-37.pyc create mode 100644 9.Most_occurence.py/__pycache__/test_Most_occurence.cpython-37-PYTEST.pyc rename {find_most_occurence_an_element.py => 9.Most_occurence.py}/__pycache__/test_find_most_occurence_of_an_element.cpython-37-PYTEST.pyc (100%) create mode 100644 9.Most_occurence.py/find_most_occurence.py create mode 100644 9.Most_occurence.py/test_Most_occurence.py delete mode 100644 Find the most occurence of an element in an array delete mode 100644 Find_occurences_of_largest_number_in_an_array/find_largest_number_occurences.py delete mode 100644 Questions.md delete mode 100644 README.md delete mode 100644 find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc delete mode 100644 find_mean_of_array_elements/find_mean_of_array_elements.py delete mode 100644 find_min_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc delete mode 100644 find_most_occurence_an_element.py/find_most_occurence_of_an_element.py diff --git a/1.FindLenght/FindLenght.py b/1.FindLenght/FindLenght.py new file mode 100644 index 0000000..ebbf543 --- /dev/null +++ b/1.FindLenght/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +array = [1,5,4,5,9] +print(count(array)) diff --git a/1.FindLenght/__pycache__/FindLenght.cpython-37.pyc b/1.FindLenght/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a39b3387b45c2c0eab77ed8bf76f42025d26e998 GIT binary patch literal 333 zcmYLE!AiqG5S`g%(D^X!<)Ce*WK}T39JZxdTruh)69M5TWI&1n3Q1Em)fpOP zz~Bcj1nN9M5>JrLQi>5UZW#4|iExE)hf7!@!IwG$+h?WDV1=*IBX@Z^7&|tClZ-Va zs>LFUCbLD=lvc7l{T|<5FBPk=-yP*rzYRY(fqyDenuwhmC223&*su!5ppZ;^l$@C#yYx15VgG@*=*ZDTd4w0y@0xxC@n1#s6plPgnEFUqDad&cG9Su-N^QerrK}- zeg=nz8~h|+Ipx3~sD#9fw}fEHW6$_`#-8_{udRi@+lSp>gpi*w7lXm>2&Q@jh7(Rx z(xG-`BZm=6MsCNW)rsHnIpfY3(y4Kmd$0zaz9W%8hr8sshZYCs^kBY#sajw-osyEM z9lWi{6)nk(4(S$|Qq913N;;#T=_jZ=g-VdoJwCZ?BuWXXx9{(aC%cg{4lb?aj}tLW;38jb|1;%(GWg=F)7&{alU`9gB-`nq-NFlZbUz;C5UkZdFbN+xt#r z4PJWv;N_EU>v4Ct`Ffb~HzFIH>8>r;2R}}2pgEqHTQ*n~J&}cQ@UI~lLS5pL4bmX8 z4&I_EJ~&vxHsuFwIK_5gBL^OQn?W;fS~F!OE!jDnI;Eq&X?EpszjXSP*D&5^GnWV2 zz4B({+*fbm+{XsWF6;m?qZ#7?uP+eVA{Zb(S_JF>QRm@T1{An_g|C*brNh$!AnK*J zpu@3rtR2rOym*eJ&XL`DfCm2;(QDRjNAz+7d1^&!yWO^w?Ez(hxaf(o7TowrPZvoV zF{H880kiiX!TXWI;C>XE@L%VR*UO7cOKh%Lk9$d)#>jRrAB__!%qp^ZS`1S?%#`ud z91zOfiPc$Nq})Q|L7JZ?X`Ce^AzjEL@e>l+h+j yZA$S$4z)1#Maa}{Vzw!A6E0ev*_=!7La9mnxZrS<^CA^bkwS%`0OT34fc*jSnh>J^ literal 0 HcmV?d00001 diff --git a/1.FindLenght/test_find_lenght.py b/1.FindLenght/test_find_lenght.py new file mode 100644 index 0000000..89aff47 --- /dev/null +++ b/1.FindLenght/test_find_lenght.py @@ -0,0 +1,13 @@ +import FindLenght + +def test_AssertTrue(): + assert True + +def test_array_retutn_5(): + #arrange + array = [1,5,2,8,9] + excepted = 5 + #act + actual = FindLenght.count(array) + #assert + assert excepted == actual \ No newline at end of file diff --git a/Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py b/10.Find_Min/FindLenght.py similarity index 100% rename from Find_occurences_of_Smallest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py rename to 10.Find_Min/FindLenght.py diff --git a/10.Find_Min/__pycache__/FindLenght.cpython-37.pyc b/10.Find_Min/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e83f05f49105fb88ebea2a3f1d3748ae08f58be GIT binary patch literal 263 zcmZ?b<>g`kf=U;gnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)c@-9{}29_~~26}Fpc`5O}nRziFhEHlD}#0F&hX)=Oogn1AaD^TthhfQvNN@-529at|&D*)vYE=2$U literal 0 HcmV?d00001 diff --git a/find_max_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/10.Find_Min/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from find_max_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 10.Find_Min/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/find_max_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc b/10.Find_Min/__pycache__/find_max_element_in_an_array.cpython-37.pyc similarity index 100% rename from find_max_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc rename to 10.Find_Min/__pycache__/find_max_element_in_an_array.cpython-37.pyc diff --git a/10.Find_Min/__pycache__/find_min.cpython-37.pyc b/10.Find_Min/__pycache__/find_min.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..749380ed00866171a5ad0d6d772d8f337edf207f GIT binary patch literal 473 zcmYjNJ5K^Z5T4n`K~6|0rLc#FppDTGW0Y7ajfI9>B!)fl0_@@5;Un3r@P}w=>EGGP z#EQRQ z6(uIYki|U4n5}SyNS&9^uC8ec24i9^#j|nJQ_}2)Acr@!@Qwwc!X^}qEF;S;vwRAs zWmzG#u)Gk87xKAfrNt>X*A}d7f)&&=*!YF8Qn7s~KR@{CGGE>*ea}#rNQj1IC%Mx=+Qz!3c+QP^-xqx{- IGZP0h0Pi;}5&!@I diff --git a/find_min_element_in_a_array/find_min_element_in_an_array.py b/10.Find_Min/find_min.py similarity index 54% rename from find_min_element_in_a_array/find_min_element_in_an_array.py rename to 10.Find_Min/find_min.py index 9042c3e..9ad5df8 100644 --- a/find_min_element_in_a_array/find_min_element_in_an_array.py +++ b/10.Find_Min/find_min.py @@ -1,8 +1,8 @@ # To find the min of dictionary values -import Finding_lenght_of_an_array_without_using_len_functin -def find_smallest_value(values): +import FindLenght +def findMin(values): - values_count = Finding_lenght_of_an_array_without_using_len_functin.count(values) + values_count = FindLenght.count(values) one = values[0] two = values[1] if (one < two): @@ -16,5 +16,5 @@ def find_smallest_value(values): i += 1 return min -values = [5,2,4,7,3,5] -print(find_smallest_value(values)) \ No newline at end of file +#values = [5,0,1,7,3,5] +#print(findMin(values)) \ No newline at end of file diff --git a/find_min_element_in_a_array/test_find_min.py b/10.Find_Min/test_find_min.py similarity index 61% rename from find_min_element_in_a_array/test_find_min.py rename to 10.Find_Min/test_find_min.py index 4f62ac7..bb4d29e 100644 --- a/find_min_element_in_a_array/test_find_min.py +++ b/10.Find_Min/test_find_min.py @@ -1,5 +1,4 @@ -import find_min_element_in_an_array - +import find_min def test_AssertTrue(): assert True @@ -8,6 +7,6 @@ def test_arrayretutn7(): values = [5,2,4,7,3,5] excepted = 2 #act - actual = find_min_element_in_an_array.find_smallest_value(values) + actual = find_min.findMin(values) #assert assert excepted == actual \ No newline at end of file diff --git a/Find_occurences_of_largest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py b/11.FindMax/FindLenght.py similarity index 100% rename from Find_occurences_of_largest_number_in_an_array/Finding_lenght_of_an_array_without_using_len_functin.py rename to 11.FindMax/FindLenght.py diff --git a/find_max_element_in_a_array/find_max_element_in_an_array.py b/11.FindMax/Max.py similarity index 54% rename from find_max_element_in_a_array/find_max_element_in_an_array.py rename to 11.FindMax/Max.py index 71d0ead..02504dd 100644 --- a/find_max_element_in_a_array/find_max_element_in_an_array.py +++ b/11.FindMax/Max.py @@ -1,8 +1,8 @@ # To find the max of dictionary values -import Finding_lenght_of_an_array_without_using_len_functin -def find_largest_value(values): +import FindLenght +def Max(values): - values_count = Finding_lenght_of_an_array_without_using_len_functin.count(values) + values_count = FindLenght.count(values) one = values[0] two = values[1] if (one > two): @@ -16,5 +16,5 @@ def find_largest_value(values): i += 1 return max -values = [5,2,4,7,3,5] -print(find_largest_value(values)) \ No newline at end of file +#values = [5,2,4,7,3,5] +#print(Max(values)) \ No newline at end of file diff --git a/11.FindMax/__pycache__/FindLenght.cpython-37.pyc b/11.FindMax/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..774c2a7380f81ec33bf134807307d87bcd43578c GIT binary patch literal 279 zcmZ?b<>g`kf~$@;F{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?^j)lC3@l^PGV@a6a}z7#Q*%;tQ}asVGxOpT;}eUD5-Vfe zfO0;mdFdG?dIgoYSiwes3@GLR5)6zijC_ndOhs%!wx1>=m`0cnVX*?`ZgJS;=BJeA Lq}qY?g0unv5k58^ literal 0 HcmV?d00001 diff --git a/find_min_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/11.FindMax/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from find_min_element_in_a_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 11.FindMax/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/11.FindMax/__pycache__/Max.cpython-37.pyc b/11.FindMax/__pycache__/Max.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4f58351813eee6c7c90b10591c35a7a269d937ae GIT binary patch literal 485 zcmYk2%}&BV5XWcsqaZ@!QQiP9hIla=VhkEj%Ef~QiA}?<*iZ^?i$bzJ;e+UrSK6y5 zUcr;IB_>WYznR(jcc$B3qfrC0$6j~1L4a>x{8>QB1$ovXC{UQd02EXF0|uysk}6OY zRaIgf44CE`HCy8vk(77P-rLe!&>zv%()=_|eo3A^5pwuM3tw0e6*i$@6d6TsndK8< zT9y?e6_yu5@j@w9>!@Hg^@AQYIqwhkLD}KDf$~{hXi0Xtd>u}1PZKSovJ#T2KBa*V7zuK sJSrZ(YzyNLN|Et@(8;-p)4cqYf2jLbwL6`uMWWCBZ8NW?g$D=t3vxka`~Uy| literal 0 HcmV?d00001 diff --git a/find_min_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc b/11.FindMax/__pycache__/find_max_element_in_an_array.cpython-37.pyc similarity index 100% rename from find_min_element_in_a_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc rename to 11.FindMax/__pycache__/find_max_element_in_an_array.cpython-37.pyc diff --git a/11.FindMax/__pycache__/test_find_max.cpython-37-PYTEST.pyc b/11.FindMax/__pycache__/test_find_max.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1a9403a9d1967d8e9b64ad4409e3197f48230f1b GIT binary patch literal 1044 zcmY*XOK%e~5VpOW%_e=&hd}h!3sUz|g-}4C29*LwdZDMNVsT@qMBPVZdrMMnBn12n z4vEACiC^R^r~HMUnDMqzu;j5l{>C$&?>k;wYZk|cXMYJHI2VJ#?g*xS21XD;6Vjz_ zWvRyqC8^)7(ds7X27(Fi2kF*@FKV!cf_@-TFo#%j(nE^_->kuW15>xa2s$Ap(R&ze z$ds03MhEl(nNY*v?3HvzzteA!cLJHJMQNyz?cimkz>3VIPh6MSe5nL^WMbiztnvP(AcN>BeXbjn0fdVMPD z=;l|nOoXDbKwLQl1H@N{fE^$jqWO~nA--4dB#z z!Unu&3Z6s^No{q(wEv^~AkyeOh#J;=&qoTMwwrN}CrONK_wsbem9(qK=6Nwl%plV? zNOC}E`!Lp@^CA%r8eb&&IZxt@r&3|D3Ts!$Kor>EiYJBCY6E?nV3q~)cv&D%mJd&z zRw@%hl-;~lB*;TaQ<&^IwnT4%A#8*CtjR)9!Y8tdTG#-3jg`migh2B4A91rjS literal 0 HcmV?d00001 diff --git a/find_min_element_in_a_array/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc b/11.FindMax/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc similarity index 100% rename from find_min_element_in_a_array/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc rename to 11.FindMax/__pycache__/test_find_max_element_in_an_array.cpython-37-PYTEST.pyc diff --git a/find_max_element_in_a_array/test_find_max.py b/11.FindMax/test_find_max.py similarity index 62% rename from find_max_element_in_a_array/test_find_max.py rename to 11.FindMax/test_find_max.py index cd79911..93c0323 100644 --- a/find_max_element_in_a_array/test_find_max.py +++ b/11.FindMax/test_find_max.py @@ -1,5 +1,5 @@ -import find_max_element_in_an_array +import Max def test_AssertTrue(): assert True @@ -9,6 +9,6 @@ def test_arrayretutn7(): values = [5,2,4,7,3,5] excepted = 7 #act - actual = find_max_element_in_an_array.find_largest_value(values) + actual = Max.Max(values) #assert assert excepted == actual \ No newline at end of file diff --git a/checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py b/12.Find_largest_number_count_value/FindLenght.py similarity index 100% rename from checking_whether_two_array_element_same_or_not/Finding_lenght_of_an_array_without_using_len_functin.py rename to 12.Find_largest_number_count_value/FindLenght.py diff --git a/Find_occurences_of_largest_number_in_an_array/find_max_element_in_an_array.py b/12.Find_largest_number_count_value/Max.py similarity index 65% rename from Find_occurences_of_largest_number_in_an_array/find_max_element_in_an_array.py rename to 12.Find_largest_number_count_value/Max.py index d8a48cb..04719a8 100644 --- a/Find_occurences_of_largest_number_in_an_array/find_max_element_in_an_array.py +++ b/12.Find_largest_number_count_value/Max.py @@ -1,8 +1,8 @@ # To find the max of dictionary values -import Finding_lenght_of_an_array_without_using_len_functin -def find_largest_value(values): +import FindLenght +def max(values): - values_count = Finding_lenght_of_an_array_without_using_len_functin.count(values) + values_count = FindLenght.count(values) one = values[0] two = values[1] if (one > two): diff --git a/12.Find_largest_number_count_value/__pycache__/FindLenght.cpython-37.pyc b/12.Find_largest_number_count_value/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5945040240cc52dc76ddd571c838ac604c56227a GIT binary patch literal 286 zcmZ?b<>g`kf~aVlnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)cW-eAS29_~~MtW|Uc`5NZiACwD#U=51rMXF|Me$(e@nwlQ zrKvF>d7sq0^o$a{g34R0U@4F}#T-C_fsuugkCBI|hz-d0(_{qG2x}lLR-oK14x8Nk Nl+v73JFs4mRseOKI1m5; literal 0 HcmV?d00001 diff --git a/Find_occurences_of_Smallest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/12.Find_largest_number_count_value/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from Find_occurences_of_Smallest_number_in_an_array/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 12.Find_largest_number_count_value/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/12.Find_largest_number_count_value/__pycache__/Max.cpython-37.pyc b/12.Find_largest_number_count_value/__pycache__/Max.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..13ced4b3ffbb5fcdf6d1a84c18251a5f55d8b948 GIT binary patch literal 423 zcmYk3y-ve05PuZ85bv+QX{_5J!4XQE^FSZH5JZ#zJGJyg;Y}2ldHp^#9P>S{KuzxUL(X@v1TvlmvWZqL4 GwD1?J;8>FY literal 0 HcmV?d00001 diff --git a/12.Find_largest_number_count_value/__pycache__/find_largest_number_count.cpython-37.pyc b/12.Find_largest_number_count_value/__pycache__/find_largest_number_count.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87333a0f110e99953459688cb6f18307f837f64f GIT binary patch literal 649 zcmZ`$v2N5r5S`hz?;Mj53JRzw!A%rs5K$CGgiygX6iDVI%XpXL6rV4QZInoR)#XEy zGQYs5Y)j=|pkiiEL=-TqnepzD}#v!AfH#~ci< z6ua)=8Xer=D!O>)w2RI(9XN3MF*rO^wC|KrFJYye4q1PD_z|4q4the!ID>>t`Sk6) zG4E_M``Y=qTJ}ws#Xc^H%1f^oQHnGl<>)~(>Djx{a4fHFZKkWs7spJ zwkw)`@!3)lfQs*B-P`Gx|K0DMU;5om<+7@J+f=p{zU>1JfDx~h*ES~XB>Gn}w3tY8 zC(9$=+{uBRVi|C)n7Yu#Nv6Gi&qPLC7Em%x(q?lY^a7(z*y62!@{f_*LT02e)$qopHXQ)JS z+uT;@0+(ox$M_zaVMXBVlz5K6;xABl29+SA+dn#QQ7O4lTMxD;)16Ri$84@{>`$hO zOBGR}>ye}*F8D;~)^i&@&a*=ya-r`;qgWhHb5ZkA{VWr77}$hEyv}7FB{?NCr*z~G zMJ^oXmCgt=-`GcF?y{P4FT6QA_2nDzgME(05VV@nGQw&sSVkxtK_KF@jQ|ZI0#^S{ z034S!*jnjYpga{oM7{KuKsgquW`E&8#|!hIg?Z`1yd=bzq}L1a`MLqG6Uwb#&*Inx z90Pt9^NHe2`!rSsO+sR@?F>M4|3ZB?l*YIlHuUD`e`pNu|HCDtJdO*&vzSX^8q~L= zm?lYNxDw~-gbJ>kh6~5VI8ozFYCp*#Lh6l3e#nc2+0f`D$&YCgWi;i&g*?LWS{TGa zUwc#tIu$pK=@y7pcI~XP>*4C*ktJFs0=T7{RT{1ek#$Xexefx67IsO41i+d1sA*WU z0oJgtgX^BfT`=g)sQN*)E6M@S+k$@*W5soSY0|YTo1KO*1uO||&XtA?dct-U?4>y? S68;SSF_1K-0Jt0A!1)8g`kf>|*(F{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?v|X%X3@l>|jrGzp^HPFy6LWI%N^_G^i=06!W88p(KB;-> z86|oJmA6>I+CiF&Ie-KMBMT!RBM(y%8<6d%$q1$qW5+=$aHr)}hnkUBW3oUovYWBJEX| z4}p?j+BTJcfr^@!|XN>o*5qc);a+TGvfC z|7>X}Gsc@o>)O%3_k)|euoqD#i>m5uQ&}ex-4hOg34b|%JD9PPth^GQVzPzJCZ6$S zvjJ=sE60^$wW1J5g$|i8n6QBIX*@Y$$YdtprgdlI=t7fV(?EjAjLOzwo3G(z?2Ou^ zbFI%s<`k*#ag~#Hh_q>kPrZ=rWk>y%1esI}=n*H9UlBT1M)Z*0(5z|ygO*l`_}TG% UVY=F$NS~8!WW1Ox&yvUZ2ma8E2><{9 literal 0 HcmV?d00001 diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc b/13.findSmallnumberCount/__pycache__/find_max_element_in_an_array.cpython-37.pyc similarity index 100% rename from Find_occurences_of_largest_number_in_an_array/__pycache__/find_max_element_in_an_array.cpython-37.pyc rename to 13.findSmallnumberCount/__pycache__/find_max_element_in_an_array.cpython-37.pyc diff --git a/13.findSmallnumberCount/__pycache__/find_min.cpython-37.pyc b/13.findSmallnumberCount/__pycache__/find_min.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..573b83c25485c131e8b197cfbd947aac1021435a GIT binary patch literal 433 zcmYjOxlRKy5S_8TtFR;$6yy)GO~g?kP=pXcR47df&}u~#;sv7Y0p48>$?o_NDESc@ z{$N|G`~nqYM@Wn{@6C8FA19qo03@IBApSytZ|nRCBjcE~+$4}7F@*>ull&DTlsJY^ zEGYt`8C5#*2|4MIw7epy;0-mrqal>o1;dCLG1pA<1*o28M&v?sBP2K8b5DC37hGLx z&|Vj`pq$alHbQ%n?St_ib}uMm=Z};fy>wuY8?q)io9FU8$#3tf#+wy&UWI<+KTgv+ zDWmp^CvHFDMV>^wdMX;8&GQE5AE4H#%TIWE7;hiMJA3^bYBtWMX`0vBb)ts0Uu-ug zRMEeGX*Qfw+LWZMCa%AIf^v%hSb#0Jd?rv}fNk>HsMaYKG9`$d?Z*BC`zcLpkQK5{ MlOubx(n1S=0cc)cs{jB1 literal 0 HcmV?d00001 diff --git a/Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc b/13.findSmallnumberCount/__pycache__/find_min_element_in_an_array.cpython-37.pyc similarity index 100% rename from Find_occurences_of_Smallest_number_in_an_array/__pycache__/find_min_element_in_an_array.cpython-37.pyc rename to 13.findSmallnumberCount/__pycache__/find_min_element_in_an_array.cpython-37.pyc diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc b/13.findSmallnumberCount/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc similarity index 100% rename from Find_occurences_of_largest_number_in_an_array/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc rename to 13.findSmallnumberCount/__pycache__/findthelargestnumberoccurencesinanarray.cpython-37.pyc diff --git a/13.findSmallnumberCount/__pycache__/test_find_min.cpython-37-PYTEST.pyc b/13.findSmallnumberCount/__pycache__/test_find_min.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85a8d01eecb1ca4e8ae139f21b4a1997809b3a89 GIT binary patch literal 1076 zcmY*Z&2AGh5VpNP*=*AQ1wlC=^@7yBL`hnZKn*Gst~t<3NUNY_yLL*{{fTU^XsQhd z;4wHf+~ARX<&;# zw+{0-*?S9hav!LwLK>|&b6c`V^1AmIkwj_SnS+Ni_&KM`+0 zr`Mg=&qv*7quyR;Jjv;C7N==mW~YoF6=g0*rm{YXvPs^V&Xiv#JK-hM&lWxigl%M_ zE!0N53D#;ZE*QFqnaeLwDAp5!S&}mcUT(oWZl*IQ6|TrRnOl`5en@gF|0ME^f{_XDAw`+=_>ti}!)5C2U*+%Z!(fN1nQ0mZ zWRd1XQe@MZGu6_VpO%wUPI95#w15bqwj=SeC{t=eqqDR)jngQPGsbPm!!>`o1}t!u z6LTKV_$}?a4Pu=|y>%Atts74ap=#m5E!C>iFj?}vuk(v75Qwy~O?=`3Wj>&mCe1c@ zgQoKS_RQ~rLp_XY;&*Ds0iQdZec}_zRCDE0jT@ht2G<1)2TjhkhBSEGbmbjn1uawd Q0{#q0XqN}n^{{9C0fy-u!2kdN literal 0 HcmV?d00001 diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc b/13.findSmallnumberCount/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc similarity index 100% rename from Find_occurences_of_largest_number_in_an_array/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc rename to 13.findSmallnumberCount/__pycache__/test_find_occurences_of_max_element.cpython-37-PYTEST.pyc diff --git a/Find_occurences_of_largest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc b/13.findSmallnumberCount/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc similarity index 100% rename from Find_occurences_of_largest_number_in_an_array/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc rename to 13.findSmallnumberCount/__pycache__/test_max_numbers_occurences.cpython-37-PYTEST.pyc diff --git a/Find_occurences_of_Smallest_number_in_an_array/find_smallest_number_occurences.py b/13.findSmallnumberCount/findSmallestNumberCount.py similarity index 51% rename from Find_occurences_of_Smallest_number_in_an_array/find_smallest_number_occurences.py rename to 13.findSmallnumberCount/findSmallestNumberCount.py index 365a54a..ece425b 100644 --- a/Find_occurences_of_Smallest_number_in_an_array/find_smallest_number_occurences.py +++ b/13.findSmallnumberCount/findSmallestNumberCount.py @@ -1,20 +1,20 @@ #12. Given an unsorted integer array A, # find the number of times the smallest number is found in the array. -import find_min_element_in_an_array -import Finding_lenght_of_an_array_without_using_len_functin +import find_min +import FindLenght def count_occuences(array,min): count = 0 i = 0 - lenght = Finding_lenght_of_an_array_without_using_len_functin.count(array) + lenght = FindLenght.count(array) while (i!=lenght): if (array[i]==min): count += 1 i += 1 return count -def find_largest_numbers_occurences(array): - min = find_min_element_in_an_array.find_smallest_value(array) +def find_Smallest_numbers_occurences(array): + min = find_min.find_smallest_value(array) count = count_occuences(array,min) return count array = [3,8,3,7,9] -print(find_largest_numbers_occurences(array)) +print(find_Smallest_numbers_occurences(array)) diff --git a/Find_occurences_of_Smallest_number_in_an_array/find_min_element_in_an_array.py b/13.findSmallnumberCount/find_min.py similarity index 71% rename from Find_occurences_of_Smallest_number_in_an_array/find_min_element_in_an_array.py rename to 13.findSmallnumberCount/find_min.py index 4b573c1..a2a5f9a 100644 --- a/Find_occurences_of_Smallest_number_in_an_array/find_min_element_in_an_array.py +++ b/13.findSmallnumberCount/find_min.py @@ -1,8 +1,8 @@ # To find the min of dictionary values -import Finding_lenght_of_an_array_without_using_len_functin +import FindLenght def find_smallest_value(values): - values_count = Finding_lenght_of_an_array_without_using_len_functin.count(values) + values_count = FindLenght.count(values) one = values[0] two = values[1] if (one < two): diff --git a/Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py b/13.findSmallnumberCount/test_find_min.py similarity index 54% rename from Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py rename to 13.findSmallnumberCount/test_find_min.py index f242d69..e7f1a5b 100644 --- a/Find_occurences_of_largest_number_in_an_array/test_max_numbers_occurences.py +++ b/13.findSmallnumberCount/test_find_min.py @@ -1,4 +1,4 @@ -import findthelargestnumberoccurencesinanarray +import findSmallestNumberCount def assertTrue(): assert True @@ -7,7 +7,7 @@ def arrayreturn2(): array = [3,9,2,7,9] excepted = 2 #act - actual = findthelargestnumberoccurencesinanarray.find_largest_numbers_occurences(array) + actual = findSmallestNumberCount.find_Smallest_numbers_occurences(array) #assert assert excepted == actual \ No newline at end of file diff --git a/find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py b/14.print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py similarity index 100% rename from find_mean_of_array_elements/Finding_lenght_of_an_array_without_using_len_functin.py rename to 14.print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py diff --git a/print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/14.print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 14.print_array_index_with_numbers_in_it/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/print_array_index_with_numbers_in_it/printing_array_index_with_number.py b/14.print_array_index_with_numbers_in_it/printing_array_index_with_number.py similarity index 100% rename from print_array_index_with_numbers_in_it/printing_array_index_with_number.py rename to 14.print_array_index_with_numbers_in_it/printing_array_index_with_number.py diff --git a/checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py b/15.Compare_Two_Array_Elements/Compare_Two_Array_Elements.py similarity index 63% rename from checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py rename to 15.Compare_Two_Array_Elements/Compare_Two_Array_Elements.py index 9134c91..472ec94 100644 --- a/checking_whether_two_array_element_same_or_not/check_whether_two_array_elements_same_or_not.py +++ b/15.Compare_Two_Array_Elements/Compare_Two_Array_Elements.py @@ -1,12 +1,12 @@ #15. Write a function that takes two unsorted integer arrays as input and # returns True if the two arrays are the same. -import Finding_lenght_of_an_array_without_using_len_functin -def check_array_elements(array1,array2): +import FindLenght +def compareArrayElements(array1,array2): index = 0 flag = False check = 0 - lenght_of_array1 = Finding_lenght_of_an_array_without_using_len_functin.count(array1) - lenght_of_array2 = Finding_lenght_of_an_array_without_using_len_functin.count(array2) + lenght_of_array1 = FindLenght.count(array1) + lenght_of_array2 = FindLenght.count(array2) if (lenght_of_array1 == lenght_of_array2): lenght = lenght_of_array1 while(index!=lenght): @@ -25,4 +25,4 @@ def check_array_elements(array1,array2): array1 = [2,8,1,4,5,2] array2 = [2,9,1,4,5] -print(check_array_elements(array1,array2)) \ No newline at end of file +print(compareArrayElements(array1,array2)) \ No newline at end of file diff --git a/find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py b/15.Compare_Two_Array_Elements/FindLenght.py similarity index 100% rename from find_min_element_in_a_array/Finding_lenght_of_an_array_without_using_len_functin.py rename to 15.Compare_Two_Array_Elements/FindLenght.py diff --git a/15.Compare_Two_Array_Elements/__pycache__/FindLenght.cpython-37.pyc b/15.Compare_Two_Array_Elements/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ea25464d7648c90b816d11b934348271004e95fd GIT binary patch literal 275 zcmZ?b<>g`kf*lSvF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?v|X%X3@l>|P4%4fa|;rSQsYC)^W$A}Qgc)DN{VCLGV@Y= zQuER?O7sdUZ?S^4gESX&00{<07Dhfs9;PBTAlpxq5lkb@hOk(Ha<@2aa`RJ4b5iZV HdO=zNZs;?K literal 0 HcmV?d00001 diff --git a/checking_whether_two_array_element_same_or_not/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/15.Compare_Two_Array_Elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from checking_whether_two_array_element_same_or_not/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 15.Compare_Two_Array_Elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/checking_whether_two_array_element_same_or_not/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc b/15.Compare_Two_Array_Elements/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc similarity index 100% rename from checking_whether_two_array_element_same_or_not/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc rename to 15.Compare_Two_Array_Elements/__pycache__/check_whether_two_array_elements_same_or_not.cpython-37.pyc diff --git a/checking_whether_two_array_element_same_or_not/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc b/15.Compare_Two_Array_Elements/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc similarity index 100% rename from checking_whether_two_array_element_same_or_not/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc rename to 15.Compare_Two_Array_Elements/__pycache__/test_check_two_array_values.cpython-37-PYTEST.pyc diff --git a/checking_whether_two_array_element_same_or_not/test_check_two_array_values.py b/15.Compare_Two_Array_Elements/test_check_two_array_values.py similarity index 62% rename from checking_whether_two_array_element_same_or_not/test_check_two_array_values.py rename to 15.Compare_Two_Array_Elements/test_check_two_array_values.py index bb9828d..ddab0c9 100644 --- a/checking_whether_two_array_element_same_or_not/test_check_two_array_values.py +++ b/15.Compare_Two_Array_Elements/test_check_two_array_values.py @@ -1,4 +1,4 @@ -import check_whether_two_array_elements_same_or_not +import Compare_Two_Array_Elements def assertTrue(): assert True @@ -9,7 +9,7 @@ def test_array1_array2retutnFalse(): array2 = [2,9,1,4,5] excepted = False #act - actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2) #assert assert excepted == actual @@ -20,7 +20,7 @@ def test_array1_array2retutnTrue(): array2 = [2,9,1,4,5] excepted = True #act - actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2) #assert assert excepted == actual @@ -31,6 +31,6 @@ def test_array1_array2retutn1False(): array2 = [2,9,1,4,5] excepted = False #act - actual = check_whether_two_array_elements_same_or_not.check_array_elements(array1,array2) + actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2) #assert assert excepted == actual \ No newline at end of file diff --git a/return_a_copy_of_an_array/return_a_copy_of_an_array.py b/16.return_a_copy_of_an_array/return_a_copy_of_an_array.py similarity index 100% rename from return_a_copy_of_an_array/return_a_copy_of_an_array.py rename to 16.return_a_copy_of_an_array/return_a_copy_of_an_array.py diff --git a/return_a_copy_of_an_array/test_return_copy_of_an_array.py b/16.return_a_copy_of_an_array/test_return_copy_of_an_array.py similarity index 100% rename from return_a_copy_of_an_array/test_return_copy_of_an_array.py rename to 16.return_a_copy_of_an_array/test_return_copy_of_an_array.py diff --git a/print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py b/17.reverseArrayElements/FindLenght.py similarity index 100% rename from print_array_index_with_numbers_in_it/Finding_lenght_of_an_array_without_using_len_functin.py rename to 17.reverseArrayElements/FindLenght.py diff --git a/17.reverseArrayElements/__pycache__/FindLenght.cpython-37.pyc b/17.reverseArrayElements/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..adc89d254905a3813a97f46a71d60f9ebd162e52 GIT binary patch literal 275 zcmZ?b<>g`kf|YSLF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?v|X%X3@l>|&Gm{>%TkMqQyq(n5-VMEQgc)DN{VCLGV@Y= zQuER?O7sdUZ?S^4gESX&00{<07Dhfs9;PBTAlpxq5lkb@hOk(Ha<@2aa`RJ4b5iZV HdO=zNm}E27 literal 0 HcmV?d00001 diff --git a/17.reverseArrayElements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/17.reverseArrayElements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..64468e0ea75c1ffae75023d6d56f7afe2c294cb3 GIT binary patch literal 343 zcmYLDJxc>Y5S`hWBS>PcU~$-8BX$xI5f#fc7D6~!j@!N5Lfnn}p#~DL&>v#yZ}A^o zYn8uXC%7Sz0D&(s1;K8h=+#KA7}3)s zToT*?k-#-R?XF;j0$$l3*nLv$7}j{7-BLGhPc~$PO}z0A1?#YyX0-|0D;sYm`Z8B1 z<SS+%&w>JbC$} z@~sJ;2ls2>P0+Ph`f#!A`ss!EfEy42Zs86NnaxN~3QYO`zaQ17SvNSnGa}68S=x=O E-&>1MUjP6A literal 0 HcmV?d00001 diff --git a/17.reverseArrayElements/__pycache__/prints_the_contents_of_the_array_in_reverse_order.cpython-37.pyc b/17.reverseArrayElements/__pycache__/prints_the_contents_of_the_array_in_reverse_order.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..788e3b37c5bec84f7969abb2e0a96fccd81d2cc8 GIT binary patch literal 612 zcmaJIr%SeX=gS@>ZvQu%+C6~nK$13(CcjguRnvM@pb_4B+1K)cyr2Dyk$o~xPTE* zK;aJI@rc^KIwKX2xY^mbkf2&U53m zaY>%~bYkt~G099~^%rdmo#d9ZO{_2nVZD2i8DgqhXfvBTm8WWAlqadLnVaXOQ)STt zR9c!TH>#s)UK&?NchZ=vM4nJ%HtMbFd`i!x?{Ba%_jz7?JRHA27<+i(WldKqi~q}P z8H(ppFAR|=`ATDER6CgRgT1?Zthd{f_D|&Lnel2mET!nP1MJ`i#%z7uLMyMJ;RgU# qTq9TCtc#P&8-!MZ2iY~*$wdFSE~j;Te4A6b&?kZ|1Quf)_wg^U{+<2+ literal 0 HcmV?d00001 diff --git a/17.reverseArrayElements/__pycache__/test_prints the contents of the array in reverse order.cpython-37-PYTEST.pyc b/17.reverseArrayElements/__pycache__/test_prints the contents of the array in reverse order.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..82123333fa27bd580c792ccd151cb55267866695 GIT binary patch literal 623 zcmb7AJx{|h5IrYpn-(Y%NJwm1kSIu1%f^RL`C3`%6jibUaYdvy31=4wY8T*#z{p?n z%EVt_;_Q@)6-)Q*XZ!BnyVI4G#_rDHKmfoe#bP;h>QTrxK@2e)LCEaxj9mv9jJ>eJ z%9m59Zbc`{!=rOQlJX9w)3LflG-(!ryISzP(msmp{{co4F!rEb@RmjPO|g@ zF+;u1hZ&9|#l>Sjiqc5YOUntDD4UmsJ0&TFa2yU`e z2}81>(dlJdDn fZarERc1(Z3r&`)S8fWojB#s#|StamEx9|J_<1w?L literal 0 HcmV?d00001 diff --git a/17.reverseArrayElements/reverse_Array_elements.py b/17.reverseArrayElements/reverse_Array_elements.py new file mode 100644 index 0000000..057ff79 --- /dev/null +++ b/17.reverseArrayElements/reverse_Array_elements.py @@ -0,0 +1,13 @@ +#17. Write a function that takes an unsorted integer +# array as input and prints the contents of the array in reverse order. +import FindLenght +def reverseContentofAnArray(array): + i = 1 + lenghtOfArray = FindLenght.count(array) + print("Printing the Content of the array in reverse order ") + while (i!=lenghtOfArray): + print(array[-i]) + i += 1 + print(array[0]) +array = [2,1,5,7,3] +reverseContentofAnArray(array) \ No newline at end of file diff --git a/18.returns_array_in_reverse_order/FindLenght.py b/18.returns_array_in_reverse_order/FindLenght.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/18.returns_array_in_reverse_order/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/18.returns_array_in_reverse_order/__pycache__/FindLenght.cpython-37.pyc b/18.returns_array_in_reverse_order/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..50df1293f7c0461e5f25b5796eea6fdb68077bb3 GIT binary patch literal 285 zcmZ?b<>g`kf+dMIF{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?OkJ#E3@l>|E%b^~OG=CKisKWDiV`d1GxOq$Qp-|{ic{nB zi&9dHV%#$GQhZYL(lbi*3My~0f(-&0Q_KM*7#LX?`51Yair9c`KTSq3jj#p6Vg<_G S;;_lhPbtkwwFBz~X$1hJTsTAk literal 0 HcmV?d00001 diff --git a/18.returns_array_in_reverse_order/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/18.returns_array_in_reverse_order/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a2f59d10783bc2ae1e3a003065172418d2ac2b0b GIT binary patch literal 324 zcmYLD!Ab)$5S>ZwQl#~);K|!w#G6z^M8#t-9)uDI%O-6DHPK0;7FzJ2AL7w(@elUu zslVXK$y#yXy?L2=Gn0$KU>i7I-iPv&^H+ZSg7Cwro#y7Ooz0^^M50M{ literal 0 HcmV?d00001 diff --git a/18.returns_array_in_reverse_order/return_array_in_reverse_order.py b/18.returns_array_in_reverse_order/return_array_in_reverse_order.py new file mode 100644 index 0000000..8fa61ee --- /dev/null +++ b/18.returns_array_in_reverse_order/return_array_in_reverse_order.py @@ -0,0 +1,17 @@ +#18. Write a function that takes an unsorted + #integer array as input and returns an array with the values in reverse order. +import FindLenght +def returnContentInReverseOrder(array): + ReversedArray = [] + i = 1 + lenght = FindLenght.count(array) + while (i!=lenght): + ReversedArray.append(array[-i]) + i += 1 + ReversedArray.append(array[0]) + + return ReversedArray + +array = [3,1,6,3,8,9] +print("The Reversed Array is") +print(returnContentInReverseOrder(array)) \ No newline at end of file diff --git a/19.return_index_upto_same_array/return_index.py b/19.return_index_upto_same_array/return_index.py new file mode 100644 index 0000000..a96f507 --- /dev/null +++ b/19.return_index_upto_same_array/return_index.py @@ -0,0 +1,23 @@ + +def array12(array1,i): + return array1[i] + +def array13(array2,i): + return array2[i] + + +def return_index(array1,array2): + flag = True + i = 0 + while (flag): + if ((array12(array1,i)) == (array13(array2,i))): + print (i) + i += 1 + flag = True + else: + flag = False + return -1 + +array1 = [1,4,2,6,0] +array2 = [7,5,2,8,5] +print(return_index(array1,array2)) diff --git a/19.return_index_upto_same_array/test_return_index.py b/19.return_index_upto_same_array/test_return_index.py new file mode 100644 index 0000000..e69de29 diff --git a/2.iscontains/__pycache__/isContain.cpython-37.pyc b/2.iscontains/__pycache__/isContain.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1780232936bfd822fca7018a3eb2ca2b744e4e5b GIT binary patch literal 371 zcmYLF!AiqG5S`gg(pXyYiGQ;Gxc@n)Gf^VpkyzYARH*C4$@fFIZFDqwNVFfkJW;U^?Of+Tt5Q$S)GBuF9= zN-9vO#9FKofjajPg}GppD~}-=LxwqF`Z%g#1W$*JAZ%nUYJ3%%w>9z(-hxM{CHv+0 z_Td{M&-$6x*~;!4mFfKDS(R$0s-?xkdXqAnY7Px8{T`3b)6+qE78fR;SIexZOj?-X zR>q5!?M;e`b{kwg(_;ecqK6?PK;7YfaxA$p2F~eulxajcuBSZ literal 0 HcmV?d00001 diff --git a/2.iscontains/__pycache__/test_isContain.cpython-37-PYTEST.pyc b/2.iscontains/__pycache__/test_isContain.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..625b87c144acbe061672ef79e46f7d125fff5054 GIT binary patch literal 1076 zcmY*X!EO^V5VgI|W;adK(jruD6#}VysnXCQff^_jIQG(>R*@DrcG^`pyOHgPrrKNp z@f94JBOLi0UpeI$dSdJ?QLyB(J$@d~%zN)vR~sMS9QK}Ig#MtVL12FbQ@sGg5yu&d zv0KT|BM74*jcd5N@nfG8?tMdXol{WB*V#=~zsNO9bJcU-rRumk?~W#B&AF;C&*WHmw$cU|gejtE1GSJ0;k0Op zjcuoE$#2+jY@1=*$nk{_W#cL4{?xVu+5-(CQ?DeYcSWYOr0SO@w;r#Tbbxta{R1+i zJk<2IHbYmwis9Zb$qY*lySm-wgonJbK$H&Q0phzuzzz@%zVd?r5jEcAt7XlR;_Cnq zVd*bOp^lW+$=udCx75yUF>_m@1Vy2<2;Y%zH^Mg?macZBw!2-&TnCs7#C2bcwBW{P zeLZGbL@b-_7)<9sp7$eVo%>P4go}p9%|V*;L}X$paxHBR=0VbDS(aGp`^9j?q%ciO z?fE#(G;n78tN?^ETZy_X#u<0eDKndZbm;|$!-9`9 Q@!ImJtSbQh1|*<=0jf6`umAu6 literal 0 HcmV?d00001 diff --git a/Check whether the given element is present or not b/2.iscontains/isContain.py similarity index 85% rename from Check whether the given element is present or not rename to 2.iscontains/isContain.py index 8fb0bad..c82ef22 100644 --- a/Check whether the given element is present or not +++ b/2.iscontains/isContain.py @@ -9,4 +9,4 @@ def find_element(array,search_element): array = [3,5,7,9,0,3] search_element = 3 -print(find_element(array,search_element)) +print(find_element(array,search_element)) diff --git a/2.iscontains/test_isContain.py b/2.iscontains/test_isContain.py new file mode 100644 index 0000000..f2b616d --- /dev/null +++ b/2.iscontains/test_isContain.py @@ -0,0 +1,15 @@ +import isContain + +def test_AssertTrue(): + assert True + + +def test_array_retutn_5(): + #arrange + array = [3,5,7,9,0,3] + Search_element = 3 + excepted = True + #act + actual = isContain.find_element(array,Search_element) + #assert + assert excepted == actual \ No newline at end of file diff --git a/20.RemoveDuplicates/__pycache__/removeDuplicates.cpython-37.pyc b/20.RemoveDuplicates/__pycache__/removeDuplicates.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e425f0dd0ed75caded512ab24b204445c6672094 GIT binary patch literal 437 zcmZ9J&q~8U5XNUViA`H8#e?D_M6i_Jlp<1l@YI7MLWxMsF0wRj>SiMbl2g6<4tn&J z_Ub9G;K|uQL7ZiN`|U97w|^$RUI!>9@8j?m0lw{G8*LI7l-Yp5f#Vy@fiv!KmwSAN zREuW+sXa%*1PI*FK;Z2g2s$zC)`Uy6c}baF5hPT|v0|^I5~gr}TsfRotaM6T?5JUh zrE^3shhWthp7%<&Rd=AN`hlOYLGo~BHEjpAbqbhq6Pan_E<}+9uJIzJqQW3IUYzDD zZBTxJvRC>!nVyBi({MB#T#IG;BBuE|k#VF&7OH=R!MZU0$6O}*fy-FSbQP(>`el6r zpi84e>Ek}zMb)KR-LhZ=WgC@MwP#_?Yo9O+oTgRTvhmhRu5@#>Kd|3o{P8m7c_Pjm LOZ$p`_W*wZpXytJ literal 0 HcmV?d00001 diff --git a/20.RemoveDuplicates/__pycache__/test_removeDuplicates.cpython-37-PYTEST.pyc b/20.RemoveDuplicates/__pycache__/test_removeDuplicates.cpython-37-PYTEST.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a2a03a0706f5a4064e62d3381d7476b08c89c9dc GIT binary patch literal 1109 zcmZ8gF>ezw6t;br%O!2oHlPTYx>WR*C=CS()Sv=o?EsykNXIpH+EXvNlkGrLT^3+s zU}9uwM*aaKzr!n2{z50-^OX>KlAoVHKfhc z!f8Uf)Xr?^Fha@D?Urb<<8?jGxbvBG%iQH9n0-#)lE9n8S#s1ziy!7J!FUBjwZL#X zB{@+$cv_Pynv)rgX@g9uX0Ud0I-{THN2oi6N|4b#I=-w$N(rgAws*40ZlH{VlWVF6 z*+dJa!$_J+sG@<8B9o@}!bZpG=(UuoG$?AfaF7TU}vX1%zNy}+>?3kTm_1w*Jy zTv8`BA}g?3G{}Pm0=7ZFz~K~IgG~j`gSmWKfmZxOJwVFPuAAmfSx$3y&ZbW8sGpi$ zIo!{k0p%6M2W;l@s&=nRGji^!GuZdA#ZrP-MsLJ;m9H!!zSsx`5#MYCco4C|SHCkL z$>nRjmb;d)lJ+5@l9v{QIhL^XqdB&3j?_!g7@1pxDwyL-=RTN#Ub9XopqF*zv=ykW zPRG*Q26}yQ(HEH(+;~x6kE0}DNO`LZrv0B7_5y|AUQjg~x9R9^oQ&f{hdk~h96l0t+s_d<1+juUP}!_y=^iIQ*>4TW?ekHiN_ zq%ZJHDUvdp$W4UmV3x(TyDY9p%ZtZWXNAG0n8uBoAr}t?wSZOSxFfCyXT4z<} zgOuKpRTR?$K!b|$|K46U05JE%;?HOn`iAE>rT8FYElgzrneq*0`y%hcL90!hbLncx YrnL9-_lGGTC*nCWsu1!)(mwN@KM=DcV*mgE literal 0 HcmV?d00001 diff --git a/20.RemoveDuplicates/removeDuplicates.py b/20.RemoveDuplicates/removeDuplicates.py new file mode 100644 index 0000000..7dcb134 --- /dev/null +++ b/20.RemoveDuplicates/removeDuplicates.py @@ -0,0 +1,13 @@ +def built_dictionary(array): # To Built a dictionary + d = {} #creating a empty dictionary + count = 0 + for i in array: + count = 1 + if i in d: + d[i] = d[i] + 1 + else: + d[i] = count + return list(d.keys()) + +array = [7,2,0,1,5,7,9,1,8] +print(built_dictionary(array)) diff --git a/20.RemoveDuplicates/test_removeDuplicates.py b/20.RemoveDuplicates/test_removeDuplicates.py new file mode 100644 index 0000000..5dba3d8 --- /dev/null +++ b/20.RemoveDuplicates/test_removeDuplicates.py @@ -0,0 +1,13 @@ +import removeDuplicates + +def test_assertTrue(): + assert True + +def test_array_return_list(): + #arrange + array = [7,2,0,1,5,7,9,1,8] + excepted = [7, 2, 0, 1, 5, 9, 8] + #act + actual = removeDuplicates.built_dictionary(array) + #assert + assert excepted == actual diff --git a/21.returnOddNumbers/returnOddnumbers.py b/21.returnOddNumbers/returnOddnumbers.py new file mode 100644 index 0000000..27abcd7 --- /dev/null +++ b/21.returnOddNumbers/returnOddnumbers.py @@ -0,0 +1,11 @@ +#21. Given an unsorted integer array as input, return the number of odd numbers in it. + +def returnOddnumbers(array): + odd = [] + for i in array: + if i%2 == 1: + odd.append(i) + return odd + +array = [5,3.2,33,2,2,7,4,9] +print (returnOddnumbers(array)) \ No newline at end of file diff --git a/22.returnEvenNumbers/returnEvennumbers.py b/22.returnEvenNumbers/returnEvennumbers.py new file mode 100644 index 0000000..857073b --- /dev/null +++ b/22.returnEvenNumbers/returnEvennumbers.py @@ -0,0 +1,12 @@ +#22. Given an unsorted integer array as input, return the number of even numbers in it. + + +def returnEvennumbers(array): + even = [] + for i in array: + if i%2 == 0: + even.append(i) + return even + +array = [12,34,54,67,34,98,12,90,2,4] +print(returnEvennumbers(array)) diff --git a/23.Prime_numbers/IsPrime.py b/23.Prime_numbers/IsPrime.py new file mode 100644 index 0000000..677556e --- /dev/null +++ b/23.Prime_numbers/IsPrime.py @@ -0,0 +1,22 @@ +#to Check given number is prime or not +import math +def Isprime(N): + Flag = True + #print N + if(N <= 1): + return False + if (N==2): + return True + else: + for i in range(2,int(math.sqrt(N)+1)): #change in while loop + if (N%i == 0): + Flag = False + + return Flag + + + +#N = int(input("Enter the number")) +#(primenumbers(N)) +print (Isprime(4)) +#print (range(2,3)) \ No newline at end of file diff --git a/23.Prime_numbers/__pycache__/IsPrime.cpython-37.pyc b/23.Prime_numbers/__pycache__/IsPrime.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d530c553d1e8c57fed9050b993ff7fc08eb0d9a GIT binary patch literal 400 zcmYjN%}T>S5T4oH)c8}7B6<#dde$!ayB41@O{kRH?y3jw}e@MoNyGlJeHk|1#k5lANaD@2&E z1f^Kw5|Jtc2)vTIAbg-Hl{s~da6!;lL=p?kNk2igDfs}%7Zav-o%*?DC^Bf+8_(e# zCEEd-&AM>ARj?d#whhvw?zZFw&f7PTyPdW0x^(+`B_meO4TSa7FdHS7k27OMIy8@w z&~s%1ZZV8RZ#o=V9DjgXrS_kL?n&G_jt`HTmuj3QciAGnPn3@Px{8~#7rWBeGgosL z=>`#?U_J^Yusz&BpQ&}qmVzkY%3WP0tVg=cREz$R`*G`c(kHo?Ca3P@+9`eX8^4cg BP(A two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +#values = [5,2,4,7,3,5] +#print(Max(values)) \ No newline at end of file diff --git a/25.2ndLargestNumber/__pycache__/FindLenght.cpython-37.pyc b/25.2ndLargestNumber/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..14cd7927fb73dff058e8abfa400eff2c6a064ffa GIT binary patch literal 271 zcmZ?b<>g`kf~$@;F{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?)LpD%3@l@eO!bWNQhXAN(o>5|{7Q3^Qj22TGJztgdFdG? zdIgoYSixFB8jCrA1Op=rBOfCVQxO}G?Wf5IrV-{sSgb&~TO2mI`6;D2sdiw!Aguso CpE2hE literal 0 HcmV?d00001 diff --git a/25.2ndLargestNumber/__pycache__/Max.cpython-37.pyc b/25.2ndLargestNumber/__pycache__/Max.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..623f0173240f9b323523a25a864c1ebc2b6dbe1f GIT binary patch literal 408 zcmYk2u};G<5Qgt;Cn}-c80f~>EETGR5U4^35EEo!07Vff)KRJ0Cg3DcBzxmQU_^}U zJcw7Oz5)~HR7jk4-+%Vmceal@odC!_zlO;N0(`s4pD_v!$;%Cb1c@_F zl?Lr~K?~XwtzsjzC)q9-?_qFB8P`8juJy8kyKcyAa5~B5S(cCQD(j7kIxym~4upQj6plXp;SROM&uWIx&7O9ngr0o6*?I4i5Dp5JCFIZqe; z`)A8Z-Al_&0me{g?qTf=!F>sfZ-9#A^8@E7nm BR0se7 literal 0 HcmV?d00001 diff --git a/25.2ndSmallestNumber/2ndSmallestNumber.py b/25.2ndSmallestNumber/2ndSmallestNumber.py new file mode 100644 index 0000000..289f43f --- /dev/null +++ b/25.2ndSmallestNumber/2ndSmallestNumber.py @@ -0,0 +1,13 @@ +import find_min + +def secondsmallestNumber(array): + v = find_min.findMin(array) + for i in array: + if v == i: + array.remove(i) + maxi = find_min.findMin(array) + + return maxi + +array = [3,1,6,9,3] +print(secondsmallestNumber(array)) \ No newline at end of file diff --git a/25.2ndSmallestNumber/FindLenght.py b/25.2ndSmallestNumber/FindLenght.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/25.2ndSmallestNumber/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/25.2ndSmallestNumber/__pycache__/FindLenght.cpython-37.pyc b/25.2ndSmallestNumber/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e389794b35e0f6af909b581df24a592a00d8200e GIT binary patch literal 272 zcmZ?b<>g`kf=U;gnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)c8ZK5b29_~Krg}zsDZ#mkIXS7tC4Qy3NvTCKZkc&0KB;-> z86|oJmA6>IdOxn`QrA@6He3netKh2*vM)Yq2A zInOUNXsZWWP>sLzYoRU4cA&QIhv$?r^Zne6UbHaR^;qMc#7dq<>gKj=tXWp6(z6@; zVVYD?5p-9H-MHiHg#%(yJ&B zuc`fn$_IDP&58-mVrAZ3Y!HCC=(Njb0tLF*p{RrT8s$8e3o@ two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +#values = [5,2,4,7,3,5] +#print(Max(values)) \ No newline at end of file diff --git a/26.Find_kth_Largest_ele/__pycache__/FindLenght.cpython-37.pyc b/26.Find_kth_Largest_ele/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d9112facf28ce690d889fa6d34850f563a766f6f GIT binary patch literal 275 zcmZ?b<>g`kf~$@;F{gp_V-N=hn1BoiATH(s5-AKRj4cdN3@J>(44TZzj6fj}0I6XH zVrL*ORss?!jJ1pv5;Y7pj42GQOp**mGC&rSIYTXDAzL_56r|hlB~T&5OOP2W88n%0 zF(yW_CFhssm1Guy%mNd?v|X%X3@l@e%=Fwc^HSooOEThp5{uGPi%a5Db5dhKfGnxPZ literal 0 HcmV?d00001 diff --git a/26.Find_kth_Largest_ele/__pycache__/Max.cpython-37.pyc b/26.Find_kth_Largest_ele/__pycache__/Max.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..536272ff3a91cf838b4e6995ba0433e64b4f0094 GIT binary patch literal 412 zcmYk2u};G<5Qgt;Ckmn680gN>EEVbi0#yhBVk%u2Kv6^#)mB?IO(033NY2JHFvEy= z242J~Q(u9Jb1Edxy6->x>^s|M?Y0kOuU~`c69K;MnrS{4MOU+0WJ2>=NM1Xuu68ue zd2y>jI~~x1_KY@hEwm%qA=J)8|AsQQ|ERF7*A47-17`foStf@nn@lU?jPqqy1+H-) zlXR)du(i>+Sr2)hsgPGsx#5dsWpMTZ#THfh*}FK7_K%|eLC+S8=hZYGCdEXRRjg7K zT_vmD{j=eu_O<0M0ho_oGh8N6ppPw@wXoQxT)+xJ(!@=Nf3W{=yul)u%T%4%N0b&G F{sNG=Rh<9; literal 0 HcmV?d00001 diff --git a/26.Find_kth_Largest_ele/__pycache__/find_min.cpython-37.pyc b/26.Find_kth_Largest_ele/__pycache__/find_min.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..989c7872df1a24235228384b0b8e8f3783e08221 GIT binary patch literal 421 zcmYjMy-ve05WcgWP(>*d1AT*LsZa+Hs6q%3Q|ZD0sv@GQHf_{20Vm~0ayAy;0!C&Y zfcNmq)K_5Q9E8MK_kDNw`R?rFb~^yFm(M}`fdF4F`7=hr5qY^qAVFdVV~|YpXBeZz z3y8#;6c|mZvoW8Llb?{6*8~;3qJcN82_<%*X2gt`8)o*C zaD8RKcpWf;?u>rpS{P5VJ*d6A{v|1H|46&l>jvC&BW8oMG?zn_&*qi&ro}3+BH#M= zlWe6*8~$?A)GaS^WqI{bSiVeii|IS)kfwY`rw8%Qe%#;fxnaqonkU1Fo~g1*RHot^ zSEP>K?UUVb$$6T)Z1E*SA>i_@% literal 0 HcmV?d00001 diff --git a/26.Find_kth_Largest_ele/find_kth_Largest_ele.py b/26.Find_kth_Largest_ele/find_kth_Largest_ele.py new file mode 100644 index 0000000..4768b01 --- /dev/null +++ b/26.Find_kth_Largest_ele/find_kth_Largest_ele.py @@ -0,0 +1,24 @@ +import Max +import FindLenght +import find_min +def kth_largest_ele(array,kthele): + lenght = FindLenght.count(array) + if (lenght == kthele): + return find_min.findMin(array) + else: + + iterator = 1 + while(iterator!=kthele): + Largest_ele = Max.Max(array) + for j in array: + if (j == Largest_ele): + array.remove(Largest_ele) + iterator += 1 + Largest_ele = Max.Max(array) + return Largest_ele + +array = [5,1,9,7,2,8,3,6,4] +kthele = 1 +#print() +v = kth_largest_ele(array,kthele) +print("The {0} Largest Element in the array is {1}".format(kthele,v)) \ No newline at end of file diff --git a/26.Find_kth_Largest_ele/find_min.py b/26.Find_kth_Largest_ele/find_min.py new file mode 100644 index 0000000..9ad5df8 --- /dev/null +++ b/26.Find_kth_Largest_ele/find_min.py @@ -0,0 +1,20 @@ + # To find the min of dictionary values +import FindLenght +def findMin(values): + + values_count = FindLenght.count(values) + one = values[0] + two = values[1] + if (one < two): + min = one + else: + min = two + i = 2 + while(i!=values_count): + if (values[i] two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +#values = [5,2,4,7,3,5] +#print(Max(values)) \ No newline at end of file diff --git a/26.Find_kth_smallest_ele/__pycache__/FindLenght.cpython-37.pyc b/26.Find_kth_smallest_ele/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..71f0b3d3d1494826b4e433d589d02b8c2f6ea39a GIT binary patch literal 276 zcmZ?b<>g`kf=U;gnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)cIxbc*29_~KW_oU!c`5PPB^mL>xrsSBsl_GnsX3`JAW@&x zy!4C`y@JYHtYG~h-NhV0f`O5Rk&lswsfZ28_S0kp(+I;MELNc0Ee@O9{FKt1R6DR< GkX8VNz%$hV literal 0 HcmV?d00001 diff --git a/26.Find_kth_smallest_ele/__pycache__/Max.cpython-37.pyc b/26.Find_kth_smallest_ele/__pycache__/Max.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9cd584d35b16481213f1d078d8f26da7ec3a6388 GIT binary patch literal 413 zcmYk1u};G<5Qgt;C#s^9iGe-y3*=UPZq3 zpVDlhv<)|!H2anpxw5=^E-as?ON-MFC`0PG!H1YiNSn&mTr0s{;w3$fgyTEt30(!|Y(e`r&|wg&S;E;4oOexV&& F_zMr!SH=JU literal 0 HcmV?d00001 diff --git a/26.Find_kth_smallest_ele/__pycache__/find_min.cpython-37.pyc b/26.Find_kth_smallest_ele/__pycache__/find_min.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ca9195075b3aaf238e7564ecac26d85b76f1234d GIT binary patch literal 422 zcmYjOy-ve05WcgWP(r&g&^KrpD%1f40)zlDK^F#46o{(Y(5R^camtV6Y&-~z%)Cuj zroI9b=Tu0Xb>DYCzB`|M-01{B@_lm^en4{7M52+^2&SZS7uOc7 z*99x+&Twg0!g`YJK;=CSt|;T?4+}SX(SUny$m-xM)$&~F`$<`Q<9x2m(69ZcQ8rg5 zYA-oy;t|iaig@{)*L;@h8q-fGR;kO+=ILI%wHpt%`>t6sEhmYYjj~LcGEtd|?_88h z`VX)5igPYf?e;bs1i%7pHOFTH1qRqAuZ_hTg`kg2fZRLbh=&q~c2pO7i1#Qj3dY+%of0d{Xn$GfMOd zDsQoZb%OL2a{vhjMixdsMjoajHXz$ilMzfKjD@gRfpWJvY;yBcN^?@}z= search_ele): + #flag = True + break + + return add +array = [5,1,9,7,2,8,3,6,4] +search_ele = 25 +print(validate(array,search_ele)) + diff --git a/28.Count_upto_greater/FindLenght.py b/28.Count_upto_greater/FindLenght.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/28.Count_upto_greater/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/28.Count_upto_greater/__pycache__/FindLenght.cpython-37.pyc b/28.Count_upto_greater/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..947aeb8f789f7c52f37143a5ebf8c2286cf808d9 GIT binary patch literal 273 zcmZ?b<>g`kg2fZRLbh= search_ele): + #flag = True + break + + return add +array = [5,1,9,7,2,8,3,6,4] +search_ele = 25 +print(validate(array,search_ele)) \ No newline at end of file diff --git a/29.swap_one_bit_right/swapRight.py b/29.swap_one_bit_right/swapRight.py new file mode 100644 index 0000000..c8300a5 --- /dev/null +++ b/29.swap_one_bit_right/swapRight.py @@ -0,0 +1,16 @@ +def swapRight(array): + + + temp = 0 + j = 0 + while (j!=1): + i = -1 + while (i!=len(array)): + array[i],temp = temp,array[i] + i += 1 + j += 1 + return array + +array = [5,7,6,9,2,8] +print(array) +print(swapRight(array)) \ No newline at end of file diff --git a/3.getIndex/FindLenght.py b/3.getIndex/FindLenght.py new file mode 100644 index 0000000..50ce3fe --- /dev/null +++ b/3.getIndex/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +array = [1,5,2,8,9] +print(count(array)) diff --git a/3.getIndex/__pycache__/FindLenght.cpython-37.pyc b/3.getIndex/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..caa821b94ab809e1bf0f613c88da2b428cbdde7b GIT binary patch literal 331 zcmYLE!AiqG5S`g%(dU0k&oaMcJJG^bXjg+RSqNa7i?SxPYi#+XqbFcEHWwY!Ej61=HBa6?w=1UC2--Eo(vgK5V`=p^GE z64hdnMYH+RHkFesPhb02XZg`-emp8oGqGe=`E_OK#@O<{87-b$?I*-v$4r1B4sb`g zND|~(o&2oxN(|i=(=-XZq1A len(array)): + shiftValue = shiftValue - len(array) + + temp = 0 + j = 0 + while (j!=shiftValue): + i = -1 + while (i!=len(array)): + array[i],temp = temp,array[i] + i += 1 + j += 1 + return array + +def shiftLeft(array,shiftValue): + if (shiftValue > len(array)): + shiftValue = shiftValue - len(array) + i = 0 + while(i!=shiftValue): + j = 0 + temp = (array[j]) + array.remove(array[j]) + array.append(temp) + i+=1 + return array + + +array = [5,7,6,9,2,8] +shiftValue = 10 +print(array) +print("Shift Right") +print(swapRight(array,shiftValue)) +print("Shift Left") +array = [5,7,6,9,2,8] +print(shiftLeft(array,shiftValue)) diff --git a/35.FindUniqueElements/FindLenght.py b/35.FindUniqueElements/FindLenght.py new file mode 100644 index 0000000..d2c9e33 --- /dev/null +++ b/35.FindUniqueElements/FindLenght.py @@ -0,0 +1,11 @@ +#To find the lenght of an array using slicing methodogy + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +#array = [1,5,2,8,9] +#print(count(array)) diff --git a/35.FindUniqueElements/__pycache__/FindLenght.cpython-37.pyc b/35.FindUniqueElements/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..40efef47b674e12e06246f3993216949235c802c GIT binary patch literal 273 zcmZ?b<>g`kf=U;gnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)cnl4r`29`0#rh0Cfc`2cJnT4gPt~sf>sd**EF(4tI)V%bJ z61{@TTdZKsAg#q5K!Smhg^`buhpC7S$oA7@1k(tUAuLv)+$|29-29Z%oK!ooUXWG* DrY$mu literal 0 HcmV?d00001 diff --git a/35.FindUniqueElements/__pycache__/builtDictionary.cpython-37.pyc b/35.FindUniqueElements/__pycache__/builtDictionary.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f7b7a3c85221688ebf10dfc951140ea7d1f8c5b6 GIT binary patch literal 345 zcmYL?!AiqG5Qb+qsl?Dq@ghD#JcOcnP^tt?d+bF-kch-=4vXo=ZW1uCx%o0ahOe<# zPkn`+oK2~n<^T8J+2NbJ(Z~m?pIMaLAi%GE?21u{NY#*x1II6T2F@NJa59?h%O$tE zCsh%dfDSo!?DJeh3@>M$!&%3)qw)PfO*Crflo%&q(-c-mn(fjP^(=d_CJe0YhHnU5 zGf0(6TjO())uNQCYRw=k8(A9^%Au*=Her07OsS5T4m264M`~6x5q1As$Mxcu)jqyB<5{ZG(sH!yIo&J^6zH~Ylt-B!Nk5RBp z{lUx+{V0i@?ce)_FFb`4w-%W^cu9j<;%?KbYkWWkP^V*&n%H1f6#MixR;y8BkgC=t z?Nf4ACpo;shoanch;X5ml$o${R_IHM$f?EQ&_-zli66$cAr#7}5_&7w{~J`|RN|}D zrhc|%CQK@mM-yV@Qo@~xdAKuim9nua0c_B$CW<=wLz|Tom%$EJxvvt??1pom&iw0= JvLa?yegWCpa*O}~ literal 0 HcmV?d00001 diff --git a/35.FindUniqueElements/__pycache__/find_min.cpython-37.pyc b/35.FindUniqueElements/__pycache__/find_min.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ac93a9bc128dd674041633ec6545e6fbe2be08ac GIT binary patch literal 419 zcmYjO%}T>S5T4oH#2DL~2m1tVE=3d(MWkr;q`inJAy}llYG}H#`SAxfHy=cgo_(8K zJ@pklIh!Il%Y5Jb?aU5))NcDg(j5+>F9i6u&Yv(c2Bi5qfdq*OgdmyZZxEuy3kbx5 zGBBFZ%|={8PI^q5-w+h=js`xkB9z#HiV-tnZkXXy$a;oVLJPwyA$jGz^o(P0%Cl<& z#_50&R5M!Il`xKEyHGjvtt-md`J>E^UNm5z8?f3xjkP>e`u?G)ok?2iB5-T>={6}< z9=4V|ZsH+NwF-IhoYs66>l))v$X2P#Pj|QiQpfXBog`|ebdg7Q6dF@~ z|M9h6vCes{?b7)M0WcrE=D19tKp$J=wJ=+wT);9x)Y#3Se_+3%_6}yLEE9ETcgZby F_zPtpSHl1R literal 0 HcmV?d00001 diff --git a/35.FindUniqueElements/dictionaryOperations.py b/35.FindUniqueElements/dictionaryOperations.py new file mode 100644 index 0000000..19f29e3 --- /dev/null +++ b/35.FindUniqueElements/dictionaryOperations.py @@ -0,0 +1,16 @@ +def built_dictionary(array): # To Built a dictionary + dictionary = {} #creating a empty dictionary + count = 0 + for i in array: + count = 1 + if i in dictionary: + dictionary[i] = dictionary[i] + 1 + else: + dictionary[i] = count + return dictionary + +def find_key_from_dictionary(dictionary,max_element): # To find key from the value in an dictionary + for k,v in dictionary.items(): + if (v == max_element): + key = k + return key \ No newline at end of file diff --git a/35.FindUniqueElements/findUnique.py b/35.FindUniqueElements/findUnique.py new file mode 100644 index 0000000..80e6305 --- /dev/null +++ b/35.FindUniqueElements/findUnique.py @@ -0,0 +1,17 @@ +#35. Given an unsorted integer array A containing +# elements from 0-9, find the number of unique elements. +import find_min +import dictionaryOperations +def findUnique(array): + dictionary = dictionaryOperations.built_dictionary(array) + listValues = list(dictionary.values()) + minimum_value = find_min.findMin(listValues) + for i in listValues: + if i == minimum_value : + b = (dictionaryOperations.find_key_from_dictionary(dictionary,i)) + print(b) + dictionary.pop(b) + +array = [5,7,8,2,6,5,8] +findUnique(array) +#print(built_dictionary(array)) \ No newline at end of file diff --git a/35.FindUniqueElements/find_min.py b/35.FindUniqueElements/find_min.py new file mode 100644 index 0000000..9ad5df8 --- /dev/null +++ b/35.FindUniqueElements/find_min.py @@ -0,0 +1,20 @@ + # To find the min of dictionary values +import FindLenght +def findMin(values): + + values_count = FindLenght.count(values) + one = values[0] + two = values[1] + if (one < two): + min = one + else: + min = two + i = 2 + while(i!=values_count): + if (values[i]g`kf=U;gnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)ciY`_$29`0#W_o$~C82qlg{7&*F>aZ8DL$!r=@}(@1(mm0 x!J0r?iaCG;10xF~A0rP_5gU;0r^yJW5hg-dtU$S295%W6DWy57c3{0AtpJtDFNOdB literal 0 HcmV?d00001 diff --git a/36.notUniques/__pycache__/dictionaryOperations.cpython-37.pyc b/36.notUniques/__pycache__/dictionaryOperations.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..751bd82836a82211577d876c11b8ad5f388d26ea GIT binary patch literal 527 zcmYjN%}T>S5T4y664M__DX2G3LKI3-5R@WC>$M(4gc1p{yM@puX*Y>9u(|mldi0g{ z>Zz}w7iWW|on>Zcc4ohsZ*Ch62T*?R2VR>3eCuE%7{dTH?Vw@6$UBUIQD)#xnE42< zH6fVNV*cwL-su2M2qj^pq^olYLwGqY4Ms~U4M}Euq9=(oju7hrwAY7aQ__w1jBki- zjMfMPYu(`sTvJ(r5J90F7EZD-i33q6Ym($~rbs9Ztg6h<+3?!yU3nLm-8jjf;&7Ss z)Z6}fSa1>O|7mwosMc#9&NF|T*4@$;8XzVf2h}ERS|?&3-zIt`S}auEvZ8x}&gxjg z2YhO(9S@0?Mn#nhN7B+RLjhjB8P_^7))cTr-&|@}`U#FSd+? zjb-X^8ph1Wgg+HYv@>xXv#Blt(#BbBBAV!rTv||sSrpY5JDAHOwa`(P!v(2IzZIcp-EamvNs+CMrPi| zD^p*AiE}C>&bsfr^ZogJ(rku6veoM*UkLE+oIhb?bVuzm9_YUob;5myd|jM9W{KQA(Yqx!-yF%*G%&f6m89nP(pJfBsbnmTYDNuytvVz zy%uOeIsK(=g!Uxc2jfk5t|{W?_X{_AQGjD43eZLKkCb^uA(_^ len(array)): + shiftValue = shiftValue - len(array) + + temp = 0 + j = 0 + while (j!=shiftValue): + i = -1 + while (i!=len(array)): + array[i],temp = temp,array[i] + i += 1 + j += 1 + return array \ No newline at end of file diff --git a/37.getIndexAfterRotationright/__pycache__/Rotateright.cpython-37.pyc b/37.getIndexAfterRotationright/__pycache__/Rotateright.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85be44d17ecf0a7d8daecb8d051b2c5c0c683f7b GIT binary patch literal 399 zcmYjNJxc>Y5S`iGKyq9xEF`veXAy!HL5UJIg*GW7sDx_{cavPcv$w$n_A31|{-tYe zyuVs>Iv$QpSX8R;_2o9JBrnmj=Q?g< qazFy;qt65i^oV=7?`qWUW4pocTkQKM73yW>)@&iyQ*~J+xu758C0Ka? literal 0 HcmV?d00001 diff --git a/37.getIndexAfterRotationright/getindexRight.py b/37.getIndexAfterRotationright/getindexRight.py new file mode 100644 index 0000000..ee68300 --- /dev/null +++ b/37.getIndexAfterRotationright/getindexRight.py @@ -0,0 +1,12 @@ +#37. Given an unsorted integer array A, +# find the value that will be in 3rd position or index after 2 rotations to the right. +import Rotateright + +def getIndexAfterrotationRight(array,index,rotation_value): + afterRotation = Rotateright.swapRight(array,rotation_value) + return afterRotation[index] + +array = [5,7,6,9,2,8] +index = 3 +rotation_value = 2 +print(getIndexAfterrotationRight(array,index,rotation_value)) \ No newline at end of file diff --git a/38.getIndexafterrotationleft/__pycache__/shiftLeft.cpython-37.pyc b/38.getIndexafterrotationleft/__pycache__/shiftLeft.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a63d73c866cb927277bd0b63dff274dcaf045cdd GIT binary patch literal 389 zcmYjNu};G<5WREKsx2uKLs?+XQji!Z2%!pCDxoeQkfJOWcA+#)g5#oAawhl=R7QTu zD^q`giF2wV&U)|OoptvtU$omTp!gW{<9!79cEu(bi9VqShy)0HhX@3_fzW$!cP?rK zpKwViA|itt47}mQSDlUSK#2lNHt!i`aN?<3syqY6+lA6Mu*9|gM5NgzGk&F*V8>9h zm%V%HI@jTf3}8j?q{4cMOl@7sY4$2@o#(ksMOd>nt`uKHt>S4s(sw+WNsD8P&yla? zH2(tCr177FtJC=KBtGhOAEh3oLeBX}OQkZ+^*BotInr^p;hI!8U)bhf len(array)): + shiftValue = shiftValue - len(array) + i = 0 + while(i!=shiftValue): + j = 0 + temp = (array[j]) + array.remove(array[j]) + array.append(temp) + i+=1 + return array diff --git a/39.getIndexafterrotationright/Rotateright.py b/39.getIndexafterrotationright/Rotateright.py new file mode 100644 index 0000000..41f4216 --- /dev/null +++ b/39.getIndexafterrotationright/Rotateright.py @@ -0,0 +1,13 @@ +def swapRight(array,shiftValue): + if (shiftValue > len(array)): + shiftValue = shiftValue - len(array) + + temp = 0 + j = 0 + while (j!=shiftValue): + i = -1 + while (i!=len(array)): + array[i],temp = temp,array[i] + i += 1 + j += 1 + return array \ No newline at end of file diff --git a/39.getIndexafterrotationright/__pycache__/Rotateright.cpython-37.pyc b/39.getIndexafterrotationright/__pycache__/Rotateright.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4535daca6dafe47a52abfb3384c8a40d672b6be4 GIT binary patch literal 399 zcmYjNJx>Bb5S`gw5+H|#g~8VDEC|uUV9*ey(1rpNHRPI$yTI{rz}^xd*{k%=_?ND= z@&1C1&YqI^lK1vaX7XmTH?>+72%mSI;0gggT(Jiu(;+4vi3EvnFaXIOz~?Wn=TIUF z;w>?mkXSTe;T5Ms*Y~~-DN0Nkk#D<}Tbyz&B}>Kj)QZ1(uAeQlV8t;oO0c30DYHWI z3rNMP`2?01p07^G16?6{IW2_zn~>A-;A6&TD)viRDbzaL4XVjF8k)y&wpIgS)O?xY zB*W+(beYD#&bpUDvlX1T8Y5-yW2v^`&?v1JCN$9^*3oEeg1)O%;Ty|cR!KJDvhO-> rV{$|S=%L313akQ%I*0=u4n4HNOD0x17=ve literal 0 HcmV?d00001 diff --git a/39.getIndexafterrotationright/getindexRight.py b/39.getIndexafterrotationright/getindexRight.py new file mode 100644 index 0000000..1f551db --- /dev/null +++ b/39.getIndexafterrotationright/getindexRight.py @@ -0,0 +1,12 @@ +#37. Given an unsorted integer array A, +# find the value that will be in 3rd position or index after 2 rotations to the right. +import Rotateright + +def getIndexAfterrotationRight(array,index,rotation_value): + afterRotation = Rotateright.swapRight(array,rotation_value) + return afterRotation[index] + +array = [5,7,6,9,2,8] +index = int(input("Enter the index value")) +rotation_value = int(input("Enter the rotation value")) +print(getIndexAfterrotationRight(array,index,rotation_value)) \ No newline at end of file diff --git a/4.Find_More_than_one_occurences/Find_More_than_once.py b/4.Find_More_than_one_occurences/Find_More_than_once.py new file mode 100644 index 0000000..aad8737 --- /dev/null +++ b/4.Find_More_than_one_occurences/Find_More_than_once.py @@ -0,0 +1,29 @@ +# Given an unsorted integer array A and an integer value X, find if X is found more than once in A. +#input = array +#output = if more than one element is found return true else false + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +def find_more_than_once(array,search_elemnt): + flag = False + i = 0 + b = count(array) + counti = 0 + while (i!=b): + if (array[i] == search_elemnt): + counti += 1 + i += 1 + if counti == 2: + flag = True + return flag + + + +search_elemnt = 2 +array = [7,9,1,2,4] +print(find_more_than_once(array,search_elemnt)) diff --git a/4.Find_More_than_one_occurences/__pycache__/Find_More_than_once.cpython-37.pyc b/4.Find_More_than_one_occurences/__pycache__/Find_More_than_once.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7bcd59b4225df2d0df2142777e2a65e223fe6c3e GIT binary patch literal 631 zcmZWn&1w`u5bo-q*~zjS4?;-5lPBjAL;|8LK~!=GxEBRsSr{f=on*-FOwuz83Cx^U z-@+HjEA=&}c?C~awWt9Ls_N^h?&|NWp7+z~Sdf)xv*iyd!~-w>m?7|vyg8zP0^yrj z2$ZNO1L}oDg9(mMV|rm0%4r8qIk}Zv0D(K7MK-oTN7<;iP~;!To97e|dbr*1L!qI`bwwOe4veD;2!rPlL3m5*m_g7rRQET{G5G!yL|a(d31PER+xXP zz02FnqRQ*a<+ZgN?<(t><$qP{4zKTmiTzkI^CpWjYnJy4fRf1~t`A(e$#DBs7_ycoymT zl7YjQ3?hXr38wJAxC_(972aOvZspch8}#|AxCl@NIP=W@-#|RG4NuQ`8tX^Xux>(y zW{(1^)R2;oVM3W*gWsi!=P3-Ve%RqsG7rJJ}uVVub#nrH{aR4~BdOh9QPi z6k$7)%pnM)%#A!;o%oT@2y-q`RAVmlU=A4mh(do3vFIQ%)_f+X2jdM4*#pDy6qQJB znrMZtaEWGkgdduF9voh@V=1{%8;>`~=UbuFj+tED*c+cK zE)|W1u2UHgx!_}=+pjEoROIi3D1`3NVIi_uQGPZ~<2+Vy5|U^IqG^@5S8XcT_D>{g zQ0eviw=V|0=YyT@{wQbkLm@a-Cvi@ToYNvnCW7Y)mjheD&_J@=kP6cspX)nSrM9#~ zG2xEsNCOPQE^^TtY9mpH-J*4-1~Y8ye!;@D&a@30j+uAtO)>MQrfIk|Z6s5tB&Bmo zrf%uVABtQ#tX8^1%mU*dl9|iu%DwVt=+u{=;M_0C42vUJ)yyg#DzsTfVi{> zSOKEJR=yLU%VSN}Dm_b`uL3~SOMgL~YpH7=%nko@^NP87+Z-f^<}R515MPsiKg1Vn zhSXjtH~M|c?>6uo@Uw)E6=&Ly6E%s`kQmN;5t!}&)UXpu*u^IP^NLewl71eE1W(f`1Vs#dUq* o(zP3(?Ud+1pp~Z0xm2CuRoD`P-K=1fl)p3tOXCVa(E$mZzgNC87ytkO literal 0 HcmV?d00001 diff --git a/4.Find_More_than_one_occurences/test_find_more_than_one_occurrences.py b/4.Find_More_than_one_occurences/test_find_more_than_one_occurrences.py new file mode 100644 index 0000000..cbd94c4 --- /dev/null +++ b/4.Find_More_than_one_occurences/test_find_more_than_one_occurrences.py @@ -0,0 +1,14 @@ +import Find_More_than_once + +def test_assertTrue(): + assert True + +def test_array_return_False(): + #arrange + search_elemnt = 2 + array = [7,9,1,2,4] + excepted = False + #act + actual = Find_More_than_once.find_more_than_once(array,search_elemnt) + #assert + assert excepted == actual \ No newline at end of file diff --git a/40.getIndexafterroationleft/__pycache__/shiftLeft.cpython-37.pyc b/40.getIndexafterroationleft/__pycache__/shiftLeft.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..278078eb19e8a179f793cbef40c087381b34f61e GIT binary patch literal 388 zcmYjNJxc>Y5S`h(gd`?b7O~Mf&5=Uz1Cd~C0+L2iIIcO|Jw0<@?rkK2y-I(F#L~aC ztyTVlm9rNj&hp;8nPuiJd)e!CfZ}5^3JwwA+ZNkkBu0d?OT>ZWJNUra4Gf$IduO9T za0z2V=@V&Gpy3T?uIz7hA1dTnvBimI8fT8YrOMHuoqecW4J+K}PehtsG40lhadr$9 zdpWqLu63QR$pF^$PAZI(h|DylNb^@=nqg6hj1L;75lR^@{Z9E5N9rz2=E7iX@Y#2j zNQ*C!Z5sdauFittX>c_39)+4@Tr9#!2`TeX#d(&9NCowRYf@gZH0{62x|e%IfL%H+ jb_gxprQAiiL;dMslWV7cWPjSU&eNRF6LC@Rv1@(-Nm^7O literal 0 HcmV?d00001 diff --git a/40.getIndexafterroationleft/getindexAterrotation.py b/40.getIndexafterroationleft/getindexAterrotation.py new file mode 100644 index 0000000..88207e6 --- /dev/null +++ b/40.getIndexafterroationleft/getindexAterrotation.py @@ -0,0 +1,13 @@ +#38. Given an unsorted integer array A, find the value that will be in +# 3rd position or index after 2 rotations to the left. + +import shiftLeft + +def getIndexAfterrotationLeft(array,index,rotation_value): + afterRotation = shiftLeft.shiftLeft(array,rotation_value) + return afterRotation[index] + +array = [5,7,6,9,2,8] +index = int(input("Enter the index value")) +rotation_value = int(input("Enter the rotation value")) +print(getIndexAfterrotationLeft(array,index,rotation_value)) \ No newline at end of file diff --git a/40.getIndexafterroationleft/shiftLeft.py b/40.getIndexafterroationleft/shiftLeft.py new file mode 100644 index 0000000..a694de4 --- /dev/null +++ b/40.getIndexafterroationleft/shiftLeft.py @@ -0,0 +1,11 @@ +def shiftLeft(array,shiftValue): + if (shiftValue > len(array)): + shiftValue = shiftValue - len(array) + i = 0 + while(i!=shiftValue): + j = 0 + temp = (array[j]) + array.remove(array[j]) + array.append(temp) + i+=1 + return array diff --git a/5.Count_Occruences_of_an_element/find_the_number_of_occurrence_of_an_element.py b/5.Count_Occruences_of_an_element/find_the_number_of_occurrence_of_an_element.py new file mode 100644 index 0000000..5a9b0ce --- /dev/null +++ b/5.Count_Occruences_of_an_element/find_the_number_of_occurrence_of_an_element.py @@ -0,0 +1,33 @@ +# Given an unsorted integer array A and an integer value X, find if X is found more than once in A. +#input = array +#output = if more than one element is found return true else false + +# Given an unsorted integer array A and an integer value X, find if X is found more than once in A. +#input = array +#output = if more than one element is found return true else false + +def count(a): + counti = 0 + while(a[counti:]): + counti += 1 + + return counti + +def find_more_than_once(array,search_elemnt): + + i = 0 + b = count(array) + counti = 0 + while (i!=b): + if (array[i] == search_elemnt): + counti += 1 + i += 1 + + return counti + + + +search_elemnt = 4 +array = [7,2,1,2,4] +count = find_more_than_once(array,search_elemnt) +print("The Number {} occurs {} times".format(search_elemnt,count)) diff --git a/6.listIndicess/list_Indices.py b/6.listIndicess/list_Indices.py new file mode 100644 index 0000000..9a95632 --- /dev/null +++ b/6.listIndicess/list_Indices.py @@ -0,0 +1,18 @@ +#6. Given an unsorted integer array A and +#an integer value X, return the indices of the locations where X is found in A. + +def getIndex(array,indexFor): + index_list = [] + i = 0 + index = 0 + lennght = len(array) + while (i!=lennght): + if (array[i] == indexFor): + index_list.append(index) + index += 1 + i += 1 + return index_list + +array = [7,4,5,7] +indexFor = 7 +print(getIndex(array,indexFor)) \ No newline at end of file diff --git a/7.sum/__pycache__/sum_elements.cpython-37.pyc b/7.sum/__pycache__/sum_elements.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a3ea2dc206648546caba111565635aa098db3d27 GIT binary patch literal 528 zcmYk2!A`U1Kl(&~FBAMOkDME_tV<$5;2VS>nBeqB;RsiF zq9T0ZjlGabE>W@_?hrv#A0ViWsGnVol#|_&Wfvp@x41qjpg;ldtPSdnJl2CPF1<&} z(rG>{sSrxj;{yVwF$ulVe3j-CWqMipKE1z=x>r%JldWbESuCe=Ceu9YEH>J;Yx15VgIV%_dC)4Tw^4=>@5KiPF%5Kn*Hi5~p71DT=ymW2Z#j&8}=OG}T5z zz|Y{&NL-NkMZR*%nOjfHcuN#4c|0>7&v@p&m+R~Gwx#f~`6rIGvG# zs2zN*$rUZgoQ~-|GNYP-?G$uQztS&IcLtRpqkD9G*^HDDQg1)p$)>x3G7cWDsUK!j zEtC!;X=1~SsYCw4L1SnufglEOx!7rGOYWP z$SVBwdh_+OLFeh>nq`oih(Q^`QToY0Owb3wF+CPT{B@nq4`(S~w%hee{pm+~qaxURCDg+*8MJ z@8Qhk320T+CXCm3eHro5Mlgu@Y$HH}h&o^U&S2^;Z}9cPwFp$S4-vJZvP8hK2sDot z6#l$G92eN@0{dBDLyIjC0lj9uUO+Efh)*X_+r6HJstZv0;$kQ=Ex7U0TxYos7{b@- zgXsPT>|UVIxfj$;0|p(6SR`Vi0d24()-@a9FpA?4Q68pA7D-_mh~jBJj`et=j2EX6 zq0IeIeMs||+tBbVPEVsaoJ5I`F65EeiNq!X&r~8Qqp93LR|~`{FLqaX@o3f9w-hOb z53fw?hKQI;=v+>^`&d9>O2Team(`gMg`k0%d2LnA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!z-?CFhssm1Guy%mNd?9nHJf030nyrPf|aNQ5hGTbCf#umj?5Adl1tdT3j{7ze2`fBI+oj7 z-78o*vm!X~eLFwj%&_y&@Am}R=V+Lofe>FD{Fx@_o={#9p+H!O>{Qb-X7z#(a~boo=#4 zZGE(~S@9uUmrCE~kGJXNO?o}x8PgZ4q`_m&V7+yQL`Q@&oCtbg0z$s!kF=7BC2fa^ n7slFg*75Oz(s9YLJZ$|(Jl31xa)tH6-f?ruD-9TFIw$Z0;{#E% literal 0 HcmV?d00001 diff --git a/find_mean_of_array_elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc b/8.Find_Mean/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc similarity index 100% rename from find_mean_of_array_elements/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc rename to 8.Find_Mean/__pycache__/Finding_lenght_of_an_array_without_using_len_functin.cpython-37.pyc diff --git a/8.Find_Mean/__pycache__/Sum.cpython-37.pyc b/8.Find_Mean/__pycache__/Sum.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ac2b3c2c6748a84f990e4c8cbc6053da63f59aab GIT binary patch literal 342 zcmYjN!AiqG5S`gg+8C?{DO7J>b1CA*Dn+CgPufclLI{M=jap1Lx=Fyo=H`E>M}KLr zp85-(oLvxn!+Xrk+kLP*8w^4q^ybs#9Ra@W@CQcCC9xio2oP9641x*%1~Cd;Lga19 zfyIh$I(Vdd8~h|+IYr_Z^u&y}M8T5Bp7D(5@qN$N*6RC52faUpkl(Nui^1&>wt57D6HZgo zrS@c*!w4mr+x2Mm;&*+{xbuZ{Yux1?oB^kAN#xHVmK^s{;=(^Y*e_tK76?wKq$Fw^ zqcyprC7ID7-6T`08R$+)XY@1u1bL^B34U~sPc9pYQbOvj``e?*gGd<%57*QWM-wfS zjuUCZSS14?#YmdQGwVGp@|RK;(rmDy4F3|0J>o zm0s^1?e|(wdXINr4Rap97D?W-*#@X)pvJ`jQp;o#i&SJH*J@`pF}JK!Rl|uK3kO@T zgCNu;E@_emks)Y{8Tp`KLOY{haN!iEgL6IeUW5}m4zHEY zfbszC12%JcsNE}XM$Ucp2Ht&~r|iM4hPRyYkk=O;+IleX_-H-g1|D_3@|^)9E??zq zrEAggbO0V<=`GN4EIN(jxeFD~5$8EJGRIEl*z?)9uejC^BYMp`orqpG5x-WXwmKaP zWgDOj#6@3>wBW{1`g)wC5kq)eT@da6fZvT28h4|*2`wTBfpJkv%xBi)ev+m!a-d&i zqeKd`iWr}chp8Us%J^vk9?IN_)%#+ca_btOrNwEI#(9zniM>eVtHfR+-*^^Zc^ggZ zAeLG4V3{=!mz6zBph^S~WtulM1+GY;$1-p4VFJ|zL0E&jtj+=;$2+o$^tcDsC^W&p z%H<{)%-y)6`%Xn#VDXL=ALLLA6D~}qc4M two): + max = one + else: + max = two + i = 2 + while(i!=values_count): + if (values[i]>max): + max = values[i] + i += 1 + return max + +#values = [5,2,4,7,3,5] +#print(Max(values)) \ No newline at end of file diff --git a/9.Most_occurence.py/__pycache__/Equate.cpython-37.pyc b/9.Most_occurence.py/__pycache__/Equate.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5e690f74976c130ee2942432a9b2a76e98502cf5 GIT binary patch literal 415 zcmYjNO-sW-5S^Xuh8SA#AV|G>ib(M$l_H|GCoQ4{B?L5N(+^t{yGfvh&CMU8M}Lmj zTs`$Kcycx>ILo|!J8x!pc21j37s%Fk-Qa@(e44|bA(0dEY>PmGWOMLAqO@MXXOi83 z$JeC5Afn3JY(k6tj653=|RMsQGTTLjdS9&Rpiua#@4f$Qjb!KxIbkp)#p8uV48G8zfXt_bHXdJU%v` J$js~={05fcRgwSz literal 0 HcmV?d00001 diff --git a/9.Most_occurence.py/__pycache__/FindLenght.cpython-37.pyc b/9.Most_occurence.py/__pycache__/FindLenght.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d88800a625ee2add382c07432a79ccc3df9908a8 GIT binary patch literal 271 zcmZ?b<>g`k0(Uo?nA1S|F^B^LOhASM5Et_Ri4=wu#ukPsh7_h?22JK`CD*=fV##+V-i5i9)#uSEDCP{`O86b0 z7!#w|lJiURN-~Q;W`T)c>Mm9>29`0FdcOI^CGq*m$)!c9dC94I1(h*wnRzKbsd?!c zB|zRSREEQrwMHNDTI?*l+peUk>;s~m?2{;K9$=-Mn7!hye zm8q}5#5olbXWjRoefFL0^KLf;vdMUqd?CQMoBSE0;EcT5BS?_Agcu}~{0(B1cny)* zPzI(Moovk~a`FrE>W)yuJ8JkqLzLJ9!$=t^*G%(;P<_peD1_!lNN&7!UwaxCT-|EW zUJtaOJ=1M$g!Uvm2ID;)-B8B$pDNdS)52XhVm2Jl3wf0n_Ybx8va%`a$hZD;x@__) z?re3|uE)GA@|f2zrRA%1ZE^kyYKN-)99*6xhr?tzn3PpLE3>Rod6DIV$Jb<%u1PE> xbuX><3BW=O+Tk;S0z>T3tb=NoauHL4q>bC^|KR@K2BTFen`M6L9#A<1_zT5eQ;h%s literal 0 HcmV?d00001 diff --git a/9.Most_occurence.py/__pycache__/find_most_occurence.cpython-37.pyc b/9.Most_occurence.py/__pycache__/find_most_occurence.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..da31ff83123462d579cff1ba0de08741828d23d0 GIT binary patch literal 992 zcmZ8f&2G~`5Z)i#b)7U+p`vi}31pC}lv`1SDq1)oS|M=&MM074-LzI?J6*4*e*dPKw zQs{h%@RLN2abu<8nW4hCNm1q6&{T1_wD6~Q@Mh548SHEw7Ns5*Nm419Cvs~t8;sIi z46}!3vwmEqV?7jUqSGRe)eLJ@t^*M2zz*Q}w9DF5t%5CKcmoTcVO&e~IVjVxCUdet zni~Tk*>Fpfsi0Aqjyae3gwQUe>{Er7yWU{Jcx=L-LD8fp*R-LU)^yGms58yyyk-lk z4zx3OP;0n$u_xC+LVJSFSAdqYU^oN04;HHlVtaKN>Qfo!Rdy^@c(vVx@nj-nRfbo+ zCe&#r%ga~$asEPwNWwnGj)ZrO3X4$~=i$F9M82)LamHz>jdu}`D_I)v{dpB@Y4~A0 zwG@pzQ7P2S8x<;xb>u3XL)Aj)BD4`6A>2*MO)WPb4h0U&6L?s500`8u4FiC?%hV=1 z!1gaKpsOVYT4GhBm45I6IDL}&$*EQwU{a3}aA<6nH~-tr?z6C(ZL7bV6`~r;w>arG PJhsqhe#`g#PKW*l{R7lZHm$aT1;Lvap}B@0>B5x_89n@UVG zkZ06eqk^6|n?DUAAsClO$D?w2;s|Bx%Tm2bxs*)EFyg8kifF+&E4dn6*40UoPdP8R z8itF4XORrqW0^*IB=N^F{2lBLo55Z~nzGY(;2m`O<=vbG-Z&V$w*_hxaa?hh$ILC4 zL9O~Pt@au>wfvk{%+y==5P(= two): - max = one - else: - max = two - i = 2 - while(i!=values_count): - if (values[i]>max): - max = values[i] - i += 1 - return max - -def find_key_from_dictionary(dictionary,max_element): # To find key from the value in an dictionary - for k,v in dictionary.items(): - if (v == max_element): - key = k - return key - -def finding_most_occureence_of_an_element(array): # the main function - dictionary = built_dictionary(array) - values = list(dictionary.values()) # converting the dictonary value to a list - max_element = find_largest_value(values) - key = find_key_from_dictionary(dictionary,max_element) - print ("the number {0} appears {1} times".format(max_element,key)) - -array = [1,2,5,3,2,4,5,5,5] -finding_most_occurence_of_an_element(array) - diff --git a/Find_occurences_of_largest_number_in_an_array/find_largest_number_occurences.py b/Find_occurences_of_largest_number_in_an_array/find_largest_number_occurences.py deleted file mode 100644 index 7d885da..0000000 --- a/Find_occurences_of_largest_number_in_an_array/find_largest_number_occurences.py +++ /dev/null @@ -1,20 +0,0 @@ -#12. Given an unsorted integer array A, -# find the number of times the smallest number is found in the array. -import find_max_element_in_an_array -import Finding_lenght_of_an_array_without_using_len_functin -def count_occuences(array,max): - count = 0 - i = 0 - lenght = Finding_lenght_of_an_array_without_using_len_functin.count(array) - while (i!=lenght): - if (array[i]==max): - count += 1 - i += 1 - return count - -def find_largest_numbers_occurences(array): - max = find_max_element_in_an_array.find_largest_value(array) - count = count_occuences(array,max) - return count -#array = [3,9,2,7,9] -#print(find_largest_numbers_occurences(array)) diff --git a/Questions.md b/Questions.md deleted file mode 100644 index 0e47ccc..0000000 --- a/Questions.md +++ /dev/null @@ -1,54 +0,0 @@ -# Programs on Unsorted Integer Arrays - -## Note: If there is a case where the solution provided will create a problem if negative integers are present in the array, then explicitly specify then same and if possible, provide an alternate soltuion that will eliminate the problem with negative integers. - -1. Find the length of the given integer array. Don't use the len() function. -2. Given an unsorted integer array A and an integer value X, find if A contains the value X. -3. Given an unsorted integer array A and an integer value X, return the index at which X is located in A or return -1 if it is not found in A. -4. Given an unsorted integer array A and an integer value X, find if X is found more than once in A. -5. Given an unsorted integer array A and an integer value X, return the number of times X is found in A. -6. Given an unsorted integer array A and an integer value X, return the indices of the locations where X is found in A. -7. Given an unsorted integer array A, find the sum of all the elements in A. -8. Given an unsorted integer array A, find the mean. -9. Given an unsorted integer array A, find the number that occurs the most or find the mode of the array. -10. Given an unsorted integer array A, find the smallest number. -11. Given an unsorted integer array A, find the largest number. -12. Given an unsorted integer array A, find the number of times the smallest number is found in the array. -13. Given an unsorted integer array A, find the number of times the largest number is found in the array. -14. Given an unsorted integer array A, print the contents of the array in the given format: {arrayindex:value, arrayindex:value}. Note that there is no comma after the last value. -15. Write a function that takes two unsorted integer arrays as input and returns True if the two arrays are the same. -16. Wrtie a function that takes an unsorted integer array as input and returns a copy of the array as output. -17. Write a function that takes an unsorted integer array as input and prints the contents of the array in reverse order. -18. Write a function that takes an unsorted integer array as input and returns an array with the values in reverse order. -19. Write a function that takes two unsorted integer arrays as input and returns the index upto which they are identical. Return -1 otherwise. -20. Write a function that takes an unsorted integer array as input and returns an array with the duplicates removed. -21. Given an unsorted integer array as input, return the number of odd numbers in it. -22. Given an unsorted integer array as input, return the number of even numbers in it. -23. Given an unsorted integer array as input, return the number of prime numbers in it. -24. Given an unsorted integer array as input, return the number of perfect squares in it. -25. Given an unsorted integer array as input, find the second largest/smallest element in the array. -26. Given an unsorted integer array as input, find the Kth largest/smallest element in the array. -27. Given an unsorted integer array and an integer value X as input, return the count of the values less than or equal to X. -28. Given an unsorted integer array and an integer value X as input, return the count of the values greater than or equal to X. -29. Given an unsorted integer array as input, rotate the contents of the array to the right by 1 position. -30. Given an unsorted integer array as input, rotate the contents of the array to the left by 1 position. -31. Given an unsorted integer array as input, rotate the contents of the array to the right by 2 positions. -32. Given an unsorted integer array of length N as input, rotate the contents of the array to the right/left by K positions, where K is always less than N. -33. Given an unsorted integer array of length N as input, rotate the contents of the array to the right/left by K positions, where K could be greater than N. -34. Given an unsorted integer array, return the count of the elements with values that falls within a given range. -35. Given an unsorted integer array A containing elements from 0-9, find the number of unique elements. -36. Given an unsorted integer array A containing elements from 0-9, count the number of times each number appears. -37. Given an unsorted integer array A, find the value that will be in 3rd position or index after 2 rotations to the right. -38. Given an unsorted integer array A, find the value that will be in 3rd position or index after 2 rotations to the left. -39. Given an unsorted integer array A, find the value that will be in index "I" after "R" rotations to the right. -40. Given an unsorted integer array A, find the value that will be in index "I" after "R" rotations to the left. -41. Given an unsorted integer array A and a value X, check if there exists a subset of A of size two that adds upto X (Subset sum for a pair). -42. Given an unsorted integer array A and a value X, check if there exists a subset of A of size two that adds upto X and print the indices of the values that adds upto X. -43. Given an unsorted integer array A and a value X, check if there exists a subset of A of size two that adds upto X and print the values that adds upto X. -44. Given an unsorted integer array A and a value X, check if there exists a subset of A of size three that adds upto X. -45. Given an unsorted integer array A and a value X, check if there exists a subset of A of size three that adds upto X and print the values that adds upto X. -46. Given an unsorted integer array A and a value X, find the minimum size of the subset required, such that the values of the subset adds upto X. Also print the elements of that subset. -47. Given an unsorted integer array A and a value X, find the maximum size of the subset that could be formed, such that the values of the subset adds upto X. Also print the elements of that subset. -48. Given an unsorted integer array A and a value X, return the subset of A containing values that are multiples of X. Return -1 otherwise. -49. Given an unsorted integer array A, check if the array A is a palindrome or not. -50. Given an unsorted integer array A, find the sum and product of the minimum and maximum values of the array. diff --git a/README.md b/README.md deleted file mode 100644 index 66e621c..0000000 --- a/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Questions on Unsorted Arrays - -### For Students of ROOT IT LEARNING CENTRE, TRICHY - -## Instructions: Fork the repository, add your solutions and give pull requests for evaluation - -For Details Contact: - -P.ANANDKUMAR - -Mobile: 9790636324 - -Email: root.anand@gmail.com - -www.therootlearning.com diff --git a/find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc b/find_mean_of_array_elements/__pycache__/test_find_mean_of_array_elements.cpython-37-PYTEST.pyc deleted file mode 100644 index ba97b3bb100805d9fa12a3a3a50f7e454a01cb5c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1110 zcmaJ>OK%e~5VpOKY|=K+R3HkMUXZ$%Dh(}C5rOjPwFl@ainMHFCq&&xWILj%HXMMT z!J+95ev)s9Q*NAlV#ZsdaH%Da?eRDEc)oA<_1aqP*VRGyAtmHDS!xXChtSniFr09j zkPfvYOC3fiN!^Y|%N@VtbH<%-q*LK8_h1Y-eNRGv4zc98hZY;2=|O)3T{XdQIwb{B z+Ze6MB`wH|4(WX|rJBLoDd>!TrC;FQDcl4ny2mFM^;jt(_15F<(PTGN#=*fgwZqXw z3#Fr2nrfutzK~)hP5qTc5A*Cu%3PX_sGrL;){!_LC2sqqonx&4X@#nDHnTaTeu$xJky7NF*W^nO0qU`z?T-(Zt-bpfaZuITj9O@vywWyg73rxV)>?ce(#cE-l2Od<#hg#iKZpsQ;uroGw3P)XOcIog+;q)mF z(BEe>mshoW>CMQQuinAFkM)&Zm{o9=F<#}h1wvZ{1H@;GfEgfaeC0a>hFreN*9zCN z<>>$r)xuk_?(@Fo%J zrI)9pSPHX>dN>^q6Ftn7@sk`7$~=hF$9$Y{3ylUzei|oH7N7yDLhr3oO)G;SmfLX$#|W!Boq3seIPVRh=V8Vf);AIK_7XA`_( z)dc@Cm-oP7Hly;>*eL}LirO3S9vRIADSE7s;M1& diff --git a/find_mean_of_array_elements/find_mean_of_array_elements.py b/find_mean_of_array_elements/find_mean_of_array_elements.py deleted file mode 100644 index e4cbabf..0000000 --- a/find_mean_of_array_elements/find_mean_of_array_elements.py +++ /dev/null @@ -1,13 +0,0 @@ -#8. Given an unsorted integer array A, find the mean. - -import find_sum_of_an_array -import Finding_lenght_of_an_array_without_using_len_functin - -def calculate_mean(array): - sum = find_sum_of_an_array.count(array) - divide_value = Finding_lenght_of_an_array_without_using_len_functin.count(array) - mean = sum / divide_value - return mean - -array = [4,2,6,7,3] -print(calculate_mean(array)) diff --git a/find_min_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc b/find_min_element_in_a_array/__pycache__/test_find_max.cpython-37-PYTEST.pyc deleted file mode 100644 index ff7eefb966f78ea0777763f9b5aa7dda4e6e6c81..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1089 zcmY*Z%We}f6tz8*$s~QyrUFrkMTLaa*;HvLpdy0GYugQ7MG=D=J0%exWPw^|VnslCSOSW8cR)$?KJs`p>`n-G`Kre`Mifus(pHpMnuY z(1diTn_22HLP_d(DzrQaI)Pxq`%XGl;fo5)p`h!3a7b z1<~7h+mK6IkSQI|dt^clgS}VKDg8#jLfi>Nf*1Y6ql;CpwNz&7(e`k>8)@s|_*(rRmx2)&xZ-mxPg<1b(Y|ETt3_^Hzlm~ zo2V*edewUSyxZLG_6M1WQ+^)HM5Zz`@gR#igj9UoboM`|QJth)|| zP@njuK~{;X!EWB505%xSHRum41jW{1Qw2QOU9|;)^A* zT=yG4CQ%G z4viEx;5{?qNyL!UW(Q2`7TtT1M(18sw-0U_eTxYo1F7gV+-btq2`b`@CnKpa54#@s zc#^~@jb5G(xsrAnsXrbK5;MrO4U!xX+TM@#r+kzM2aQjX{Fo(+ z;NI724Snli7S*)7sHVq@n two): - max = one - else: - max = two - i = 2 - while(i!=values_count): - if (values[i]>max): - max = values[i] - i += 1 - return max -def find_key_from_dictionary(dictionary,max_element): # To find key from the value in an dictionary - for k,v in dictionary.items(): - if (v == max_element): - key = k - return key -def finding_most_occureence_of_an_element(array): # the main function - dictionary = built_dictionary(array) - values = list(dictionary.values()) # converting the dictonary value to a list - max_element = find_largest_value(values) - key = find_key_from_dictionary(dictionary,max_element) - print ("the number {0} appears {1} times".format(max_element,key)) - -array = [1,2,5,3,2,4,5,5,5] -finding_most_occureence_of_an_element(array) \ No newline at end of file From f24858e8849dfd11e2aea73bc687b412a9378aaf Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:31:55 +0530 Subject: [PATCH 05/10] Code Revised Completely --- removeDuplicatesonly/findLenght.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 removeDuplicatesonly/findLenght.py diff --git a/removeDuplicatesonly/findLenght.py b/removeDuplicatesonly/findLenght.py new file mode 100644 index 0000000..61ac828 --- /dev/null +++ b/removeDuplicatesonly/findLenght.py @@ -0,0 +1,18 @@ +Question : +========== + To find the lenght of an array using slicing methodogy +Input : +======= + Unsorted Integer Array +Output: +======= + Count the No of Element in the Array - Integer +Code: +===== +def FindLenght(array): + count = 0 + while(a[count:]): + count += 1 + return count + + From 14526c8cc05d527dbbee58421c542c13c981c55e Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:36:06 +0530 Subject: [PATCH 06/10] Code Revised Completely --- removeDuplicatesonly/issorted.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 removeDuplicatesonly/issorted.py diff --git a/removeDuplicatesonly/issorted.py b/removeDuplicatesonly/issorted.py new file mode 100644 index 0000000..4f418db --- /dev/null +++ b/removeDuplicatesonly/issorted.py @@ -0,0 +1,28 @@ +problem statement : +=================== + Function to check whether the given array is sorted or not +Input : +======= + Integer Array + + Output : + ======== + True - if sorted - Bool + False - if not sorted - Bool + +Code : +===== +import findLenght +def isSorted(array): # To Check whether array is sorted or not + + flag = True + lenght = findLenght.getLenght(array) + + if lenght == 0 or lenght == 1: + return True + iteratorValue = 0 + while (i!=lenght-1): + if array[iteratorValue] > array[iteratorValue+1]: + flag = False + iteratorValue+=1 + return flag From c19098bd38a1d1237ff03c8be6afe4dd81acdf0e Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:38:43 +0530 Subject: [PATCH 07/10] Code Revised Completely --- removeDuplicatesonly/removeNonDuplicate.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 removeDuplicatesonly/removeNonDuplicate.py diff --git a/removeDuplicatesonly/removeNonDuplicate.py b/removeDuplicatesonly/removeNonDuplicate.py new file mode 100644 index 0000000..c2d51eb --- /dev/null +++ b/removeDuplicatesonly/removeNonDuplicate.py @@ -0,0 +1,29 @@ +"""problem Statement : + =================== + To remove the Non Duplicte element from the array + +Input : +======= + Integer Array +Output : +======== + Contains non Duplicate elements + +Code : +====== +def removeDuplicate(array): # To remove the Duplicate Element form the Array + j = 0 + i = 0 + count = 0 + lenght = getLenght(array) -1 + while(i!=lenght): + if (array[i] != array[i+1]): + array[j] = array[i] + #print(array[i]) + count += 1 + j += 1 + i += 1 + + array[j] = array[-1] + array.append(count) + return array From da44d4cd37e5081381f5fe3bb9ca9468adc96bd3 Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:40:52 +0530 Subject: [PATCH 08/10] Code Revised Completely --- removeDuplicatesonly/mainCode | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 removeDuplicatesonly/mainCode diff --git a/removeDuplicatesonly/mainCode b/removeDuplicatesonly/mainCode new file mode 100644 index 0000000..480d043 --- /dev/null +++ b/removeDuplicatesonly/mainCode @@ -0,0 +1,28 @@ +Problem Statement : +================== + To remove non duplicate elements + +Input : +======= + Integer array +ouput : +====== + Contain only single value non dulipcate elements + +Code : +====== + +def Main(array): + if isSorted(array): + array = removeDuplicate(array) + else : + array.sort() + array = removeDuplicate(array) + + untill = (array.pop())+1 + for i in range(0,untill): + print(array[i], end="") + if i != untill-1 : + print(",",end = " ") + + return array From 2a76f3abef767d067db9608ba1b6ce05f6d05ff0 Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:41:55 +0530 Subject: [PATCH 09/10] Code Revised Completely --- 6.listIndicess/list_Indices.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/6.listIndicess/list_Indices.py b/6.listIndicess/list_Indices.py index 9a95632..c083821 100644 --- a/6.listIndicess/list_Indices.py +++ b/6.listIndicess/list_Indices.py @@ -4,7 +4,8 @@ def getIndex(array,indexFor): index_list = [] i = 0 - index = 0 + index = 0 + lennght = len(array) while (i!=lennght): if (array[i] == indexFor): @@ -15,4 +16,4 @@ def getIndex(array,indexFor): array = [7,4,5,7] indexFor = 7 -print(getIndex(array,indexFor)) \ No newline at end of file +print(getIndex(array,indexFor)) From 2d0e14b27ff78c6e89b75f9a240f6888bb564947 Mon Sep 17 00:00:00 2001 From: "G.Sureya Pragaash" <36239801+SUREYAPRAGAASH09@users.noreply.github.com> Date: Thu, 21 Feb 2019 23:43:35 +0530 Subject: [PATCH 10/10] Code revised Completely --- 6.listIndicess/list_Indices.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/6.listIndicess/list_Indices.py b/6.listIndicess/list_Indices.py index c083821..6444d77 100644 --- a/6.listIndicess/list_Indices.py +++ b/6.listIndicess/list_Indices.py @@ -13,7 +13,3 @@ def getIndex(array,indexFor): index += 1 i += 1 return index_list - -array = [7,4,5,7] -indexFor = 7 -print(getIndex(array,indexFor))