diff --git a/bootcamp/contrib/student_17.py b/bootcamp/contrib/student_17.py new file mode 100644 index 0000000..afc4878 --- /dev/null +++ b/bootcamp/contrib/student_17.py @@ -0,0 +1,15 @@ +def is_prime(n: int) -> bool: + """ + Check if a number is prime. + A prime num is greater than 1 and has no divisors other than 1 and itself. + Parameters: + n (int): The number to check. + Returns: + bool: True if the number is prime, False otherwise. + """ + if n <= 1: + return False + for i in range(2, int(n**0.5) + 1): + if n % i == 0: + return False + return True diff --git a/bootcamp/core/student_17.py b/bootcamp/core/student_17.py index b904827..9495a3b 100644 --- a/bootcamp/core/student_17.py +++ b/bootcamp/core/student_17.py @@ -24,7 +24,7 @@ def count_substring(string, substring): left_bound = i right_bound = i + substring_length candidate_substring = string[left_bound:right_bound] - if candidate_substring == substring: + if candidate_substring.lower() == substring.lower(): count += 1 return count diff --git a/bootcamp/core/tests/test_student_17.py b/bootcamp/core/tests/test_student_17.py index 76ea70d..dd6be59 100644 --- a/bootcamp/core/tests/test_student_17.py +++ b/bootcamp/core/tests/test_student_17.py @@ -26,3 +26,12 @@ def test_count_substring_none(): expected_count = 0 observed_count = count_substring(test_string, test_substring) assert expected_count == observed_count + + +def test_count_substring_case_sensitive(): + test_string = "CGCTAGCGT" + test_substring = "cgc" + + expected_count = 1 + observed_count = count_substring(test_string, test_substring) + assert expected_count == observed_count