From c14f7b84d5c09703b5ea40859e78b2a8fbc370b1 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 23 Sep 2025 16:26:51 +0300 Subject: [PATCH] Allow equality of neighbors for maxima --- hands_on/local_maxima_part2/local_maxima.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hands_on/local_maxima_part2/local_maxima.py b/hands_on/local_maxima_part2/local_maxima.py index 723b640..1d3d46a 100644 --- a/hands_on/local_maxima_part2/local_maxima.py +++ b/hands_on/local_maxima_part2/local_maxima.py @@ -9,12 +9,12 @@ def find_maxima(x): """ sol = [] for idx, num in enumerate(x): - if idx == 0 and num > x[idx+1]: + if idx == 0 and num => x[idx+1]: sol.append(idx) - elif idx == len(x)-1 and num > x[idx-1]: + elif idx == len(x)-1 and num => x[idx-1]: sol.append(idx) else: - if x[idx-1] < num and num > x[idx+1]: + if x[idx-1] <= num and num => x[idx+1]: sol.append(idx) return sol