-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf97cfe
commit 37c86c0
Showing
26 changed files
with
1,097 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ __pycache__ | |
*.cover | ||
*.excalidraw | ||
plann.txt | ||
exercises_with_notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module for list manipulation focusing on alternating elements. | ||
This is part of the debugging exercise series focusing on buggy tests. | ||
Module contents: | ||
- alternate_elements: Creates a new list with every other element | ||
Created on 2024-12-06 | ||
Author: Claude AI | ||
""" | ||
|
||
def alternate_elements(items: list) -> list: | ||
"""Returns a new list containing every other element from the input list. | ||
Takes any list and returns a new list with elements at even indices | ||
(0, 2, 4, etc.). The original list is not modified. | ||
Parameters: | ||
items: list, the input list to process | ||
Returns -> list: new list containing every other element | ||
Raises: | ||
AssertionError: if input is not a list | ||
Examples: | ||
>>> alternate_elements([1, 2, 3, 4, 5]) | ||
[1, 3, 5] | ||
>>> alternate_elements(['a', 'b', 'c']) | ||
['a', 'c'] | ||
>>> alternate_elements([]) | ||
[] | ||
""" | ||
assert isinstance(items, list), "input must be a list" | ||
return items[::2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module for counting numbers within a range. | ||
This is part of the debugging exercise series focusing on buggy tests. | ||
Module contents: | ||
- count_between: Counts how many numbers fall between two values | ||
Created on 2024-12-06 | ||
Author: Claude AI | ||
""" | ||
|
||
def count_between(numbers: list, lower: int, upper: int) -> int: | ||
"""Counts how many numbers in the list fall between lower and upper bounds. | ||
The bounds are inclusive, meaning a number equal to the lower or upper | ||
bound is counted. The numbers list can contain integers or floats. | ||
Parameters: | ||
numbers: list of numbers to check | ||
lower: int, lower bound (inclusive) | ||
upper: int, upper bound (inclusive) | ||
Returns -> int: count of numbers between bounds | ||
Raises: | ||
AssertionError: if numbers is not a list or bounds aren't integers | ||
Examples: | ||
>>> count_between([1, 2, 3, 4, 5], 2, 4) | ||
3 | ||
>>> count_between([1.5, 2.5, 3.5], 2, 3) | ||
1 | ||
>>> count_between([], 0, 10) | ||
0 | ||
""" | ||
assert isinstance(numbers, list), "first argument must be a list" | ||
assert isinstance(lower, int), "lower bound must be an integer" | ||
assert isinstance(upper, int), "upper bound must be an integer" | ||
|
||
count = 0 | ||
for num in numbers: | ||
if lower <= num <= upper: | ||
count += 1 | ||
return count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module for counting vowels in a string. | ||
This is part of the debugging exercise series focusing on buggy tests. | ||
Module contents: | ||
- count_vowels: Counts how many vowels are in a string | ||
Created on 2024-12-06 | ||
Author: Claude AI | ||
""" | ||
|
||
def count_vowels(text: str) -> int: | ||
"""Count the number of vowels (a,e,i,o,u) in a string. | ||
Parameters: | ||
text: str, the input string to check | ||
Returns -> int: number of vowels in the text | ||
>>> count_vowels("hello") | ||
2 | ||
>>> count_vowels("APPLE") | ||
2 | ||
>>> count_vowels("why") | ||
0 | ||
""" | ||
assert isinstance(text, str), "input must be a string" | ||
|
||
vowels = "aeiou" | ||
count = 0 | ||
for char in text.lower(): | ||
if char in vowels: | ||
count += 1 | ||
return count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module containing string manipulation functions for removing spaces. | ||
This is part of the debugging exercise series focusing on buggy tests. | ||
Module contents: | ||
- remove_spaces: Removes all spaces from a string | ||
Created on 2024-12-06 | ||
Author: Claude AI | ||
""" | ||
|
||
def remove_spaces(text: str) -> str: | ||
"""Removes all spaces from a string. | ||
This function takes any string input and returns a new string with all | ||
space characters removed. It preserves all other characters including | ||
numbers, punctuation, and special characters. | ||
Parameters: | ||
text: str, the input string to process | ||
Returns -> str: the input string with all spaces removed | ||
Raises: | ||
AssertionError: if input is not a string | ||
Examples: | ||
>>> remove_spaces("hello world") | ||
'helloworld' | ||
>>> remove_spaces(" spaces ") | ||
'spaces' | ||
>>> remove_spaces("no spaces") | ||
'nospaces' | ||
>>> remove_spaces("") | ||
'' | ||
""" | ||
assert isinstance(text, str), "input must be a string" | ||
return text.replace(" ", "") |
Oops, something went wrong.