diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed new file mode 100644 index 0000000..ce599f6 --- /dev/null +++ b/.pytest_cache/v/cache/lastfailed @@ -0,0 +1,3 @@ +{ + "Mode/test_Mode.py": true +} \ No newline at end of file diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids new file mode 100644 index 0000000..58ddc90 --- /dev/null +++ b/.pytest_cache/v/cache/nodeids @@ -0,0 +1,76 @@ +[ + "Copy of Array/test_copy.py::test_canassertTrue", + "Copy of Array/test_copy.py::test_copy", + "Count Repeated/test_count_repeated.py::test_canassertTrue", + "Count Repeated/test_count_repeated.py::test_count_repeated", + "Count Repeated/test_greater_count.py::test_canassertTrue", + "Count Repeated/test_greater_count.py::test_Greater", + "Count Repeated/test_lesser_count.py::test_canassertTrue", + "Count Repeated/test_lesser_count.py::test_Lesser", + "Duplicates/test_remove_duplicates.py::test_canassertTrue", + "Duplicates/test_remove_duplicates.py::test_duplicates", + "Identical/test_identical.py::test_canassertTrue", + "Identical/test_identical.py::test_identical_array", + "Index and Value/test_dictionary.py::test_canassertTrue", + "Index and Value/test_dictionary.py::test_dictionary", + "Lengthofarray/test_lengthofarray.py::test_canassertTrue", + "Lengthofarray/test_lengthofarray.py::test_len_of_array", + "Mean/test_mean.py::test_canassertTrue", + "Mean/test_mean.py::test_mean", + "Min and Max/test_Pallindrome.py::test_canassertTrue", + "Min and Max/test_Pallindrome.py::test_pallindrome", + "Multiple Integers/test_repeated.py::test_canassertTrue", + "Multiple Integers/test_repeated.py::test_isRepeated", + "Numbers/test_even_numbers.py::test_canassertTrue", + "Numbers/test_even_numbers.py::test_even_numbers", + "Numbers/test_odd_numbers.py::test_canassertTrue", + "Numbers/test_odd_numbers.py::test_odd_numbers", + "Numbers/test_prime.py::test_canassertTrue", + "Numbers/test_prime.py::test_prime", + "Numbers/test_square.py::test_canassertTrue", + "Numbers/test_square.py::test_square", + "Reverse of Array/test_reverse.py::test_canassertTrue", + "Reverse of Array/test_reverse.py::test_reverse", + "Rotation/test_I_index.py::test_canassertTrue", + "Rotation/test_I_index.py::test_Right", + "Rotation/test_I_index.py::test_Left", + "Rotation/test_K_rotations.py::test_canasssertTrue", + "Rotation/test_K_rotations.py::test_rotate_right", + "Rotation/test_K_rotations.py::test_rotate_left", + "Rotation/test_index.py::test_canassertTrue", + "Rotation/test_index.py::test_right_index", + "Rotation/test_index.py::test_left_index", + "Rotation/test_one_left.py::test_canassertTrue", + "Rotation/test_one_left.py::test_one_left", + "Rotation/test_one_right.py::test_canassertTrue", + "Rotation/test_one_right.py::test_one_right", + "Rotation/test_two_right.py::test_canassertTrue", + "Rotation/test_two_right.py::test_two_right", + "Same Array/test_same_array.py::test_canassertTrue", + "Same Array/test_same_array.py::test_Is_same", + "Smallest and Largest in Array/test_Kth_Largest.py::test_canassertTrue", + "Smallest and Largest in Array/test_Kth_Largest.py::test_Largest", + "Smallest and Largest in Array/test_Kth_Smallest.py::test_canassertTrue", + "Smallest and Largest in Array/test_Kth_Smallest.py::test_Smallest", + "Smallest and Largest in Array/test_Largest.py::test_canassertTrue", + "Smallest and Largest in Array/test_Largest.py::test_Largest", + "Smallest and Largest in Array/test_Smallest.py::test_canassertTrue", + "Smallest and Largest in Array/test_Smallest.py::test_Smallest", + "Smallest and Largest in Array/test_count.py::test_canassertTrue", + "Smallest and Largest in Array/test_count.py::test_smallest", + "Smallest and Largest in Array/test_count.py::test_largest", + "Smallest and Largest in Array/test_second_comparison.py::test_canassertTrue", + "Smallest and Largest in Array/test_second_comparison.py::test_Largest_smallest", + "Subset/test_41.py::test_canassertTrue", + "Subset/test_41.py::test_IsExists", + "Subset/test_42.py::test_canassertTrue", + "Subset/test_42.py::test_Subset_Index", + "Subset/test_43.py::test_canassertTrue", + "Subset/test_43.py::test_subset_values", + "Sum_of_Array/test_sum_of_Array.py::test_canassertTrue", + "Sum_of_Array/test_sum_of_Array.py::test_sum_of_array", + "X_in_given_array/test_X_in_array.py::test_canassertTrue", + "X_in_given_array/test_X_in_array.py::test_X_in_array", + "X_index/test_X_index.py::test_canassertTrue", + "X_index/test_X_index.py::test_X_index" +] \ No newline at end of file diff --git a/.pytest_cache/v/cache/stepwise b/.pytest_cache/v/cache/stepwise new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/.pytest_cache/v/cache/stepwise @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d64e1ea --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,18 @@ +{ + "python.pythonPath": "C:\\Users\\GRENINJA\\Anaconda3\\python.exe", + "python.linting.pylintEnabled": true, + "python.linting.enabled": true, + "python.testing.unittestArgs": [ + "-v", + "-s", + ".", + "-p", + "test*.py" + ], + "python.testing.pytestEnabled": true, + "python.testing.nosetestsEnabled": false, + "python.testing.unittestEnabled": false, + "python.testing.pytestArgs": [ + "." + ] +} \ No newline at end of file diff --git a/Copy of Array/__pycache__/copy.cpython-37.pyc b/Copy of Array/__pycache__/copy.cpython-37.pyc new file mode 100644 index 0000000..3e9e1b6 Binary files /dev/null and b/Copy of Array/__pycache__/copy.cpython-37.pyc differ diff --git a/Copy of Array/__pycache__/test_copy.cpython-27-PYTEST.pyc b/Copy of Array/__pycache__/test_copy.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..0a8966b Binary files /dev/null and b/Copy of Array/__pycache__/test_copy.cpython-27-PYTEST.pyc differ diff --git a/Copy of Array/__pycache__/test_copy.cpython-37-PYTEST.pyc b/Copy of Array/__pycache__/test_copy.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..95181f6 Binary files /dev/null and b/Copy of Array/__pycache__/test_copy.cpython-37-PYTEST.pyc differ diff --git a/Copy of Array/__pycache__/test_copy.cpython-37-pytest-5.0.1.pyc b/Copy of Array/__pycache__/test_copy.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..45f348c Binary files /dev/null and b/Copy of Array/__pycache__/test_copy.cpython-37-pytest-5.0.1.pyc differ diff --git a/Copy of Array/copy.py b/Copy of Array/copy.py new file mode 100644 index 0000000..4de17f1 --- /dev/null +++ b/Copy of Array/copy.py @@ -0,0 +1,25 @@ +# Return the copy of the given unsorted array: + +def copy(Array): + + C=[] + for a in Array: + C.append(a) + + return C + +#Getting Input from the user: + +N=int(input("Enter the number of elements: ")) + +Array=[] + +for a in range(0,N): + + Elements=int(input("Enter the Elements in Array: ")) + + Array.append(Elements) + +print("The given Array is", Array) + +print("The copy of the given array is", copy(Array)) diff --git a/Copy of Array/test_copy.py b/Copy of Array/test_copy.py new file mode 100644 index 0000000..ed310b7 --- /dev/null +++ b/Copy of Array/test_copy.py @@ -0,0 +1,18 @@ +# Test case for the copy of the given array: + +import copy + +def test_canassertTrue(): + assert True + +def test_copy(): + + #Arrange + Array=[1,7,2,5,4,9] + expected=[1,7,2,5,4,9] + + #Act + actual=copy.copy(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Count Repeated/Count_Repeated.py b/Count Repeated/Count_Repeated.py new file mode 100644 index 0000000..899f198 --- /dev/null +++ b/Count Repeated/Count_Repeated.py @@ -0,0 +1,30 @@ +# Given an unsorted integer array A and an integer value X, return the number of times X is found in A. + +def Count_Repeated(Array,X): + + count=0 + for i in Array: + + if i==X: + count+=1 + + return count + + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The Given array is: " ,Array) + +#X=input("Enter the search Elements: ") + +#print ("The Index of the given Search elements is: " ,Count_Repeated(Array,X)) \ No newline at end of file diff --git a/Count Repeated/Count_Repeated.pyc b/Count Repeated/Count_Repeated.pyc new file mode 100644 index 0000000..f9223cf Binary files /dev/null and b/Count Repeated/Count_Repeated.pyc differ diff --git a/Count Repeated/Greater_comparision.py b/Count Repeated/Greater_comparision.py new file mode 100644 index 0000000..6637936 --- /dev/null +++ b/Count Repeated/Greater_comparision.py @@ -0,0 +1,32 @@ +# Find the count of the values which is greater than or equal to the given integer: + +def Is_Greater(Array,Integer): + + count=0 + + for a in Array: + + if (a>=Integer): + count+=1 + + return count + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#Integer=input("Enter the integer value: ") + +#print("The count is: ",Is_Greater(Array,Integer)) + + \ No newline at end of file diff --git a/Count Repeated/Greater_comparision.pyc b/Count Repeated/Greater_comparision.pyc new file mode 100644 index 0000000..a8f0770 Binary files /dev/null and b/Count Repeated/Greater_comparision.pyc differ diff --git a/Count Repeated/Lesser_comparision.py b/Count Repeated/Lesser_comparision.py new file mode 100644 index 0000000..738de11 --- /dev/null +++ b/Count Repeated/Lesser_comparision.py @@ -0,0 +1,30 @@ +# Find the count of the Integer in the given array and compare the array is less than or equal to the given Integer. + +def Is_Lesser(Array,Integer): + + count=0 + + for a in Array: + + if (a<=Integer): + count+=1 + + return count + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#Integer=input("Enter the integer value: ") + +#print("The count is: ",Is_Lesser(Array,Integer)) diff --git a/Count Repeated/Lesser_comparision.pyc b/Count Repeated/Lesser_comparision.pyc new file mode 100644 index 0000000..177c690 Binary files /dev/null and b/Count Repeated/Lesser_comparision.pyc differ diff --git a/Count Repeated/__pycache__/Count_Repeated.cpython-37.pyc b/Count Repeated/__pycache__/Count_Repeated.cpython-37.pyc new file mode 100644 index 0000000..101162e Binary files /dev/null and b/Count Repeated/__pycache__/Count_Repeated.cpython-37.pyc differ diff --git a/Count Repeated/__pycache__/Greater_comparision.cpython-37.pyc b/Count Repeated/__pycache__/Greater_comparision.cpython-37.pyc new file mode 100644 index 0000000..ac7b66a Binary files /dev/null and b/Count Repeated/__pycache__/Greater_comparision.cpython-37.pyc differ diff --git a/Count Repeated/__pycache__/Lesser_comparision.cpython-37.pyc b/Count Repeated/__pycache__/Lesser_comparision.cpython-37.pyc new file mode 100644 index 0000000..04d0ec7 Binary files /dev/null and b/Count Repeated/__pycache__/Lesser_comparision.cpython-37.pyc differ diff --git a/Count Repeated/__pycache__/test_count_repeated.cpython-27-PYTEST.pyc b/Count Repeated/__pycache__/test_count_repeated.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..cc121c9 Binary files /dev/null and b/Count Repeated/__pycache__/test_count_repeated.cpython-27-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_count_repeated.cpython-37-PYTEST.pyc b/Count Repeated/__pycache__/test_count_repeated.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..9c0a7e4 Binary files /dev/null and b/Count Repeated/__pycache__/test_count_repeated.cpython-37-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_count_repeated.cpython-37-pytest-5.0.1.pyc b/Count Repeated/__pycache__/test_count_repeated.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..baca59f Binary files /dev/null and b/Count Repeated/__pycache__/test_count_repeated.cpython-37-pytest-5.0.1.pyc differ diff --git a/Count Repeated/__pycache__/test_greater_count.cpython-27-PYTEST.pyc b/Count Repeated/__pycache__/test_greater_count.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..bfe41dd Binary files /dev/null and b/Count Repeated/__pycache__/test_greater_count.cpython-27-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_greater_count.cpython-37-PYTEST.pyc b/Count Repeated/__pycache__/test_greater_count.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..033994a Binary files /dev/null and b/Count Repeated/__pycache__/test_greater_count.cpython-37-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_greater_count.cpython-37-pytest-5.0.1.pyc b/Count Repeated/__pycache__/test_greater_count.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..d9bb6ac Binary files /dev/null and b/Count Repeated/__pycache__/test_greater_count.cpython-37-pytest-5.0.1.pyc differ diff --git a/Count Repeated/__pycache__/test_lesser_count.cpython-27-PYTEST.pyc b/Count Repeated/__pycache__/test_lesser_count.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..1718faa Binary files /dev/null and b/Count Repeated/__pycache__/test_lesser_count.cpython-27-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_lesser_count.cpython-37-PYTEST.pyc b/Count Repeated/__pycache__/test_lesser_count.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..2015997 Binary files /dev/null and b/Count Repeated/__pycache__/test_lesser_count.cpython-37-PYTEST.pyc differ diff --git a/Count Repeated/__pycache__/test_lesser_count.cpython-37-pytest-5.0.1.pyc b/Count Repeated/__pycache__/test_lesser_count.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..42dc527 Binary files /dev/null and b/Count Repeated/__pycache__/test_lesser_count.cpython-37-pytest-5.0.1.pyc differ diff --git a/Count Repeated/test_count_repeated.py b/Count Repeated/test_count_repeated.py new file mode 100644 index 0000000..f9bc3cd --- /dev/null +++ b/Count Repeated/test_count_repeated.py @@ -0,0 +1,19 @@ +# Test case for the count of repeated numbers: + +import Count_Repeated + +def test_canassertTrue(): + assert True + +def test_count_repeated(): + + #arrange + Array=[5,3,8,0,1,8] + X=8 + expected=2 + + #act + actual=Count_Repeated.Count_Repeated(Array,X) + + #assert + assert expected==actual \ No newline at end of file diff --git a/Count Repeated/test_greater_count.py b/Count Repeated/test_greater_count.py new file mode 100644 index 0000000..6bbb319 --- /dev/null +++ b/Count Repeated/test_greater_count.py @@ -0,0 +1,19 @@ +# Test case for the greater count: + +import Greater_comparision + +def test_canassertTrue(): + assert True + +def test_Greater(): + + #Arrange: + Array=[2,3,2,2,4,5] + Integer=3 + expected=3 + + #Act: + actual=Greater_comparision.Is_Greater(Array,Integer) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Count Repeated/test_lesser_count.py b/Count Repeated/test_lesser_count.py new file mode 100644 index 0000000..cc4555b --- /dev/null +++ b/Count Repeated/test_lesser_count.py @@ -0,0 +1,19 @@ +# Test case for the lesser count: + +import Lesser_comparision + +def test_canassertTrue(): + assert True + +def test_Lesser(): + + #Arrange: + Array=[2,3,2,2,4,5] + Integer=3 + expected=4 + + #Act: + actual=Lesser_comparision.Is_Lesser(Array,Integer) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Duplicates/__pycache__/remove_duplicates.cpython-37.pyc b/Duplicates/__pycache__/remove_duplicates.cpython-37.pyc new file mode 100644 index 0000000..ab0d376 Binary files /dev/null and b/Duplicates/__pycache__/remove_duplicates.cpython-37.pyc differ diff --git a/Duplicates/__pycache__/test_remove_duplicates.cpython-27-PYTEST.pyc b/Duplicates/__pycache__/test_remove_duplicates.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..a7ef635 Binary files /dev/null and b/Duplicates/__pycache__/test_remove_duplicates.cpython-27-PYTEST.pyc differ diff --git a/Duplicates/__pycache__/test_remove_duplicates.cpython-37-PYTEST.pyc b/Duplicates/__pycache__/test_remove_duplicates.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..21a2c9c Binary files /dev/null and b/Duplicates/__pycache__/test_remove_duplicates.cpython-37-PYTEST.pyc differ diff --git a/Duplicates/__pycache__/test_remove_duplicates.cpython-37-pytest-5.0.1.pyc b/Duplicates/__pycache__/test_remove_duplicates.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..1afd81c Binary files /dev/null and b/Duplicates/__pycache__/test_remove_duplicates.cpython-37-pytest-5.0.1.pyc differ diff --git a/Duplicates/remove_duplicates.py b/Duplicates/remove_duplicates.py new file mode 100644 index 0000000..03fda4b --- /dev/null +++ b/Duplicates/remove_duplicates.py @@ -0,0 +1,27 @@ +# Remove the Duplicates from the given array: + +def duplicates(Array): + + duplicates_removed=[] + + for a in Array: + if a not in duplicates_removed: + duplicates_removed.append(a) + + return duplicates_removed + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The array without duplicates:", duplicates(Array)) \ No newline at end of file diff --git a/Duplicates/remove_duplicates.pyc b/Duplicates/remove_duplicates.pyc new file mode 100644 index 0000000..0e28db5 Binary files /dev/null and b/Duplicates/remove_duplicates.pyc differ diff --git a/Duplicates/test_remove_duplicates.py b/Duplicates/test_remove_duplicates.py new file mode 100644 index 0000000..d31fb7d --- /dev/null +++ b/Duplicates/test_remove_duplicates.py @@ -0,0 +1,18 @@ +# Test case for removing duplicates from the given array: + +def test_canassertTrue(): + assert True + +import remove_duplicates + +def test_duplicates(): + + #Arrange: + Array=[5,2,6,2,3,5,6,2] + expected=[5,2,6,3] + + #Act: + actual=remove_duplicates.duplicates(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Identical/__pycache__/identical.cpython-37.pyc b/Identical/__pycache__/identical.cpython-37.pyc new file mode 100644 index 0000000..0624102 Binary files /dev/null and b/Identical/__pycache__/identical.cpython-37.pyc differ diff --git a/Identical/__pycache__/test_identical.cpython-27-PYTEST.pyc b/Identical/__pycache__/test_identical.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..8fed48d Binary files /dev/null and b/Identical/__pycache__/test_identical.cpython-27-PYTEST.pyc differ diff --git a/Identical/__pycache__/test_identical.cpython-37-PYTEST.pyc b/Identical/__pycache__/test_identical.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..b5f9cb4 Binary files /dev/null and b/Identical/__pycache__/test_identical.cpython-37-PYTEST.pyc differ diff --git a/Identical/__pycache__/test_identical.cpython-37-pytest-5.0.1.pyc b/Identical/__pycache__/test_identical.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..a8b6f60 Binary files /dev/null and b/Identical/__pycache__/test_identical.cpython-37-pytest-5.0.1.pyc differ diff --git a/Identical/identical.py b/Identical/identical.py new file mode 100644 index 0000000..95429d1 --- /dev/null +++ b/Identical/identical.py @@ -0,0 +1,47 @@ +# Compare the given array A and B and retruns the index upto which they are identical: + +def identical(A,B): + + if (len(A)>len(B)): + A,B=B,A + + for i in range(0,len(A)): + + index=i + if not (A[i]==B[i]): + index=i-1 + break + index=(len(A)-1) + + return index + + +# Getting Input from User: + +#N=input("Enter the number of elements in Array A: ") + +#A=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array A: ") + + #A.append(Elements) + +# Getting Input from User: + +#N=input("Enter the number of elements for Array B: ") + +#B=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array B: ") + + #B.append(Elements) + +#print("The given Array A is", A) + +#print("The given Array B is", B) + +#print("The identical elements in the given array A and B upto the index of: ",identical(A,B)) diff --git a/Identical/identical.pyc b/Identical/identical.pyc new file mode 100644 index 0000000..6e6633a Binary files /dev/null and b/Identical/identical.pyc differ diff --git a/Identical/test_identical.py b/Identical/test_identical.py new file mode 100644 index 0000000..6249a97 --- /dev/null +++ b/Identical/test_identical.py @@ -0,0 +1,19 @@ +# Test case for the identical elements: + +import identical + +def test_canassertTrue(): + assert True + +def test_identical_array(): + + #Arrange: + A=[3,41,5,64,2,1] + B=[3,41,5,6,2,1] + expected=2 + + #Act: + actual=identical.identical(A,B) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Index and Value/__pycache__/dictionary.cpython-37.pyc b/Index and Value/__pycache__/dictionary.cpython-37.pyc new file mode 100644 index 0000000..4c63d7c Binary files /dev/null and b/Index and Value/__pycache__/dictionary.cpython-37.pyc differ diff --git a/Index and Value/__pycache__/test_dictionary.cpython-27-PYTEST.pyc b/Index and Value/__pycache__/test_dictionary.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..87581c9 Binary files /dev/null and b/Index and Value/__pycache__/test_dictionary.cpython-27-PYTEST.pyc differ diff --git a/Index and Value/__pycache__/test_dictionary.cpython-37-PYTEST.pyc b/Index and Value/__pycache__/test_dictionary.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..2949aa3 Binary files /dev/null and b/Index and Value/__pycache__/test_dictionary.cpython-37-PYTEST.pyc differ diff --git a/Index and Value/__pycache__/test_dictionary.cpython-37-pytest-5.0.1.pyc b/Index and Value/__pycache__/test_dictionary.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..10ef35a Binary files /dev/null and b/Index and Value/__pycache__/test_dictionary.cpython-37-pytest-5.0.1.pyc differ diff --git a/Index and Value/dictionary.py b/Index and Value/dictionary.py new file mode 100644 index 0000000..24611bb --- /dev/null +++ b/Index and Value/dictionary.py @@ -0,0 +1,29 @@ +#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. + +def Dictionary(Array): + + Dictionary={} + X=len(Array) + index=0 + + while (index!=X): + Dictionary[index]=Array[index] + index+=1 + + return Dictionary + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Array in the format", Dictionary(Array)) diff --git a/Index and Value/dictionary.pyc b/Index and Value/dictionary.pyc new file mode 100644 index 0000000..6128ba7 Binary files /dev/null and b/Index and Value/dictionary.pyc differ diff --git a/Index and Value/exam.py b/Index and Value/exam.py new file mode 100644 index 0000000..fc7cef1 --- /dev/null +++ b/Index and Value/exam.py @@ -0,0 +1,28 @@ +N=3 +mod_count=0 +count = 0 +I=0 + +Index = [1,2,3,4,5,6,7,8,9,10] + +while not (count==len(Index)): + + Dictionary = {0:0} + + if I>N: + + I=0 + + if mod_count%N==0: + + Dictionary[count+1]=Index[I] + + count+=1 + mod_count+=1 + I+=1 + + mod_count+=1 + I+=1 + +print Dictionary + \ No newline at end of file diff --git a/Index and Value/test_dictionary.py b/Index and Value/test_dictionary.py new file mode 100644 index 0000000..87d767f --- /dev/null +++ b/Index and Value/test_dictionary.py @@ -0,0 +1,18 @@ +#Test condition for creating dictionary in python: + +import dictionary + +def test_canassertTrue(): + assert True + +def test_dictionary(): + + #Arrange: + Array=[6,2,84,9] + expected={0:6,1:2,2:84,3:9} + + #Actual: + actual=dictionary.Dictionary(Array) + + #Assert + assert expected==actual \ No newline at end of file diff --git a/Indices/Indices.py b/Indices/Indices.py new file mode 100644 index 0000000..f495e8e --- /dev/null +++ b/Indices/Indices.py @@ -0,0 +1,28 @@ +#Given an unsorted integer array A and an integer value X, +# return the indices of the locations where X is found in A. + +def Indices_of_X(Array,X): + + for i in range(0,len(Array)): + + if Array[i]==X: + print (i) + + + # Getting Input from User: + +N=int(input("Enter the number of elements: ")) + +Array=[] + +for a in range(0,N): + + Elements=int(input("Enter the Elements in Array: ")) + + Array.append(Elements) + +print("The Given array is: " ,Array) + +X=int(input("Enter the search Elements: ")) + +Indices_of_X(Array,X) \ No newline at end of file diff --git a/Indices/Indices.pyc b/Indices/Indices.pyc new file mode 100644 index 0000000..5ef71a1 Binary files /dev/null and b/Indices/Indices.pyc differ diff --git a/Indices/__pycache__/test_indices.cpython-27-PYTEST.pyc b/Indices/__pycache__/test_indices.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..04854b2 Binary files /dev/null and b/Indices/__pycache__/test_indices.cpython-27-PYTEST.pyc differ diff --git a/Lengthofarray/Lengthofarray.py b/Lengthofarray/Lengthofarray.py new file mode 100644 index 0000000..d1b656f --- /dev/null +++ b/Lengthofarray/Lengthofarray.py @@ -0,0 +1,28 @@ +# Find the length of the given array: + +def lengthofarray(A): + + count=0 + + while(A[count:]): + count+=1 + + return count + +#Getting Input from user: + +#N=input("Enter the Number of elements: ") + +#A=[] + +#for a in range (0,N): + + #X = input("Enter the Numbers: ") + + #A.append(X) + +#print A + + +#print("The length of the given array is: ") +#print(lengthofarray(A)) diff --git a/Lengthofarray/Lengthofarray.pyc b/Lengthofarray/Lengthofarray.pyc new file mode 100644 index 0000000..1212c86 Binary files /dev/null and b/Lengthofarray/Lengthofarray.pyc differ diff --git a/Lengthofarray/__pycache__/Lengthofarray.cpython-37.pyc b/Lengthofarray/__pycache__/Lengthofarray.cpython-37.pyc new file mode 100644 index 0000000..17a38bb Binary files /dev/null and b/Lengthofarray/__pycache__/Lengthofarray.cpython-37.pyc differ diff --git a/Lengthofarray/__pycache__/test_lengthofarray.cpython-27-PYTEST.pyc b/Lengthofarray/__pycache__/test_lengthofarray.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..6516fec Binary files /dev/null and b/Lengthofarray/__pycache__/test_lengthofarray.cpython-27-PYTEST.pyc differ diff --git a/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-PYTEST.pyc b/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..195b1af Binary files /dev/null and b/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-PYTEST.pyc differ diff --git a/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-pytest-5.0.1.pyc b/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..47b9376 Binary files /dev/null and b/Lengthofarray/__pycache__/test_lengthofarray.cpython-37-pytest-5.0.1.pyc differ diff --git a/Lengthofarray/test_lengthofarray.py b/Lengthofarray/test_lengthofarray.py new file mode 100644 index 0000000..f0525ae --- /dev/null +++ b/Lengthofarray/test_lengthofarray.py @@ -0,0 +1,18 @@ +#Test condition for length of the given array: + +import Lengthofarray + +def test_canassertTrue(): + assert True + +def test_len_of_array(): + + #arrange + A=[4,6,2] + expected=3 + + #act + actual=Lengthofarray.lengthofarray(A) + + #assert + assert expected==actual \ No newline at end of file diff --git a/Lengthofarray/test_lengthofarray.pyc b/Lengthofarray/test_lengthofarray.pyc new file mode 100644 index 0000000..22d98d5 Binary files /dev/null and b/Lengthofarray/test_lengthofarray.pyc differ diff --git a/Mean/Mean_of_the_Array.py b/Mean/Mean_of_the_Array.py new file mode 100644 index 0000000..2708cf1 --- /dev/null +++ b/Mean/Mean_of_the_Array.py @@ -0,0 +1,28 @@ +# Find the mean of the given unsorted Array: + +def Mean_of_Array(Array): + + A=len(Array) + sum=0 + + for a in Array: + sum+=a + + Mean=sum//A + return Mean + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Mean value of given array is", Mean_of_Array(Array)) \ No newline at end of file diff --git a/Mean/Mean_of_the_Array.pyc b/Mean/Mean_of_the_Array.pyc new file mode 100644 index 0000000..758e886 Binary files /dev/null and b/Mean/Mean_of_the_Array.pyc differ diff --git a/Mean/__pycache__/Mean_of_the_Array.cpython-37.pyc b/Mean/__pycache__/Mean_of_the_Array.cpython-37.pyc new file mode 100644 index 0000000..b957661 Binary files /dev/null and b/Mean/__pycache__/Mean_of_the_Array.cpython-37.pyc differ diff --git a/Mean/__pycache__/test_mean.cpython-27-PYTEST.pyc b/Mean/__pycache__/test_mean.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..fec8883 Binary files /dev/null and b/Mean/__pycache__/test_mean.cpython-27-PYTEST.pyc differ diff --git a/Mean/__pycache__/test_mean.cpython-37-PYTEST.pyc b/Mean/__pycache__/test_mean.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..6ef295f Binary files /dev/null and b/Mean/__pycache__/test_mean.cpython-37-PYTEST.pyc differ diff --git a/Mean/__pycache__/test_mean.cpython-37-pytest-5.0.1.pyc b/Mean/__pycache__/test_mean.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..e302ce9 Binary files /dev/null and b/Mean/__pycache__/test_mean.cpython-37-pytest-5.0.1.pyc differ diff --git a/Mean/test_mean.py b/Mean/test_mean.py new file mode 100644 index 0000000..37d791d --- /dev/null +++ b/Mean/test_mean.py @@ -0,0 +1,18 @@ +# Test condition to find the mean of the given array: + +import Mean_of_the_Array + +def test_canassertTrue(): + assert True + +def test_mean(): + + #Arrange: + Array=[6,0,1,7,11,4,3] + expected=4 + + #Actual: + actual=Mean_of_the_Array.Mean_of_Array(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Min and Max/Largest.py b/Min and Max/Largest.py new file mode 100644 index 0000000..68554d3 --- /dev/null +++ b/Min and Max/Largest.py @@ -0,0 +1,28 @@ +# Find the Largest Number in the given Array: + +def Largest_in_Array(Array): + + Largest=0 + + for a in Array: + if (a>Largest): + Largest=a + + return Largest + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Largest number of the given array is", Largest_in_Array(Array)) + diff --git a/Min and Max/Largest.pyc b/Min and Max/Largest.pyc new file mode 100644 index 0000000..0b1e9b1 Binary files /dev/null and b/Min and Max/Largest.pyc differ diff --git a/Min and Max/Minmax.py b/Min and Max/Minmax.py new file mode 100644 index 0000000..fcb1aed --- /dev/null +++ b/Min and Max/Minmax.py @@ -0,0 +1,36 @@ +# 50. Given an unsorted integer array A, find the sum and product of the minimum and maximum values of the array. + +import Largest + +import Smallest + + + +def minmax(Array): + + Max=Largest.Largest_in_Array(Array) + Min=Smallest.Smallest_in_Array(Array) + + Sum=Min+Max + Product=Min*Max + + print("The Sum of Minimum and Maximum Value is: ", Sum) + print("The Prouduct of Minimum and Maximum Value is: ",Product) + +# Getting Input from User: + +N=input("Enter the number of elements: ") + +Array=[] + +for a in range(0,N): + + Elements=input("Enter the Elements in Array: ") + + Array.append(Elements) + +print("The given Array is", Array) + +minmax(Array) + + diff --git a/Min and Max/Smallest.py b/Min and Max/Smallest.py new file mode 100644 index 0000000..0a8d9d6 --- /dev/null +++ b/Min and Max/Smallest.py @@ -0,0 +1,28 @@ +# Find the smallest number in the given Array: + +def Smallest_in_Array(Array): + + Smallest=2147483647 + + for a in Array: + if (amaxcount): + maxcount=count + mode=a + + return mode + + +#Getting Input from User: + +N=int(input("Enter the number of elements: ")) + +Array=[] + +for a in range(0,N): + + Elements=int(input("Enter the Elements in Array: ")) + + Array.append(Elements) + +print("The given Array is", Array) + +print("The Mode of given array is", Mode(Array)) \ No newline at end of file diff --git a/Mode/Mode.pyc b/Mode/Mode.pyc new file mode 100644 index 0000000..f60a452 Binary files /dev/null and b/Mode/Mode.pyc differ diff --git a/Mode/__pycache__/Mode.cpython-37.pyc b/Mode/__pycache__/Mode.cpython-37.pyc new file mode 100644 index 0000000..65582f2 Binary files /dev/null and b/Mode/__pycache__/Mode.cpython-37.pyc differ diff --git a/Mode/__pycache__/test_Mode.cpython-27-PYTEST.pyc b/Mode/__pycache__/test_Mode.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..9396349 Binary files /dev/null and b/Mode/__pycache__/test_Mode.cpython-27-PYTEST.pyc differ diff --git a/Mode/__pycache__/test_Mode.cpython-37-PYTEST.pyc b/Mode/__pycache__/test_Mode.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..5070b43 Binary files /dev/null and b/Mode/__pycache__/test_Mode.cpython-37-PYTEST.pyc differ diff --git a/Mode/__pycache__/test_Mode.cpython-37-pytest-5.0.1.pyc b/Mode/__pycache__/test_Mode.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..7531bfa Binary files /dev/null and b/Mode/__pycache__/test_Mode.cpython-37-pytest-5.0.1.pyc differ diff --git a/Mode/test_Mode.py b/Mode/test_Mode.py new file mode 100644 index 0000000..1269de7 --- /dev/null +++ b/Mode/test_Mode.py @@ -0,0 +1,18 @@ +#Test condition to find the mode of the given array: + +import Mode + +def test_canassertTrue(): + assert True + +def test_Mode(): + + #Arrange + Array=[7,2,0,2,2] + expected=2 + + #Act + actual=Mode.Mode(Array) + + #Assert + assert expected==actual diff --git a/Multiple Integers/Repeated.py b/Multiple Integers/Repeated.py new file mode 100644 index 0000000..0ebc7d9 --- /dev/null +++ b/Multiple Integers/Repeated.py @@ -0,0 +1,33 @@ +# Give an unsorted integer array A and its Integer value X, find if X is found more then once in A: + +def Is_repeated(Array,X): + + flag=False + count=0 + for i in Array: + + if i==X: + count+=1 + + if count==2: + flag=True + return flag + + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The Given array is: " ,Array) + +#X=input("Enter the search Elements: ") + +#print ("The Index of the given Search elements is: " ,Is_repeated(Array,X)) diff --git a/Multiple Integers/Repeated.pyc b/Multiple Integers/Repeated.pyc new file mode 100644 index 0000000..503bd3b Binary files /dev/null and b/Multiple Integers/Repeated.pyc differ diff --git a/Multiple Integers/__pycache__/Repeated.cpython-37.pyc b/Multiple Integers/__pycache__/Repeated.cpython-37.pyc new file mode 100644 index 0000000..18bb910 Binary files /dev/null and b/Multiple Integers/__pycache__/Repeated.cpython-37.pyc differ diff --git a/Multiple Integers/__pycache__/test_repeated.cpython-27-PYTEST.pyc b/Multiple Integers/__pycache__/test_repeated.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..66b1f1d Binary files /dev/null and b/Multiple Integers/__pycache__/test_repeated.cpython-27-PYTEST.pyc differ diff --git a/Multiple Integers/__pycache__/test_repeated.cpython-37-PYTEST.pyc b/Multiple Integers/__pycache__/test_repeated.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..967a06d Binary files /dev/null and b/Multiple Integers/__pycache__/test_repeated.cpython-37-PYTEST.pyc differ diff --git a/Multiple Integers/__pycache__/test_repeated.cpython-37-pytest-5.0.1.pyc b/Multiple Integers/__pycache__/test_repeated.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..8256c5d Binary files /dev/null and b/Multiple Integers/__pycache__/test_repeated.cpython-37-pytest-5.0.1.pyc differ diff --git a/Multiple Integers/test_repeated.py b/Multiple Integers/test_repeated.py new file mode 100644 index 0000000..c9195e7 --- /dev/null +++ b/Multiple Integers/test_repeated.py @@ -0,0 +1,22 @@ +# Test condition for the repeated Numbers: + +import Repeated + +def test_canassertTrue(): + assert True + +def test_isRepeated(): + + #arrange + + Array=[5,6,3,4,3,9] + X=9 + expected=False + + #act + actual=Repeated.Is_repeated(Array,X) + + #assert + assert expected==actual + + diff --git a/Numbers/__pycache__/even_numbers.cpython-37.pyc b/Numbers/__pycache__/even_numbers.cpython-37.pyc new file mode 100644 index 0000000..b35c5da Binary files /dev/null and b/Numbers/__pycache__/even_numbers.cpython-37.pyc differ diff --git a/Numbers/__pycache__/odd_numbers.cpython-37.pyc b/Numbers/__pycache__/odd_numbers.cpython-37.pyc new file mode 100644 index 0000000..24768b3 Binary files /dev/null and b/Numbers/__pycache__/odd_numbers.cpython-37.pyc differ diff --git a/Numbers/__pycache__/perfect_sq.cpython-37.pyc b/Numbers/__pycache__/perfect_sq.cpython-37.pyc new file mode 100644 index 0000000..e44fa19 Binary files /dev/null and b/Numbers/__pycache__/perfect_sq.cpython-37.pyc differ diff --git a/Numbers/__pycache__/prime_numbers.cpython-37.pyc b/Numbers/__pycache__/prime_numbers.cpython-37.pyc new file mode 100644 index 0000000..70c0550 Binary files /dev/null and b/Numbers/__pycache__/prime_numbers.cpython-37.pyc differ diff --git a/Numbers/__pycache__/test_even_numbers.cpython-27-PYTEST.pyc b/Numbers/__pycache__/test_even_numbers.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..6bb79fa Binary files /dev/null and b/Numbers/__pycache__/test_even_numbers.cpython-27-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_even_numbers.cpython-37-PYTEST.pyc b/Numbers/__pycache__/test_even_numbers.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..6a8d322 Binary files /dev/null and b/Numbers/__pycache__/test_even_numbers.cpython-37-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_even_numbers.cpython-37-pytest-5.0.1.pyc b/Numbers/__pycache__/test_even_numbers.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..4e87df7 Binary files /dev/null and b/Numbers/__pycache__/test_even_numbers.cpython-37-pytest-5.0.1.pyc differ diff --git a/Numbers/__pycache__/test_odd_numbers.cpython-27-PYTEST.pyc b/Numbers/__pycache__/test_odd_numbers.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..c862032 Binary files /dev/null and b/Numbers/__pycache__/test_odd_numbers.cpython-27-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_odd_numbers.cpython-37-PYTEST.pyc b/Numbers/__pycache__/test_odd_numbers.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..9f0dc12 Binary files /dev/null and b/Numbers/__pycache__/test_odd_numbers.cpython-37-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_odd_numbers.cpython-37-pytest-5.0.1.pyc b/Numbers/__pycache__/test_odd_numbers.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..adb0578 Binary files /dev/null and b/Numbers/__pycache__/test_odd_numbers.cpython-37-pytest-5.0.1.pyc differ diff --git a/Numbers/__pycache__/test_prime.cpython-27-PYTEST.pyc b/Numbers/__pycache__/test_prime.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..fb21f83 Binary files /dev/null and b/Numbers/__pycache__/test_prime.cpython-27-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_prime.cpython-37-PYTEST.pyc b/Numbers/__pycache__/test_prime.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..4598658 Binary files /dev/null and b/Numbers/__pycache__/test_prime.cpython-37-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_prime.cpython-37-pytest-5.0.1.pyc b/Numbers/__pycache__/test_prime.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..e0a786c Binary files /dev/null and b/Numbers/__pycache__/test_prime.cpython-37-pytest-5.0.1.pyc differ diff --git a/Numbers/__pycache__/test_square.cpython-27-PYTEST.pyc b/Numbers/__pycache__/test_square.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..42dfed9 Binary files /dev/null and b/Numbers/__pycache__/test_square.cpython-27-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_square.cpython-37-PYTEST.pyc b/Numbers/__pycache__/test_square.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..4bbb66e Binary files /dev/null and b/Numbers/__pycache__/test_square.cpython-37-PYTEST.pyc differ diff --git a/Numbers/__pycache__/test_square.cpython-37-pytest-5.0.1.pyc b/Numbers/__pycache__/test_square.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..2924b1b Binary files /dev/null and b/Numbers/__pycache__/test_square.cpython-37-pytest-5.0.1.pyc differ diff --git a/Numbers/even_numbers.py b/Numbers/even_numbers.py new file mode 100644 index 0000000..705b957 --- /dev/null +++ b/Numbers/even_numbers.py @@ -0,0 +1,27 @@ +# Find the even number in the given array: + +def Even_numbers(Array): + + Even_array=[] + for a in Array: + + if (a%2==0): + Even_array.append(a) + + return Even_array + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Even number of the given array is", Even_numbers(Array)) \ No newline at end of file diff --git a/Numbers/even_numbers.pyc b/Numbers/even_numbers.pyc new file mode 100644 index 0000000..be55b4f Binary files /dev/null and b/Numbers/even_numbers.pyc differ diff --git a/Numbers/odd_numbers.py b/Numbers/odd_numbers.py new file mode 100644 index 0000000..dd9d8b6 --- /dev/null +++ b/Numbers/odd_numbers.py @@ -0,0 +1,27 @@ +# Return the odd numbers in the given array: + +def Odd_numbers(Array): + + Odd_array=[] + for a in Array: + + if not (a%2==0): + Odd_array.append(a) + + return Odd_array + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Odd numbers in the given array is", Odd_numbers(Array)) \ No newline at end of file diff --git a/Numbers/odd_numbers.pyc b/Numbers/odd_numbers.pyc new file mode 100644 index 0000000..9b5b0ff Binary files /dev/null and b/Numbers/odd_numbers.pyc differ diff --git a/Numbers/perfect_sq.py b/Numbers/perfect_sq.py new file mode 100644 index 0000000..7acff9c --- /dev/null +++ b/Numbers/perfect_sq.py @@ -0,0 +1,42 @@ +# Find the perfect squares in the given array: + +import math + +def Is_perfect_sq(X): + + flag=True + M=math.sqrt(X) + N=round(M) + + if not (M==N): + flag=False + + return flag + +def perfect_sq_array(Array): + + sq_array=[] + + for a in Array: + + if (Is_perfect_sq(a)): + sq_array.append(a) + + return sq_array + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The perfect squares in the given array is", perfect_sq_array(Array)) + diff --git a/Numbers/perfect_sq.pyc b/Numbers/perfect_sq.pyc new file mode 100644 index 0000000..92cac91 Binary files /dev/null and b/Numbers/perfect_sq.pyc differ diff --git a/Numbers/prime_numbers.py b/Numbers/prime_numbers.py new file mode 100644 index 0000000..924ce24 --- /dev/null +++ b/Numbers/prime_numbers.py @@ -0,0 +1,44 @@ +# Return the prime number from the given array: + +import math + +def Isprime(N): + flag=True + if (N<=1): + flag=False + if (N==2): + return flag + + for i in range(2,int(math.sqrt(N)+1)): + + if (N%i==0): + flag=False + break + return flag + +def prime_array(Array): + + prime_array=[] + + for a in Array: + if (Isprime(a)): + prime_array.append(a) + + return prime_array + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The prime number of the given array is", prime_array(Array)) + diff --git a/Numbers/prime_numbers.pyc b/Numbers/prime_numbers.pyc new file mode 100644 index 0000000..da421de Binary files /dev/null and b/Numbers/prime_numbers.pyc differ diff --git a/Numbers/test_even_numbers.py b/Numbers/test_even_numbers.py new file mode 100644 index 0000000..03cee52 --- /dev/null +++ b/Numbers/test_even_numbers.py @@ -0,0 +1,18 @@ +# Test condition for the even numbers in the given array: + +import even_numbers + +def test_canassertTrue(): + assert True + +def test_even_numbers(): + + #Arrange: + Array=[8,1,5,3,6,4] + expected=[8,6,4] + + #Act: + actual=even_numbers.Even_numbers(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Numbers/test_odd_numbers.py b/Numbers/test_odd_numbers.py new file mode 100644 index 0000000..155ef1c --- /dev/null +++ b/Numbers/test_odd_numbers.py @@ -0,0 +1,18 @@ +# Test condition for the odd numbers in the given array: + +import odd_numbers + +def test_canassertTrue(): + assert True + +def test_odd_numbers(): + + #Arrange: + Array=[8,1,5,3,6,4] + expected=[1,5,3] + + #Act: + actual=odd_numbers.Odd_numbers(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Numbers/test_prime.py b/Numbers/test_prime.py new file mode 100644 index 0000000..82f9054 --- /dev/null +++ b/Numbers/test_prime.py @@ -0,0 +1,18 @@ +# Test condition for finding prime numbers in the given array: + +import prime_numbers + +def test_canassertTrue(): + assert True + +def test_prime(): + + #Arrange: + Array=[11,5,9,6,2] + expected=[11,5,2] + + #Act: + actual=prime_numbers.prime_array(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Numbers/test_square.py b/Numbers/test_square.py new file mode 100644 index 0000000..3fa610e --- /dev/null +++ b/Numbers/test_square.py @@ -0,0 +1,18 @@ +# Test condition for the perfect square in the given array: + +import perfect_sq + +def test_canassertTrue(): + assert True + +def test_square(): + + #Arrange: + Array=[16,5,9,6,2] + expected=[16,9] + + #Act: + actual=perfect_sq.perfect_sq_array(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Questions.md b/Questions.md index 0e47ccc..0d57ebc 100644 --- a/Questions.md +++ b/Questions.md @@ -36,8 +36,8 @@ 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. +*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. diff --git a/Reverse of Array/__pycache__/test_reverse.cpython-27-PYTEST.pyc b/Reverse of Array/__pycache__/test_reverse.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..23cf611 Binary files /dev/null and b/Reverse of Array/__pycache__/test_reverse.cpython-27-PYTEST.pyc differ diff --git a/Reverse of Array/__pycache__/test_reverse.cpython-37-PYTEST.pyc b/Reverse of Array/__pycache__/test_reverse.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..6e236fd Binary files /dev/null and b/Reverse of Array/__pycache__/test_reverse.cpython-37-PYTEST.pyc differ diff --git a/Reverse of Array/__pycache__/test_reverse.cpython-37-pytest-5.0.1.pyc b/Reverse of Array/__pycache__/test_reverse.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..7f1b29d Binary files /dev/null and b/Reverse of Array/__pycache__/test_reverse.cpython-37-pytest-5.0.1.pyc differ diff --git a/Reverse of Array/rev_array.py b/Reverse of Array/rev_array.py new file mode 100644 index 0000000..b327b1d --- /dev/null +++ b/Reverse of Array/rev_array.py @@ -0,0 +1,32 @@ +# The reverse of the given array: + +def Rev_array(Array): + + Reverse=[] + index=1 + Length = len(Array) + + while (index!=Length): + + elements=(Array[-index]) + Reverse.append(elements) + index+=1 + + Reverse.append(Array[0]) + return Reverse + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The reverse order of the given array is:", Rev_array(Array)) \ No newline at end of file diff --git a/Reverse of Array/rev_array.pyc b/Reverse of Array/rev_array.pyc new file mode 100644 index 0000000..2aa369d Binary files /dev/null and b/Reverse of Array/rev_array.pyc differ diff --git a/Reverse of Array/rev_elements.py b/Reverse of Array/rev_elements.py new file mode 100644 index 0000000..5e20bd0 --- /dev/null +++ b/Reverse of Array/rev_elements.py @@ -0,0 +1,32 @@ +# Print the elements in the given array by the reverse order: + +def Rev_elements(Array): + + + index=1 + Length = len(Array) + + + while (index!=Length): + + elements=(Array[-index]) + print elements + index+=1 + + print Array[0] + +# Getting Input from User: + +N=input("Enter the number of elements: ") + +Array=[] + +for a in range(0,N): + + Elements=input("Enter the Elements in Array: ") + + Array.append(Elements) + +print("The given Array is", Array) + +Rev_elements(Array) \ No newline at end of file diff --git a/Reverse of Array/test_reverse.py b/Reverse of Array/test_reverse.py new file mode 100644 index 0000000..9cd90c7 --- /dev/null +++ b/Reverse of Array/test_reverse.py @@ -0,0 +1,18 @@ +# Test condition for the reverse of the given array: + +import rev_array + +def test_canassertTrue(): + assert True + +def test_reverse(): + + #Arrange: + Array=[8,0,1,4,2,9] + expected=[9,2,4,1,0,8] + + #Act + actual=rev_array.Rev_array(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/K_rotations_left.py b/Rotation/K_rotations_left.py new file mode 100644 index 0000000..715a9ce --- /dev/null +++ b/Rotation/K_rotations_left.py @@ -0,0 +1,29 @@ +def by_left(Array,K): + + position=1 + + while not (position>K): + + X=Array.pop(0) + Array.append(X) + position+=1 + + return Array + +# Getting Input from User: + +#K=input("Enter the number of Rotations: ") + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The left rotations of the given array is", by_left(Array,K)) \ No newline at end of file diff --git a/Rotation/K_rotations_left.pyc b/Rotation/K_rotations_left.pyc new file mode 100644 index 0000000..a67f925 Binary files /dev/null and b/Rotation/K_rotations_left.pyc differ diff --git a/Rotation/K_rotations_right.py b/Rotation/K_rotations_right.py new file mode 100644 index 0000000..e8e9536 --- /dev/null +++ b/Rotation/K_rotations_right.py @@ -0,0 +1,31 @@ +# Rotate the given array by K positions: + +def by_right(Array,K): + + position=1 + + while not (position>K): + + X=Array.pop(-1) + Array.insert(0,X) + position+=1 + + return Array + +# Getting Input from User: + +#K=input("Enter the number of Rotations: ") + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The right rotations of the given array is", by_right(Array,K)) diff --git a/Rotation/K_rotations_right.pyc b/Rotation/K_rotations_right.pyc new file mode 100644 index 0000000..bdf1232 Binary files /dev/null and b/Rotation/K_rotations_right.pyc differ diff --git a/Rotation/One_left.py b/Rotation/One_left.py new file mode 100644 index 0000000..ac90bce --- /dev/null +++ b/Rotation/One_left.py @@ -0,0 +1,30 @@ +# Rotate the given array by one position to the left: + +def One_left(Array): + + #rotate=[] + X=Array.pop(0) + + #for a in Array: + #rotate.append(a) + + #To Rotate Left: + Array.append(X) + + return Array + + #Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The one bit left rotation of the given array is:", One_left(Array)) \ No newline at end of file diff --git a/Rotation/One_left.pyc b/Rotation/One_left.pyc new file mode 100644 index 0000000..092bfa2 Binary files /dev/null and b/Rotation/One_left.pyc differ diff --git a/Rotation/One_right.py b/Rotation/One_right.py new file mode 100644 index 0000000..f4ca798 --- /dev/null +++ b/Rotation/One_right.py @@ -0,0 +1,29 @@ +# Rotate the given array by moving one position to right: + +def One_right(Array): + + #rotate=[] + X=Array.pop(-1) + +# To rotate one bit by left: + Array.insert(0,X) + #for a in Array: + #rotate.append(a) + + return Array + + #Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The first rotation of the given array is",One_right(Array)) \ No newline at end of file diff --git a/Rotation/One_right.pyc b/Rotation/One_right.pyc new file mode 100644 index 0000000..4094082 Binary files /dev/null and b/Rotation/One_right.pyc differ diff --git a/Rotation/__pycache__/K_rotations_left.cpython-37.pyc b/Rotation/__pycache__/K_rotations_left.cpython-37.pyc new file mode 100644 index 0000000..1cc1461 Binary files /dev/null and b/Rotation/__pycache__/K_rotations_left.cpython-37.pyc differ diff --git a/Rotation/__pycache__/K_rotations_right.cpython-37.pyc b/Rotation/__pycache__/K_rotations_right.cpython-37.pyc new file mode 100644 index 0000000..2cab4ba Binary files /dev/null and b/Rotation/__pycache__/K_rotations_right.cpython-37.pyc differ diff --git a/Rotation/__pycache__/One_left.cpython-37.pyc b/Rotation/__pycache__/One_left.cpython-37.pyc new file mode 100644 index 0000000..f223d9b Binary files /dev/null and b/Rotation/__pycache__/One_left.cpython-37.pyc differ diff --git a/Rotation/__pycache__/One_right.cpython-37.pyc b/Rotation/__pycache__/One_right.cpython-37.pyc new file mode 100644 index 0000000..8a9955d Binary files /dev/null and b/Rotation/__pycache__/One_right.cpython-37.pyc differ diff --git a/Rotation/__pycache__/index_R_left.cpython-37.pyc b/Rotation/__pycache__/index_R_left.cpython-37.pyc new file mode 100644 index 0000000..3dd0c30 Binary files /dev/null and b/Rotation/__pycache__/index_R_left.cpython-37.pyc differ diff --git a/Rotation/__pycache__/index_R_right.cpython-37.pyc b/Rotation/__pycache__/index_R_right.cpython-37.pyc new file mode 100644 index 0000000..376d76b Binary files /dev/null and b/Rotation/__pycache__/index_R_right.cpython-37.pyc differ diff --git a/Rotation/__pycache__/index_left.cpython-37.pyc b/Rotation/__pycache__/index_left.cpython-37.pyc new file mode 100644 index 0000000..1a32b4b Binary files /dev/null and b/Rotation/__pycache__/index_left.cpython-37.pyc differ diff --git a/Rotation/__pycache__/index_right.cpython-37.pyc b/Rotation/__pycache__/index_right.cpython-37.pyc new file mode 100644 index 0000000..2c285f0 Binary files /dev/null and b/Rotation/__pycache__/index_right.cpython-37.pyc differ diff --git a/Rotation/__pycache__/test_I_index.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_I_index.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..84a6894 Binary files /dev/null and b/Rotation/__pycache__/test_I_index.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_I_index.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_I_index.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..c3db2c0 Binary files /dev/null and b/Rotation/__pycache__/test_I_index.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_I_index.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_I_index.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..5ae9809 Binary files /dev/null and b/Rotation/__pycache__/test_I_index.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/test_K_rotations.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_K_rotations.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..39136f2 Binary files /dev/null and b/Rotation/__pycache__/test_K_rotations.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_K_rotations.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_K_rotations.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..36ed7ad Binary files /dev/null and b/Rotation/__pycache__/test_K_rotations.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_K_rotations.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_K_rotations.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..419df91 Binary files /dev/null and b/Rotation/__pycache__/test_K_rotations.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/test_index.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_index.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..e28a936 Binary files /dev/null and b/Rotation/__pycache__/test_index.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_index.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_index.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..b368698 Binary files /dev/null and b/Rotation/__pycache__/test_index.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_index.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_index.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..cf16514 Binary files /dev/null and b/Rotation/__pycache__/test_index.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/test_one_left.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_one_left.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..9ae96ad Binary files /dev/null and b/Rotation/__pycache__/test_one_left.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_one_left.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_one_left.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..35a3424 Binary files /dev/null and b/Rotation/__pycache__/test_one_left.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_one_left.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_one_left.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..7b8c1c1 Binary files /dev/null and b/Rotation/__pycache__/test_one_left.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/test_one_right.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_one_right.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..cc44a24 Binary files /dev/null and b/Rotation/__pycache__/test_one_right.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_one_right.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_one_right.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..ab70f9e Binary files /dev/null and b/Rotation/__pycache__/test_one_right.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_one_right.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_one_right.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..74567a1 Binary files /dev/null and b/Rotation/__pycache__/test_one_right.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/test_two_right.cpython-27-PYTEST.pyc b/Rotation/__pycache__/test_two_right.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..ac07e28 Binary files /dev/null and b/Rotation/__pycache__/test_two_right.cpython-27-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_two_right.cpython-37-PYTEST.pyc b/Rotation/__pycache__/test_two_right.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..2629652 Binary files /dev/null and b/Rotation/__pycache__/test_two_right.cpython-37-PYTEST.pyc differ diff --git a/Rotation/__pycache__/test_two_right.cpython-37-pytest-5.0.1.pyc b/Rotation/__pycache__/test_two_right.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..3d9b64d Binary files /dev/null and b/Rotation/__pycache__/test_two_right.cpython-37-pytest-5.0.1.pyc differ diff --git a/Rotation/__pycache__/two_right.cpython-37.pyc b/Rotation/__pycache__/two_right.cpython-37.pyc new file mode 100644 index 0000000..24414a3 Binary files /dev/null and b/Rotation/__pycache__/two_right.cpython-37.pyc differ diff --git a/Rotation/complete_rotation_right.py b/Rotation/complete_rotation_right.py new file mode 100644 index 0000000..0aa761d --- /dev/null +++ b/Rotation/complete_rotation_right.py @@ -0,0 +1,18 @@ +# Write the rotation code for the given for one complete Rotations: +# Without using Inbuilt functions. + +def complete_rotation_right(Array): + + count=0 + while not (count==len(Array)): + + index=-1 + swap=0 + while not (index==len(Array)): + Array[index],swap=swap,Array[index] + index+=1 + count+=1 + return Array + +Array=[1,2,3,4,5] +print(complete_rotation_right(Array)) \ No newline at end of file diff --git a/Rotation/index_R_left.py b/Rotation/index_R_left.py new file mode 100644 index 0000000..4b68933 --- /dev/null +++ b/Rotation/index_R_left.py @@ -0,0 +1,38 @@ +## Rotate the given array by R positions and find the Integer in the given index I: + + +def by_left(Array,R,I): + + Rotation=1 + + while not (Rotation>R): + + X=Array.pop(0) + Array.append(X) + Rotation+=1 + + Value=-1 + + if (IR): + + X=Array.pop(-1) + Array.insert(0,X) + Rotation+=1 + + Value=-1 + + if (I2): + + X=Array.pop(0) + Array.append(X) + rotation+=1 + + Value=Array[3] + return Value + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The third index of the given array after two rotations:",Left_Index(Array) ) \ No newline at end of file diff --git a/Rotation/index_left.pyc b/Rotation/index_left.pyc new file mode 100644 index 0000000..454d110 Binary files /dev/null and b/Rotation/index_left.pyc differ diff --git a/Rotation/index_right.py b/Rotation/index_right.py new file mode 100644 index 0000000..c10197c --- /dev/null +++ b/Rotation/index_right.py @@ -0,0 +1,30 @@ +# Find the 3rd index of the given array after two rotations: + +def Right_Index(Array): + + rotation=1 + + while not (rotation>2): + + X=Array.pop(-1) + Array.insert(0,X) + rotation+=1 + + Value=Array[3] + return Value + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The third index of the given array after two rotations:",Right_Index(Array) ) \ No newline at end of file diff --git a/Rotation/index_right.pyc b/Rotation/index_right.pyc new file mode 100644 index 0000000..1ab4938 Binary files /dev/null and b/Rotation/index_right.pyc differ diff --git a/Rotation/test_I_index.py b/Rotation/test_I_index.py new file mode 100644 index 0000000..e1b379d --- /dev/null +++ b/Rotation/test_I_index.py @@ -0,0 +1,40 @@ +# Test case for Ith index after R rotations: + +def test_canassertTrue(): + assert True + +# Rotation to the Right: + +import index_R_right + +def test_Right(): + + #Arrange: + Array=[6,2,5,9,3] + R=3 + I=2 + expected=3 + + #Act: + actual=index_R_right.by_right(Array,R,I) + + #Assert: + assert expected==actual + +# Rotation to the Left: + +import index_R_left + +def test_Left(): + + #Arrange: + Array=[4,9,1,0,3] + R=2 + I=4 + expected=9 + + #Act: + actual=index_R_left.by_left(Array,R,I) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/test_K_rotations.py b/Rotation/test_K_rotations.py new file mode 100644 index 0000000..f425b19 --- /dev/null +++ b/Rotation/test_K_rotations.py @@ -0,0 +1,39 @@ +# Test case for Rotating the given array by K times: + +def test_canasssertTrue(): + assert True + +# For rotating right: + +import K_rotations_right + +def test_rotate_right(): + + #Arrange: + Array=[6,2,8,1,0,5] + K=3 + expected=[1,0,5,6,2,8] + + #Act: + actual=K_rotations_right.by_right(Array,K) + + #Assert: + assert expected==actual + + +# For rotating Left: + +import K_rotations_left + +def test_rotate_left(): + + #Arrange: + Array=[6,9,2,0,1] + K=2 + expected=[2,0,1,6,9] + + #Act: + actual=K_rotations_left.by_left(Array,K) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/test_index.py b/Rotation/test_index.py new file mode 100644 index 0000000..78d9bf7 --- /dev/null +++ b/Rotation/test_index.py @@ -0,0 +1,36 @@ +# Test condition for finding the value in the 3rd index after Two rotations of the given array: + +def test_canassertTrue(): + assert True + +# Rotation to right: + +import index_right + +def test_right_index(): + + #Arrange: + Array=[7,3,8,1,5] + expected=3 + + #Act: + actual=index_right.Right_Index(Array) + + #Assert: + assert expected==actual + +# Rotation to Left: + +import index_left + +def test_left_index(): + + #Arrange: + Array=[7,2,8,4,6] + expected=7 + + #Act: + actual=index_left.Left_Index(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/test_one_left.py b/Rotation/test_one_left.py new file mode 100644 index 0000000..1ab726e --- /dev/null +++ b/Rotation/test_one_left.py @@ -0,0 +1,18 @@ +# Test ccondition for rotating array to left by one bit: + +import One_left + +def test_canassertTrue(): + assert True + +def test_one_left(): + + #Arrange: + Array=[7,9,2,4,0,5] + expected=[9,2,4,0,5,7] + + #Act: + actual=One_left.One_left(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/test_one_right.py b/Rotation/test_one_right.py new file mode 100644 index 0000000..070b335 --- /dev/null +++ b/Rotation/test_one_right.py @@ -0,0 +1,18 @@ +# Test ccondition for rotating array to left by one bit: + +import One_right + +def test_canassertTrue(): + assert True + +def test_one_right(): + + #Arrange: + Array=[7,9,2,4,0,5] + expected=[5,7,9,2,4,0] + + #Act: + actual=One_right.One_right(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/test_two_right.py b/Rotation/test_two_right.py new file mode 100644 index 0000000..caa7bf9 --- /dev/null +++ b/Rotation/test_two_right.py @@ -0,0 +1,18 @@ +# Test case for rotation of the array by the two bits: + +import two_right + +def test_canassertTrue(): + assert True + +def test_two_right(): + + #Arrange: + Array=[8,3,0,1,2] + expected=[1,2,8,3,0] + + #Act: + actual=two_right.Two_right(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Rotation/two_left.py b/Rotation/two_left.py new file mode 100644 index 0000000..4892be7 --- /dev/null +++ b/Rotation/two_left.py @@ -0,0 +1,39 @@ +# Rotate the given array to the right by two positions: + +def Two_left(Array): + + #move=[] + #rotate=[] + position=0 + + #To rotate right by two bits: + while not (position>=2): + + X=Array.pop(0) + Array.append(X) + position+=1 + + #for a in Array: + #rotate.insert(0,a) + + #rotate+=move + + #return rotate + return Array + +# Getting Input from User: + +N=input("Enter the number of elements: ") + +Array=[] + +for a in range(0,N): + + Elements=input("Enter the Elements in Array: ") + + Array.append(Elements) + +print("The given Array is", Array) + +print("The rotation of the given array by the two positions to the right is:",Two_left(Array) ) + diff --git a/Rotation/two_right.py b/Rotation/two_right.py new file mode 100644 index 0000000..e0feccd --- /dev/null +++ b/Rotation/two_right.py @@ -0,0 +1,36 @@ +# Rotate the given array to the right by two positions: + +def Two_right(Array): + + #rotate=[] + position=0 + + #To rotate right by two bits: + while not (position>=2): + + X=Array.pop(-1) + Array.insert(0,X) + position+=1 + + #for a in Array: + #rotate.append(a) + + #return rotate + return Array + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The rotation of the given array by the two positions to the right is:",Two_right(Array) ) + diff --git a/Rotation/two_right.pyc b/Rotation/two_right.pyc new file mode 100644 index 0000000..c6a5efe Binary files /dev/null and b/Rotation/two_right.pyc differ diff --git a/Same Array/__pycache__/same_array.cpython-37.pyc b/Same Array/__pycache__/same_array.cpython-37.pyc new file mode 100644 index 0000000..1966849 Binary files /dev/null and b/Same Array/__pycache__/same_array.cpython-37.pyc differ diff --git a/Same Array/__pycache__/test_same_array.cpython-27-PYTEST.pyc b/Same Array/__pycache__/test_same_array.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..fa1cb0e Binary files /dev/null and b/Same Array/__pycache__/test_same_array.cpython-27-PYTEST.pyc differ diff --git a/Same Array/__pycache__/test_same_array.cpython-37-PYTEST.pyc b/Same Array/__pycache__/test_same_array.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..6af880e Binary files /dev/null and b/Same Array/__pycache__/test_same_array.cpython-37-PYTEST.pyc differ diff --git a/Same Array/__pycache__/test_same_array.cpython-37-pytest-5.0.1.pyc b/Same Array/__pycache__/test_same_array.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..244aa48 Binary files /dev/null and b/Same Array/__pycache__/test_same_array.cpython-37-pytest-5.0.1.pyc differ diff --git a/Same Array/same_array.py b/Same Array/same_array.py new file mode 100644 index 0000000..a4ac7b3 --- /dev/null +++ b/Same Array/same_array.py @@ -0,0 +1,46 @@ +#Find the both array are same: + +def Is_same(A,B): + + flag=True + + if (len(A)!=len(B)): + flag=False + + for a in A: + for b in B: + if (a!=b): + flag=False + break + + return flag + +# Getting Input from User: + +#M=input("Enter the A elements: ") + +#A=[] + +#for a in range(0,M): + + #A_Elements=input("Enter the Elements in Array: ") + + #A.append(A_Elements) + + +#N=input("Enter the B elements: ") + +#B=[] + +#for b in range(0,N): + + #B_Elements=input("Enter the Elements in Array: ") + + #B.append(B_Elements) + + +#print("The given Array (A) is", A) + +#print("The given Array (B) is", B) + +#print("The given arrays A and B are same", Is_same(A,B)) diff --git a/Same Array/same_array.pyc b/Same Array/same_array.pyc new file mode 100644 index 0000000..5022d4a Binary files /dev/null and b/Same Array/same_array.pyc differ diff --git a/Same Array/test_same_array.py b/Same Array/test_same_array.py new file mode 100644 index 0000000..88a7c83 --- /dev/null +++ b/Same Array/test_same_array.py @@ -0,0 +1,21 @@ +#Test condition to find the same array: + +import same_array + +def test_canassertTrue(): + assert True + +def test_Is_same(): + + #Arrange: + A=[8,3,1,9] + B=[8,3,1,9] + expected=True + + #Act: + actual=same_array.Is_same(A,B) + + #Assert: + assert expected==actual + + diff --git a/Smallest and Largest in Array/Kth_largest.py b/Smallest and Largest in Array/Kth_largest.py new file mode 100644 index 0000000..41d73c4 --- /dev/null +++ b/Smallest and Largest in Array/Kth_largest.py @@ -0,0 +1,45 @@ +# Find the Kth largest and smallest number in the given array: + +import Largest + +def Kth_Largest(Array,K): + + Descending=[] + Length=len(Array) + count=0 + + while not(count==Length): + + X=Largest.Largest_in_Array(Array) + Descending.append(X) + Array.remove(X) + count+=1 + + Result=Descending[K-1] + return Result + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#K=input("Enter the value of K: ") + +#print("The given Kth Largest number in the given array is",Kth_Largest(Array,K) ) + + + + + + + + diff --git a/Smallest and Largest in Array/Kth_largest.pyc b/Smallest and Largest in Array/Kth_largest.pyc new file mode 100644 index 0000000..3ce488a Binary files /dev/null and b/Smallest and Largest in Array/Kth_largest.pyc differ diff --git a/Smallest and Largest in Array/Kth_smallest.py b/Smallest and Largest in Array/Kth_smallest.py new file mode 100644 index 0000000..1fd671e --- /dev/null +++ b/Smallest and Largest in Array/Kth_smallest.py @@ -0,0 +1,38 @@ +# Find the Kth largest and smallest number in the given array: + +import Smallest + +def Kth_Smallest(Array,K): + + Ascending=[] + Length=len(Array) + count=0 + + while not(count==Length): + + X=Smallest.Smallest_in_Array(Array) + Ascending.append(X) + Array.remove(X) + count+=1 + + Result=Ascending[K-1] + return Result + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#K=input("Enter the value of K: ") + +#print("The given Kth Smallest number in the given array is",Kth_Smallest(Array,K) ) + diff --git a/Smallest and Largest in Array/Kth_smallest.pyc b/Smallest and Largest in Array/Kth_smallest.pyc new file mode 100644 index 0000000..b7791cb Binary files /dev/null and b/Smallest and Largest in Array/Kth_smallest.pyc differ diff --git a/Smallest and Largest in Array/Largest.py b/Smallest and Largest in Array/Largest.py new file mode 100644 index 0000000..68554d3 --- /dev/null +++ b/Smallest and Largest in Array/Largest.py @@ -0,0 +1,28 @@ +# Find the Largest Number in the given Array: + +def Largest_in_Array(Array): + + Largest=0 + + for a in Array: + if (a>Largest): + Largest=a + + return Largest + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The Largest number of the given array is", Largest_in_Array(Array)) + diff --git a/Smallest and Largest in Array/Largest.pyc b/Smallest and Largest in Array/Largest.pyc new file mode 100644 index 0000000..16a4281 Binary files /dev/null and b/Smallest and Largest in Array/Largest.pyc differ diff --git a/Smallest and Largest in Array/Smallest.py b/Smallest and Largest in Array/Smallest.py new file mode 100644 index 0000000..0a8d9d6 --- /dev/null +++ b/Smallest and Largest in Array/Smallest.py @@ -0,0 +1,28 @@ +# Find the smallest number in the given Array: + +def Smallest_in_Array(Array): + + Smallest=2147483647 + + for a in Array: + if (aLargest): + + Second_largest=Largest + Largest=a + + elif (a==Largest): + Largest=a + + elif (a>Second_largest): + Second_largest=a + + return Second_largest + +def second_smallest(Array): + + Smallest=Array[0] + Second_smallest=Array[1] + + for a in Array: + + if (aSecond_smallest): + Second_smallest=a + + return Second_smallest + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The second largest number of the given array is", second_largest(Array)) +#print("The second smallest number of the given array is", second_smallest(Array)) \ No newline at end of file diff --git a/Smallest and Largest in Array/second_largest_smallest.pyc b/Smallest and Largest in Array/second_largest_smallest.pyc new file mode 100644 index 0000000..ee7c0ad Binary files /dev/null and b/Smallest and Largest in Array/second_largest_smallest.pyc differ diff --git a/Smallest and Largest in Array/test_Kth_Largest.py b/Smallest and Largest in Array/test_Kth_Largest.py new file mode 100644 index 0000000..fde0719 --- /dev/null +++ b/Smallest and Largest in Array/test_Kth_Largest.py @@ -0,0 +1,19 @@ +# Test condition for the Kth Largest number in the given array: + +import Kth_largest + +def test_canassertTrue(): + assert True + +def test_Largest(): + + #Arrange: + Array=[8,2,5,1,9,4] + K=4 + expected=4 + + #Act: + actual=Kth_largest.Kth_Largest(Array,K) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Smallest and Largest in Array/test_Kth_Smallest.py b/Smallest and Largest in Array/test_Kth_Smallest.py new file mode 100644 index 0000000..b612502 --- /dev/null +++ b/Smallest and Largest in Array/test_Kth_Smallest.py @@ -0,0 +1,19 @@ +# Test condition for the Kth Smallest number in the given array: + +import Kth_smallest + +def test_canassertTrue(): + assert True + +def test_Smallest(): + + #Arrange: + Array=[8,2,5,1,9,4] + K=4 + expected=5 + + #Act: + actual=Kth_smallest.Kth_Smallest(Array,K) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Smallest and Largest in Array/test_Largest.py b/Smallest and Largest in Array/test_Largest.py new file mode 100644 index 0000000..c4945fb --- /dev/null +++ b/Smallest and Largest in Array/test_Largest.py @@ -0,0 +1,18 @@ +# Test condition for finding the largest numgber in an array: + +import Largest + +def test_canassertTrue(): + assert True + +def test_Largest(): + + #Arrange + Array=[7,0,1,11,2] + expected=11 + + #Act + actual=Largest.Largest_in_Array(Array) + + #Assert + assert expected==actual diff --git a/Smallest and Largest in Array/test_Smallest.py b/Smallest and Largest in Array/test_Smallest.py new file mode 100644 index 0000000..693832f --- /dev/null +++ b/Smallest and Largest in Array/test_Smallest.py @@ -0,0 +1,19 @@ +#Test Condition for the smallest element in array: + +import Smallest + +def test_canassertTrue(): + assert True + +def test_Smallest(): + + #Arrange: + Array=[8,4,9,2,5,11] + expected=11 + + #Act + actual=Smallest.Smallest_in_Array(Array) + + #Assert + assert expected==actual + diff --git a/Smallest and Largest in Array/test_count.py b/Smallest and Largest in Array/test_count.py new file mode 100644 index 0000000..5403f41 --- /dev/null +++ b/Smallest and Largest in Array/test_count.py @@ -0,0 +1,31 @@ +# Test condition for counting largest and smallest array: + +import count_smallest +import count_largest + +def test_canassertTrue(): + assert True + +def test_smallest(): + + #Arrange: + Array=[7,9,2,3,8,2,2] + expected=3 + + #Act + actual=count_smallest.count_smallest(Array) + + #Assert: + assert expected==actual + +def test_largest(): + + #Arrange: + Array=[7,9,2,3,8,2,9] + expected=2 + + #Act + actual=count_largest.count_largest(Array) + + #Assert: + assert expected==actual \ No newline at end of file diff --git a/Smallest and Largest in Array/test_second_comparison.py b/Smallest and Largest in Array/test_second_comparison.py new file mode 100644 index 0000000..52e5b96 --- /dev/null +++ b/Smallest and Largest in Array/test_second_comparison.py @@ -0,0 +1,21 @@ +# Test condition to find the second largest and smallest number in the given array: + +import second_largest_smallest + +def test_canassertTrue(): + assert True + +def test_Largest_smallest(): + + #Arrange: + Array=[9,4,2,5,1] + largest_expected=5 + smallest_expected=2 + + #Act: + largest_actual=second_largest_smallest.second_largest(Array) + smallest_actual=second_largest_smallest.second_smallest(Array) + + #Assert: + assert largest_expected==largest_actual + assert smallest_expected==smallest_actual \ No newline at end of file diff --git a/Subset/Indices.py b/Subset/Indices.py new file mode 100644 index 0000000..1f79cb0 --- /dev/null +++ b/Subset/Indices.py @@ -0,0 +1,46 @@ + #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. + +def Subset_Index(Array,X): + + Length=len(Array) + Subset=[] + + #Primary Index = I + #Secondary Index = J + + I=0 + + while not (I==Length): + + J=I+1 + + while not (J==Length): + + + if (Array[I]+Array[J]==X): + Indices ={I,J} + Subset.append(Indices) + + J=J+1 + + I=I+1 + + return Subset + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#X=input("Enter the Sum: ") + +#print("The Subset of Given Array is:",Subset_Index(Array,X)) \ No newline at end of file diff --git a/Subset/Indices.pyc b/Subset/Indices.pyc new file mode 100644 index 0000000..ca5df7e Binary files /dev/null and b/Subset/Indices.pyc differ diff --git a/Subset/IsExists(3).py b/Subset/IsExists(3).py new file mode 100644 index 0000000..8930261 --- /dev/null +++ b/Subset/IsExists(3).py @@ -0,0 +1 @@ +#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. \ No newline at end of file diff --git a/Subset/IsExists.py b/Subset/IsExists.py new file mode 100644 index 0000000..cfdbcd0 --- /dev/null +++ b/Subset/IsExists.py @@ -0,0 +1,52 @@ +#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). + +def Is_Exists(Array,X): + + Length=len(Array) + flag=False + + #Primary Index = I + #Secondary Index = J + + I=0 + + while not (I==Length): + + J=I+1 + + while not (J==Length): + + + if (Array[I]+Array[J]==X): + flag=True + return flag + + J=J+1 + + I=I+1 + + return flag + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#X=input("Enter the Sum: ") + +#print("The subset of size two that adds upto X is Exists:",Is_Exists(Array,X)) + + + + + + diff --git a/Subset/IsExists.pyc b/Subset/IsExists.pyc new file mode 100644 index 0000000..45de9c3 Binary files /dev/null and b/Subset/IsExists.pyc differ diff --git a/Subset/Multiples.py b/Subset/Multiples.py new file mode 100644 index 0000000..e69de29 diff --git a/Subset/Values.py b/Subset/Values.py new file mode 100644 index 0000000..a9430b9 --- /dev/null +++ b/Subset/Values.py @@ -0,0 +1,46 @@ +#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. + +def Subset_Values(Array,X): + + Length=len(Array) + Subset=[] + + #Primary Index = I + #Secondary Index = J + + I=0 + + while not (I==Length): + + J=I+1 + + while not (J==Length): + + + if (Array[I]+Array[J]==X): + Values ={Array[I],Array[J]} + Subset.append(Values) + + J=J+1 + + I=I+1 + + return Subset + +# Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#X=input("Enter the Sum: ") + +#print("The Subset of Given Array is:",Subset_Values(Array,X)) \ No newline at end of file diff --git a/Subset/Values.pyc b/Subset/Values.pyc new file mode 100644 index 0000000..fa3ef2a Binary files /dev/null and b/Subset/Values.pyc differ diff --git a/Subset/__pycache__/Indices.cpython-37.pyc b/Subset/__pycache__/Indices.cpython-37.pyc new file mode 100644 index 0000000..02d1eb7 Binary files /dev/null and b/Subset/__pycache__/Indices.cpython-37.pyc differ diff --git a/Subset/__pycache__/IsExists.cpython-37.pyc b/Subset/__pycache__/IsExists.cpython-37.pyc new file mode 100644 index 0000000..b4b85f2 Binary files /dev/null and b/Subset/__pycache__/IsExists.cpython-37.pyc differ diff --git a/Subset/__pycache__/Values.cpython-37.pyc b/Subset/__pycache__/Values.cpython-37.pyc new file mode 100644 index 0000000..0f7defb Binary files /dev/null and b/Subset/__pycache__/Values.cpython-37.pyc differ diff --git a/Subset/__pycache__/test_41.cpython-27-PYTEST.pyc b/Subset/__pycache__/test_41.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..0768f8b Binary files /dev/null and b/Subset/__pycache__/test_41.cpython-27-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_41.cpython-37-PYTEST.pyc b/Subset/__pycache__/test_41.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..1564ecc Binary files /dev/null and b/Subset/__pycache__/test_41.cpython-37-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_41.cpython-37-pytest-5.0.1.pyc b/Subset/__pycache__/test_41.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..48ea9ee Binary files /dev/null and b/Subset/__pycache__/test_41.cpython-37-pytest-5.0.1.pyc differ diff --git a/Subset/__pycache__/test_42.cpython-27-PYTEST.pyc b/Subset/__pycache__/test_42.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..f7166ee Binary files /dev/null and b/Subset/__pycache__/test_42.cpython-27-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_42.cpython-37-PYTEST.pyc b/Subset/__pycache__/test_42.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..5e5418e Binary files /dev/null and b/Subset/__pycache__/test_42.cpython-37-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_42.cpython-37-pytest-5.0.1.pyc b/Subset/__pycache__/test_42.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..d7605d4 Binary files /dev/null and b/Subset/__pycache__/test_42.cpython-37-pytest-5.0.1.pyc differ diff --git a/Subset/__pycache__/test_43.cpython-27-PYTEST.pyc b/Subset/__pycache__/test_43.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..f9cee65 Binary files /dev/null and b/Subset/__pycache__/test_43.cpython-27-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_43.cpython-37-PYTEST.pyc b/Subset/__pycache__/test_43.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..3cef686 Binary files /dev/null and b/Subset/__pycache__/test_43.cpython-37-PYTEST.pyc differ diff --git a/Subset/__pycache__/test_43.cpython-37-pytest-5.0.1.pyc b/Subset/__pycache__/test_43.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..5353435 Binary files /dev/null and b/Subset/__pycache__/test_43.cpython-37-pytest-5.0.1.pyc differ diff --git a/Subset/test_41.py b/Subset/test_41.py new file mode 100644 index 0000000..7e1995c --- /dev/null +++ b/Subset/test_41.py @@ -0,0 +1,19 @@ +# Test Conditon for the existence of subset in the given Array + +import IsExists + +def test_canassertTrue(): + assert True + +def test_IsExists(): + + #Arrange: + Array=[8,3,1,6] + X=9 + expected=True + + #Act + actual=IsExists.Is_Exists(Array,X) + + #Assert + assert expected==actual \ No newline at end of file diff --git a/Subset/test_42.py b/Subset/test_42.py new file mode 100644 index 0000000..bacd369 --- /dev/null +++ b/Subset/test_42.py @@ -0,0 +1,19 @@ +# Test condition for the subset of indices: + +import Indices + +def test_canassertTrue(): + assert True + +def test_Subset_Index(): + + #Arrange: + Array=[8,3,1,6] + X=9 + expected=[set([0,2]),set([1,3])] + + #Act: + actual=Indices.Subset_Index(Array,X) + + #Assert: + assert expected==actual diff --git a/Subset/test_43.py b/Subset/test_43.py new file mode 100644 index 0000000..b268e51 --- /dev/null +++ b/Subset/test_43.py @@ -0,0 +1,21 @@ +# Test condtions of the values of subset: + +import Values + +def test_canassertTrue(): + assert True + +def test_subset_values(): + + #Arrange: + Array=[8,3,1,6] + X=9 + expected=[set([8,1]),set([3,6])] + + #Act: + actual=Values.Subset_Values(Array,X) + + #Assert: + assert expected==actual + + diff --git a/Sum_of_Array/__pycache__/sum_of_Array.cpython-37.pyc b/Sum_of_Array/__pycache__/sum_of_Array.cpython-37.pyc new file mode 100644 index 0000000..898ce04 Binary files /dev/null and b/Sum_of_Array/__pycache__/sum_of_Array.cpython-37.pyc differ diff --git a/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-27-PYTEST.pyc b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..3580cd5 Binary files /dev/null and b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-27-PYTEST.pyc differ diff --git a/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-PYTEST.pyc b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..829d2a8 Binary files /dev/null and b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-PYTEST.pyc differ diff --git a/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-pytest-5.0.1.pyc b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..68a874f Binary files /dev/null and b/Sum_of_Array/__pycache__/test_sum_of_Array.cpython-37-pytest-5.0.1.pyc differ diff --git a/Sum_of_Array/sum_of_Array.py b/Sum_of_Array/sum_of_Array.py new file mode 100644 index 0000000..19e9b31 --- /dev/null +++ b/Sum_of_Array/sum_of_Array.py @@ -0,0 +1,26 @@ +# Find the sum of an Unsorted array: + +def Sum_of_array(Array): + + Sum=0 + + for a in Array: + Sum+=a + + return Sum + + # Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The given Array is", Array) + +#print("The sum of given array is", Sum_of_array(Array)) \ No newline at end of file diff --git a/Sum_of_Array/sum_of_Array.pyc b/Sum_of_Array/sum_of_Array.pyc new file mode 100644 index 0000000..db1b41a Binary files /dev/null and b/Sum_of_Array/sum_of_Array.pyc differ diff --git a/Sum_of_Array/test_sum_of_Array.py b/Sum_of_Array/test_sum_of_Array.py new file mode 100644 index 0000000..bc9f330 --- /dev/null +++ b/Sum_of_Array/test_sum_of_Array.py @@ -0,0 +1,19 @@ +# Test condition to find the sum of the given unsorted array: + +import sum_of_Array + +def test_canassertTrue(): + assert True + +def test_sum_of_array(): + + #Arrange + Array=[6,2,0,1,7,9] + expected=25 + + #Act + actual=sum_of_Array. Sum_of_array(Array) + + #Assert + assert expected==actual + diff --git a/X_in_given_array/X_in_Array.py b/X_in_given_array/X_in_Array.py new file mode 100644 index 0000000..0506317 --- /dev/null +++ b/X_in_given_array/X_in_Array.py @@ -0,0 +1,28 @@ +# Given an unsorted integer array A and an integer value X, find if A contains the value X. + +def X_in_array(Array,X): + + flag=False + + for i in Array: + + if (i==X): + flag=True + break + + return flag + +# Getting input from User: + +#X=input("Enter the search element: ") +#N=input("Enter the Number of elements: ") + +#Array=[] + +#for a in range (0,N): + #Elements=input("Enter the input elements: ") + #Array.append(Elements) + +#print Array +#print(X_in_array(Array,X)) + diff --git a/X_in_given_array/X_in_Array.pyc b/X_in_given_array/X_in_Array.pyc new file mode 100644 index 0000000..2022293 Binary files /dev/null and b/X_in_given_array/X_in_Array.pyc differ diff --git a/X_in_given_array/__pycache__/X_in_Array.cpython-37.pyc b/X_in_given_array/__pycache__/X_in_Array.cpython-37.pyc new file mode 100644 index 0000000..a787480 Binary files /dev/null and b/X_in_given_array/__pycache__/X_in_Array.cpython-37.pyc differ diff --git a/X_in_given_array/__pycache__/test_X_in_array.cpython-27-PYTEST.pyc b/X_in_given_array/__pycache__/test_X_in_array.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..f9dcf16 Binary files /dev/null and b/X_in_given_array/__pycache__/test_X_in_array.cpython-27-PYTEST.pyc differ diff --git a/X_in_given_array/__pycache__/test_X_in_array.cpython-37-PYTEST.pyc b/X_in_given_array/__pycache__/test_X_in_array.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..4a107b6 Binary files /dev/null and b/X_in_given_array/__pycache__/test_X_in_array.cpython-37-PYTEST.pyc differ diff --git a/X_in_given_array/__pycache__/test_X_in_array.cpython-37-pytest-5.0.1.pyc b/X_in_given_array/__pycache__/test_X_in_array.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..1a29310 Binary files /dev/null and b/X_in_given_array/__pycache__/test_X_in_array.cpython-37-pytest-5.0.1.pyc differ diff --git a/X_in_given_array/__pycache__/test_X_index.cpython-27-PYTEST.pyc b/X_in_given_array/__pycache__/test_X_index.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..b891d9b Binary files /dev/null and b/X_in_given_array/__pycache__/test_X_index.cpython-27-PYTEST.pyc differ diff --git a/X_in_given_array/test_X_in_array.py b/X_in_given_array/test_X_in_array.py new file mode 100644 index 0000000..4d599fe --- /dev/null +++ b/X_in_given_array/test_X_in_array.py @@ -0,0 +1,19 @@ +# Test condition for checking given X in array: + +import X_in_Array + +def test_canassertTrue(): + assert True + +def test_X_in_array(): + + #arrange + Array=[6,9,0,2,5,1,7] + X=8 + expected=False + + #act + actual=X_in_Array.X_in_array(Array,X) + + #assert + assert expected==actual diff --git a/X_index/X_index.py b/X_index/X_index.py new file mode 100644 index 0000000..60914fa --- /dev/null +++ b/X_index/X_index.py @@ -0,0 +1,34 @@ +# 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. + +def X_index(Array,X): + + for i in Array: + + if(i==X): + + Index=Array.index(X) + break + Index=-1 + + return Index + +#Getting Input from User: + +#N=input("Enter the number of elements: ") + +#Array=[] + +#for a in range(0,N): + + #Elements=input("Enter the Elements in Array: ") + + #Array.append(Elements) + +#print("The Given array is: " ,Array) + +#X=input("Enter the search Elements: ") + +#print ("The Index of the given Search elements is: " ,X_index(Array,X)) + + diff --git a/X_index/X_index.pyc b/X_index/X_index.pyc new file mode 100644 index 0000000..3500262 Binary files /dev/null and b/X_index/X_index.pyc differ diff --git a/X_index/__pycache__/X_index.cpython-37.pyc b/X_index/__pycache__/X_index.cpython-37.pyc new file mode 100644 index 0000000..f735690 Binary files /dev/null and b/X_index/__pycache__/X_index.cpython-37.pyc differ diff --git a/X_index/__pycache__/test_X_index.cpython-27-PYTEST.pyc b/X_index/__pycache__/test_X_index.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..4bdbfae Binary files /dev/null and b/X_index/__pycache__/test_X_index.cpython-27-PYTEST.pyc differ diff --git a/X_index/__pycache__/test_X_index.cpython-37-PYTEST.pyc b/X_index/__pycache__/test_X_index.cpython-37-PYTEST.pyc new file mode 100644 index 0000000..a5b88b0 Binary files /dev/null and b/X_index/__pycache__/test_X_index.cpython-37-PYTEST.pyc differ diff --git a/X_index/__pycache__/test_X_index.cpython-37-pytest-5.0.1.pyc b/X_index/__pycache__/test_X_index.cpython-37-pytest-5.0.1.pyc new file mode 100644 index 0000000..11c626e Binary files /dev/null and b/X_index/__pycache__/test_X_index.cpython-37-pytest-5.0.1.pyc differ diff --git a/X_index/test_X_index.py b/X_index/test_X_index.py new file mode 100644 index 0000000..e4a8607 --- /dev/null +++ b/X_index/test_X_index.py @@ -0,0 +1,19 @@ +# Test condition for the Index of the Given Array: + +import X_index + +def test_canassertTrue(): + assert True + +def test_X_index(): + + #arrange + Array=[6,9,0,2,5,3,8] + X=9 + expected=1 + + #act + actual=X_index.X_index(Array,X) + + #assert + assert expected==actual diff --git a/rough_sheet.py b/rough_sheet.py new file mode 100644 index 0000000..7bcfce2 --- /dev/null +++ b/rough_sheet.py @@ -0,0 +1,8 @@ +def print_array(Array): + print Array + +array = [1,2,3] +#print array +print_array(array) + +print len(array) \ No newline at end of file diff --git a/user_input.py b/user_input.py new file mode 100644 index 0000000..9f2587d --- /dev/null +++ b/user_input.py @@ -0,0 +1,15 @@ +# Getting Input from User: + +N=input("Enter the number of elements: ") + +Array=[] + +for a in range(0,N): + + Elements=input("Enter the Elements in Array: ") + + Array.append(Elements) + +print("The given Array is", Array) + +print("The sum of given array is") \ No newline at end of file