diff --git a/hands_on/first/test_first.py b/hands_on/first/test_first.py index 5ac7354..a57c562 100644 --- a/hands_on/first/test_first.py +++ b/hands_on/first/test_first.py @@ -1,6 +1,16 @@ +from first import times_3 + def test_times_3_integer(): pass def test_times_3_string(): pass + +def test_times_3_list(): + value = [1] + expected = [1, 1, 1] + + result = times_3(value) + + assert result == expected \ No newline at end of file diff --git a/hands_on/local_maxima_part2/local_maxima.py b/hands_on/local_maxima_part2/local_maxima.py index db89ba3..e36cf3c 100644 --- a/hands_on/local_maxima_part2/local_maxima.py +++ b/hands_on/local_maxima_part2/local_maxima.py @@ -7,4 +7,22 @@ def find_maxima(x): Output: 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))