fix-1 #4

Open
pallavibe wants to merge 2 commits from pallavibe/2025-plovdiv-testing-debugging:fix-1 into main
2 changed files with 20 additions and 6 deletions
Showing only changes of commit 354d7cf9f1 - Show all commits

View file

@ -7,4 +7,12 @@ def find_maxima(x):
Output: Output:
idx -- list of indices of the local maxima in x idx -- list of indices of the local maxima in x
""" """
return [] idx = []
for i in range(len(x)):
if i == 0 and x[i] > x[i+1]:
idx.append(i)
elif i != len(x)-1 and x[i] > x[i-1] and x[i] > x[i+1]:
idx.append(i)
elif i== len(x)-1 and x[i] > x[i-1]:
idx.append(i)
return idx

View file

@ -16,15 +16,21 @@ def test_find_maxima_edges():
def test_find_maxima_empty(): def test_find_maxima_empty():
values = [1,2,2,1]
expected = [1]
maxima = find_maxima(values)
assert maxima == expected
def test_find_maxima_plateau():
values = [] values = []
expected = [] expected = []
maxima = find_maxima(values) maxima = find_maxima(values)
assert maxima == expected assert maxima == expected
def test_find_maxima_plateau():
raise Exception('not yet implemented')
def test_find_maxima_not_a_plateau(): def test_find_maxima_not_a_plateau():
raise Exception('not yet implemented') values = []
expected = []
maxima = find_maxima(values)
assert maxima == expected