Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 1.FindLenght/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

array = [1,5,4,5,9]
print(count(array))
Binary file added 1.FindLenght/__pycache__/FindLenght.cpython-37.pyc
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions 1.FindLenght/test_find_lenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import FindLenght

def test_AssertTrue():
assert True

def test_array_retutn_5():
#arrange
array = [1,5,2,8,9]
excepted = 5
#act
actual = FindLenght.count(array)
#assert
assert excepted == actual
11 changes: 11 additions & 0 deletions 10.Find_Min/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
Binary file added 10.Find_Min/__pycache__/FindLenght.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added 10.Find_Min/__pycache__/find_min.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions 10.Find_Min/find_min.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To find the min of dictionary values
import FindLenght
def findMin(values):

values_count = FindLenght.count(values)
one = values[0]
two = values[1]
if (one < two):
min = one
else:
min = two
i = 2
while(i!=values_count):
if (values[i]<min):
min = values[i]
i += 1
return min

#values = [5,0,1,7,3,5]
#print(findMin(values))
12 changes: 12 additions & 0 deletions 10.Find_Min/test_find_min.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import find_min
def test_AssertTrue():
assert True

def test_arrayretutn7():
#arrange
values = [5,2,4,7,3,5]
excepted = 2
#act
actual = find_min.findMin(values)
#assert
assert excepted == actual
11 changes: 11 additions & 0 deletions 11.FindMax/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
20 changes: 20 additions & 0 deletions 11.FindMax/Max.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To find the max of dictionary values
import FindLenght
def Max(values):

values_count = FindLenght.count(values)
one = values[0]
two = values[1]
if (one > two):
max = one
else:
max = two
i = 2
while(i!=values_count):
if (values[i]>max):
max = values[i]
i += 1
return max

#values = [5,2,4,7,3,5]
#print(Max(values))
Binary file added 11.FindMax/__pycache__/FindLenght.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added 11.FindMax/__pycache__/Max.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions 11.FindMax/test_find_max.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import Max

def test_AssertTrue():
assert True

def test_arrayretutn7():
#arrange
values = [5,2,4,7,3,5]
excepted = 7
#act
actual = Max.Max(values)
#assert
assert excepted == actual
11 changes: 11 additions & 0 deletions 12.Find_largest_number_count_value/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
20 changes: 20 additions & 0 deletions 12.Find_largest_number_count_value/Max.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To find the max of dictionary values
import FindLenght
def max(values):

values_count = FindLenght.count(values)
one = values[0]
two = values[1]
if (one > two):
max = one
else:
max = two
i = 2
while(i!=values_count):
if (values[i]>max):
max = values[i]
i += 1
return max

#values = [5,2,4,7,3,5]
#print(find_largest_value(values))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions 12.Find_largest_number_count_value/find_largest_number_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#12. Given an unsorted integer array A,
# find the number of times the smallest number is found in the array.
import Max
import FindLenght
def count_occuences(array,max):
count = 0
i = 0
lenght = FindLenght.count(array)
while (i!=lenght):
if (array[i]==max):
count += 1
i += 1
return count

def find_largest_numbers_occurences(array):
max = Max.max(array)
count = count_occuences(array,max)
return count
array = [3,9,2,7,9]
print(find_largest_numbers_occurences(array))
13 changes: 13 additions & 0 deletions 12.Find_largest_number_count_value/test_largest_Number_Count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import find_largest_number_count
def assertTrue():
assert True

def arrayreturn2():
#arrange
array = [3,9,2,7,9]
excepted = 2
#act
actual = find_largest_number_count.find_largest_numbers_occurences(array)
#assert
assert excepted == actual

11 changes: 11 additions & 0 deletions 13.findSmallnumberCount/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions 13.findSmallnumberCount/findSmallestNumberCount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#12. Given an unsorted integer array A,
# find the number of times the smallest number is found in the array.
import find_min
import FindLenght
def count_occuences(array,min):
count = 0
i = 0
lenght = FindLenght.count(array)
while (i!=lenght):
if (array[i]==min):
count += 1
i += 1
return count

