From 83ad43f5470c6cb4d015845db1c78195db4e3a68 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 3 Sep 2019 09:33:24 +0200 Subject: [PATCH] first attempt on local_maxima --- hands_on/local_maxima/local_maxima.py | 12 ++++++++++++ 1 file changed, 12 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..0072d55 --- /dev/null +++ b/hands_on/local_maxima/local_maxima.py @@ -0,0 +1,12 @@ +def find_maxima(lst): + max_index = [] + for index in range(len(lst)): + if lst[index] > lst[index-1] and lst[index] > lst[index+1]: + max_index.append(index) + return max_index + +lst = [1,4,-5,0,2,1] +#sst = [-1,-1, 0, -1] +#lst = [4,2,1,3,1,5] + +print(find_maxima(lst))