diff --git a/hands_on/local_maxima/local_maxima.py b/hands_on/local_maxima/local_maxima.py new file mode 100644 index 0000000..77fe08f --- /dev/null +++ b/hands_on/local_maxima/local_maxima.py @@ -0,0 +1,16 @@ +def find_maxima(input): + + output = [] + + for i,v in enumerate(input[1:-1]): + + if (v>input[i]) and (v>input[i+2]): + + output.append(i+1) + + return(output) + +print(find_maxima([1,4,-5,0,2,1])) +print(find_maxima([-1,-1,0,-1])) + +print('end') \ No newline at end of file