def find_Smallest_numbers_occurences(array):
min = find_min.find_smallest_value(array)
count = count_occuences(array,min)
return count
array = [3,8,3,7,9]
print(find_Smallest_numbers_occurences(array))
20 changes: 20 additions & 0 deletions 13.findSmallnumberCount/find_min.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To find the min of dictionary values
import FindLenght
def find_smallest_value(values):

values_count = FindLenght.count(values)
one = values[0]
two = values[1]
if (one < two):
min = one
else:
min = two
i = 2
while(i!=values_count):
if (values[i]<min):
min = values[i]
i += 1
return min

#values = [5,2,4,7,2,5]
#print(find_smallest_value(values))
13 changes: 13 additions & 0 deletions 13.findSmallnumberCount/test_find_min.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import findSmallestNumberCount
def assertTrue():
assert True

def arrayreturn2():
#arrange
array = [3,9,2,7,9]
excepted = 2
#act
actual = findSmallestNumberCount.find_Smallest_numbers_occurences(array)
#assert
assert excepted == actual

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#14. Given an unsorted integer array A, print the contents of the array in the
# given format: {arrayindex:value, arrayindex:value}.
# Note that there is no comma after the last value.

import Finding_lenght_of_an_array_without_using_len_functin
def printing_index_with_values(array):
dictionary = {}
index = 0
lenght = Finding_lenght_of_an_array_without_using_len_functin.count(array)
while(index!=lenght):
dictionary[index] = array[index]
index += 1
return dictionary

array = [9,7,3,4,0]
print(printing_index_with_values(array))
28 changes: 28 additions & 0 deletions 15.Compare_Two_Array_Elements/Compare_Two_Array_Elements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#15. Write a function that takes two unsorted integer arrays as input and
# returns True if the two arrays are the same.
import FindLenght
def compareArrayElements(array1,array2):
index = 0
flag = False
check = 0
lenght_of_array1 = FindLenght.count(array1)
lenght_of_array2 = FindLenght.count(array2)
if (lenght_of_array1 == lenght_of_array2):
lenght = lenght_of_array1
while(index!=lenght):
if ( array1[index] == array2[index] ):
check = 1
else:
check = 0
break
index += 1

if check == 1 :
flag = True


return flag

array1 = [2,8,1,4,5,2]
array2 = [2,9,1,4,5]
print(compareArrayElements(array1,array2))
11 changes: 11 additions & 0 deletions 15.Compare_Two_Array_Elements/FindLenght.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#To find the lenght of an array using slicing methodogy

def count(a):
counti = 0
while(a[counti:]):
counti += 1

return counti

#array = [1,5,2,8,9]
#print(count(array))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 36 additions & 0 deletions 15.Compare_Two_Array_Elements/test_check_two_array_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Compare_Two_Array_Elements

def assertTrue():
assert True

def test_array1_array2retutnFalse():
#arrange
array1 = [2,8,1,4,5]
array2 = [2,9,1,4,5]
excepted = False
#act
actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2)
#assert
assert excepted == actual


def test_array1_array2retutnTrue():
#arrange
array1 = [2,9,1,4,5]
array2 = [2,9,1,4,5]
excepted = True
#act
actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2)
#assert
assert excepted == actual


def test_array1_array2retutn1False():
#arrange
array1 = [2,9,1,4,5,2]
array2 = [2,9,1,4,5]
excepted = False
#act
actual = Compare_Two_Array_Elements.compareArrayElements(array1,array2)
#assert
assert excepted == actual
11 changes: 11 additions & 0 deletions 16.return_a_copy_of_an_array/return_a_copy_of_an_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#16. Wrtie a function that takes an unsorted integer array as input and returns a copy of the array as output.

def produce_copy(array):
copy_array = []
for i in array:
copy_array.append(i)

return copy_array

array = [3,1,6,8,9]
print(produce_copy(array))
Loading