Skip to content

Commit 898ecd8

Browse files
authored
Added Convert Integer to String Challenge (#55)
* Created README * Added image * Added solution * Reworking the repo layout * Migrated yet another solution * Working through documentation * Implemented first pytest * Added docs
1 parent 6ab9d89 commit 898ecd8

File tree

13 files changed

+94
-65
lines changed

13 files changed

+94
-65
lines changed

challenges/how-to-capitalize-a-string/capitalize_string.py

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Provides a series of solutions to the challenge provided at the following link:
3+
https://therenegadecoder.com/code/how-to-capitalize-a-string-in-python/#challenge
4+
"""
5+
6+
7+
def capitalize_1(string):
8+
return string[0].upper() + string[1:].lower()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import solutions
2+
from inspect import getmembers, isfunction
3+
4+
5+
def test_capitalize_all_lowercase():
6+
for _, value in getmembers(solutions, isfunction):
7+
assert value("deku") == "Deku"

challenges/how-to-check-if-a-key-exists-in-a-dictionary/check-key-2.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

challenges/how-to-check-if-a-key-exists-in-a-dictionary/check-key-advance-dict.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

challenges/how-to-check-if-a-key-exists-in-a-dictionary/check-key.py

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Provides a series of solutions to the challenge provided at the following link:
3+
https://therenegadecoder.com/code/how-to-check-if-a-key-exists-in-a-dictionary-in-python/#challenge
4+
"""
5+
6+
7+
def case_insensitive_lookup_1(dictionary: dict, term: str):
8+
"""
9+
Implements a case insensitive lookup using a try/catch.
10+
11+
:author: Muhimen123
12+
:param dictionary: a literal dictionary of terms and definitions
13+
:param term: the term to lookup
14+
:return: the definition if it exists
15+
"""
16+
key = term.lower()
17+
try:
18+
return dictionary[key.lower()]
19+
except:
20+
return None
21+
22+
23+
def case_insensitive_lookup_2(dictionary: dict, term: str):
24+
"""
25+
Implements a case insensitive lookup using the get() method.
26+
27+
:author: jrg94
28+
:param dictionary: a literal dictionary of terms and definitions
29+
:param term: the term to lookup
30+
:return: the definition if it exists
31+
"""
32+
return dictionary.get(term.lower())

challenges/how-to-check-if-a-string-contains-a-substring/check_substring.py

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Provides a series of solutions to the challenge provided at the following link:
3+
https://therenegadecoder.com/code/how-to-check-if-a-string-contains-a-substring-in-python/#challenge
4+
"""
5+
6+
7+
def search_1(addresses: list, street_number: str, street_name: str) -> list:
8+
"""
9+
Implements a two-term search functionality using sets.
10+
11+
:author: jrg94
12+
:param addresses: a list of addresses
13+
:param street_number: a street number
14+
:param street_name: a street name
15+
:return: a list of street addresses that match the term-term query
16+
"""
17+
number_matches = set()
18+
name_matches = set()
19+
for address in addresses:
20+
if not street_number or street_number in address: number_matches.add(address)
21+
if not street_name or street_name in address: name_matches.add(address)
22+
intersection = number_matches & name_matches
23+
return list(intersection)

challenges/how-to-compute-absolute-value/compute-absolute-value.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
print('+' * number)
77
else: # The number is negative
88
print('-' * (-1 * number))
9-

0 commit comments

Comments
 (0)