From 23acdb30def24b6f85c1521e19124a1bd879e5aa Mon Sep 17 00:00:00 2001 From: Marat Date: Tue, 18 Mar 2025 12:10:29 +1300 Subject: [PATCH] modify solution and tests --- modules/50-loops/29-edge-cases/index.py | 2 -- modules/50-loops/29-edge-cases/test_code.py | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/50-loops/29-edge-cases/index.py b/modules/50-loops/29-edge-cases/index.py index a40f1c30..47c8d339 100644 --- a/modules/50-loops/29-edge-cases/index.py +++ b/modules/50-loops/29-edge-cases/index.py @@ -3,8 +3,6 @@ def is_arguments_for_substr_correct(string, index, length): return False elif length < 0: return False - elif index > len(string) - 1: - return False elif index + length > len(string): return False return True diff --git a/modules/50-loops/29-edge-cases/test_code.py b/modules/50-loops/29-edge-cases/test_code.py index 19c4fa71..0dc458d9 100644 --- a/modules/50-loops/29-edge-cases/test_code.py +++ b/modules/50-loops/29-edge-cases/test_code.py @@ -3,12 +3,13 @@ def test1(): string = 'Sansa Stark' - end = len(string) - 1 + end = len(string) assert not index.is_arguments_for_substr_correct(string, -1, 0) assert not index.is_arguments_for_substr_correct(string, 0, -1) assert not index.is_arguments_for_substr_correct(string, end + 1, 0) - assert not index.is_arguments_for_substr_correct(string, end, 5) - assert index.is_arguments_for_substr_correct(string, end, 1) + assert not index.is_arguments_for_substr_correct(string, end, 1) + assert index.is_arguments_for_substr_correct(string, end, 0) + assert index.is_arguments_for_substr_correct(string, end - 1, 1) assert index.is_arguments_for_substr_correct(string, 3, 3) assert index.is_arguments_for_substr_correct(string, 0, 3) assert index.is_arguments_for_substr_correct(string, 0, 1)