fixed find maxima function first 3 #7

Open
juliada wants to merge 4 commits from juliada/2025-plovdiv-testing-debugging:fix into main
2 changed files with 29 additions and 1 deletions
Showing only changes of commit d03243efe4 - Show all commits

View file

@ -1,6 +1,16 @@
from first import times_3
def test_times_3_integer(): def test_times_3_integer():
pass pass
def test_times_3_string(): def test_times_3_string():
pass pass
def test_times_3_list():
value = [1]
expected = [1, 1, 1]
result = times_3(value)
assert result == expected

View file

@ -7,4 +7,22 @@ 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 [] localmax = []
for i, num in enumerate(x):
if i == 0:
if x[i+1] < x[i]:
localmax.append(i)
elif i == len(x)-1:
if x[i-1] < x[i]:
localmax.append(i)
else:
if x[i+1] < x[i] and x[i-1] < x[i]:
localmax.append(i)
return localmax
if __name__ == "__main__":
x = [1, 2, 3]
print(find_maxima(x))