local maxima tests

This commit is contained in:
ASPP Student 2025-09-23 16:31:03 +03:00
parent 47f74329bf
commit 354d7cf9f1
2 changed files with 20 additions and 6 deletions

View file

@ -7,4 +7,12 @@ def find_maxima(x):
Output:
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