From cfc6d8366d42cae0b48eb20dc51bbd7f23e4cb48 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 3 Sep 2019 09:42:53 +0200 Subject: [PATCH] add local maxima --- hands_on/local_maxima/local_maxima.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 hands_on/local_maxima/local_maxima.py 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