@@ -0,0 +1,1171 @@
+from itertools import groupby%0A%0Adef pick_peaks(arr):%0A%0A    res = %7B'pos':%5B%5D, 'peaks':%5B%5D%7D%0A    if not arr: return res%0A    %0A    #%5BA,B,B,C,D,D,E%5D =%3E %5B%5BA%5D,%5BB,B%5D,%5BC%5D,%5BD,D%5D,%5BE%5D%5D%0A    #see enum() below%0A    #%5B%5BA%5D,%5BB,B%5D,%5BC%5D,%5BD,D%5D,%5BE%5D%5D = %3E %5B0:%5BA%5D,1:%5BB,B%5D,3:%5BC%5D,4:%5BD,D%5D,6:%5BE%5D%5D%0A    arr = dict(enum(list(j) for i,j in groupby(arr)))%0A         %0A    #storing keys to be able to find%0A    #previous value and the next one%0A    keys = sorted(arr.keys())%0A    %0A    for i in arr:%0A        %0A        #excluding edges%0A        if i != keys%5B0%5D and i != keys%5B-1%5D:%0A        %0A            current  = arr%5Bi%5D%5B0%5D%0A            previous = arr%5Bkeys%5Bkeys.index(i) + 1%5D%5D%5B0%5D%0A            post     = arr%5Bkeys%5Bkeys.index(i) - 1%5D%5D%5B0%5D%0A            %0A            if current %3E post and current %3E previous:%0A                res%5B'pos'%5D   = res%5B'pos'%5D + %5Bi%5D%0A                res%5B'peaks'%5D = res%5B'peaks'%5D + %5Barr%5Bi%5D%5B0%5D%5D%0A    return res%0A    %0Adef enum(a):%0A    #enumerate groups of elements based %0A    #on the ordinal position of the first %0A    #element of a group in a flattened list%0A    i = 0%0A    for j in a:%0A        if len(j) == 1:%0A            yield(i,j)%0A            i += 1%0A        else:%0A            yield(i, j)%0A            i += len(j)  %0A

Create 4kyu_pick_peaks.py