aboutsummaryrefslogtreecommitdiff
path: root/challenge-235
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-09 20:40:05 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-09 20:40:05 +0100
commite13e7af75f5d4d962d1a7260c04781daa56666e1 (patch)
treee5eaaa027903107d8b46967fba26e9a627c82e66 /challenge-235
parent5ff3e30687373515a1b6707f5762974453a2bf07 (diff)
parent5966a37da10a8d575ce14270e7c4372f8d613666 (diff)
downloadperlweeklychallenge-club-e13e7af75f5d4d962d1a7260c04781daa56666e1.tar.gz
perlweeklychallenge-club-e13e7af75f5d4d962d1a7260c04781daa56666e1.tar.bz2
perlweeklychallenge-club-e13e7af75f5d4d962d1a7260c04781daa56666e1.zip
Merge branch 'week235' of https://github.com/oWnOIzRi/perlweeklychallenge-club into oWnOIzRi-week235
Diffstat (limited to 'challenge-235')
-rw-r--r--challenge-235/steven-wilson/python/ch-1.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/challenge-235/steven-wilson/python/ch-1.py b/challenge-235/steven-wilson/python/ch-1.py
index 4d5a26bae5..b7cbbe1543 100644
--- a/challenge-235/steven-wilson/python/ch-1.py
+++ b/challenge-235/steven-wilson/python/ch-1.py
@@ -9,12 +9,18 @@ def remove_one(elements):
False
>>> remove_one( [2, 2, 3] )
True
+ >>> remove_one( [1, 2, 3, 1, 2, 3] )
+ False
+ >>> remove_one( [1, 2, 3, 1])
+ True
"""
remove = 0
for i in range(len(elements) - 1):
if(elements[i] > elements[i+1]):
remove += 1
- if remove == 2:
+ if (i > 0) and (i < len(elements) - 2) and (elements[i-1] > elements[i+1]):
+ remove += 1
+ if remove > 1:
return False
return True