fix-1 #4
2 changed files with 18 additions and 2 deletions
|
@ -1,5 +1,12 @@
|
|||
from first import times_3
|
||||
|
||||
def test_times_3_integer():
|
||||
pass
|
||||
value = [2]
|
||||
expected = [1,1,1]
|
||||
|
||||
result = times_3(value)
|
||||
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_times_3_string():
|
||||
|
|
|
@ -7,9 +7,18 @@ 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
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
x = [1, 2, 3]
|
||||
# x = [1,2,2,3,1]
|
||||
print(find_maxima(x))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue