diff options
| author | Steven Wilson <steven1170@zoho.eu> | 2023-10-09 14:51:13 +0100 |
|---|---|---|
| committer | Steven Wilson <steven1170@zoho.eu> | 2023-10-09 14:51:13 +0100 |
| commit | 5966a37da10a8d575ce14270e7c4372f8d613666 (patch) | |
| tree | 2f9e8fde1879fe3012d64d0242c3177898c10656 | |
| parent | 34a882b97947ad6bb1c13273e228e64a20a93d9b (diff) | |
| download | perlweeklychallenge-club-5966a37da10a8d575ce14270e7c4372f8d613666.tar.gz perlweeklychallenge-club-5966a37da10a8d575ce14270e7c4372f8d613666.tar.bz2 perlweeklychallenge-club-5966a37da10a8d575ce14270e7c4372f8d613666.zip | |
another edge case fix
| -rw-r--r-- | challenge-235/steven-wilson/python/ch-01.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/challenge-235/steven-wilson/python/ch-01.py b/challenge-235/steven-wilson/python/ch-01.py index e128a00985..b7cbbe1543 100644 --- a/challenge-235/steven-wilson/python/ch-01.py +++ b/challenge-235/steven-wilson/python/ch-01.py @@ -11,12 +11,14 @@ def remove_one(elements): 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 (i > 0) and (elements[i-1] > elements[i+1]): + if (i > 0) and (i < len(elements) - 2) and (elements[i-1] > elements[i+1]): remove += 1 if remove > 1: return False |
