Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bootcamp/contrib/student_17.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bootcamp/core/student_17.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions bootcamp/core/tests/test_student_17.py
Original file line number Diff line number Diff line change
Expand Up @@ -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