fix findmax for three test cases #1 fix1 #14

Open
jiamengwu wants to merge 3 commits from jiamengwu/2025-plovdiv-testing-debugging:findmax into main
Showing only changes of commit 8ae15bf2a5 - Show all commits

View file

@ -7,9 +7,13 @@ 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(1, len(x)-1):
if (x[i] > x[i-1]) & (x[i] > x[i+1]):
idx.append(i)
return idx
if __name__ == "__main__": if __name__ == "__main__":
x = [1, 2, 3] x = [1, 3, -2, 0, 2, 1]
print(find_maxima(x)) print(find_maxima(x))