Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
835 B
3
Indexable
Never
inlist = input().split(',')
k = int(input())

for i in range(len(inlist)):
    inlist[i] = float(inlist[i])


def find_troughs_wings(inlist, k=2):
    if k < 1:
        k = 2

    go_down = [0] * len(inlist)
    go_up = [0] * len(inlist)
    for i in range(len(inlist)-1):
        if inlist[i] > inlist[i+1]:
            go_down[i+1] = go_down[i] + 1
        if inlist[-i-1] > inlist[-i-2]:
            go_up[-i-2] = go_up[-i-1] + 1

    candidates = []
    for i in range(len(inlist)):
        if go_down[i] == k and go_up[i] == k:
                candidates.append(i)

    if candidates == []:
        return "NA"
    else:
        for i in range(len(candidates)):
            candidates[i] = str(candidates[i])

        for i in range(len(candidates)):
            return '\n'.join(candidates)


print(find_troughs_wings(inlist, k))