diff --git a/hands_on/first/test_first.py b/hands_on/first/test_first.py index 5ac7354..db95069 100644 --- a/hands_on/first/test_first.py +++ b/hands_on/first/test_first.py @@ -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(): diff --git a/hands_on/local_maxima/local_maxima.py b/hands_on/local_maxima/local_maxima.py index cfd0a9e..650e20d 100644 --- a/hands_on/local_maxima/local_maxima.py +++ b/hands_on/local_maxima/local_maxima.py @@ -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))