Skip to content
Closed
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
4 changes: 4 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
* [Count 1S Brian Kernighan Method](bit_manipulation/count_1s_brian_kernighan_method.py)
* [Count Number Of One Bits](bit_manipulation/count_number_of_one_bits.py)
* [Excess 3 Code](bit_manipulation/excess_3_code.py)
* [Fast Walsh Hadamard Transform](bit_manipulation/fast_walsh_hadamard_transform.py)
* [Find Previous Power Of Two](bit_manipulation/find_previous_power_of_two.py)
* [Find Unique Number](bit_manipulation/find_unique_number.py)
* [Gray Code Sequence](bit_manipulation/gray_code_sequence.py)
Expand Down Expand Up @@ -765,6 +766,7 @@
* [Juggler Sequence](maths/juggler_sequence.py)
* [Karatsuba](maths/karatsuba.py)
* [Kth Lexicographic Permutation](maths/kth_lexicographic_permutation.py)
* [Laplace Transformation](maths/laplace_transformation.py)
* [Largest Of Very Large Numbers](maths/largest_of_very_large_numbers.py)
* [Least Common Multiple](maths/least_common_multiple.py)
* [Line Intersection](maths/line_intersection.py)
Expand All @@ -787,6 +789,7 @@
* [Adams Bashforth](maths/numerical_analysis/adams_bashforth.py)
* [Bisection](maths/numerical_analysis/bisection.py)
* [Bisection 2](maths/numerical_analysis/bisection_2.py)
* [Brent Method](maths/numerical_analysis/brent_method.py)
* [Integration By Simpson Approx](maths/numerical_analysis/integration_by_simpson_approx.py)
* [Intersection](maths/numerical_analysis/intersection.py)
* [Nevilles Method](maths/numerical_analysis/nevilles_method.py)
Expand Down Expand Up @@ -838,6 +841,7 @@
* [Hexagonal Numbers](maths/series/hexagonal_numbers.py)
* [Logarithmic Series](maths/series/logarithmic_series.py)
* [P Series](maths/series/p_series.py)
* [Sieve Of Atkin](maths/sieve_of_atkin.py)
* [Sieve Of Eratosthenes](maths/sieve_of_eratosthenes.py)
* [Sigmoid](maths/sigmoid.py)
* [Signum](maths/signum.py)
Expand Down
19 changes: 10 additions & 9 deletions strings/lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ def lower(word: str) -> str:
>>> lower("whAT")
'what'
"""
result = []

for char in word:
code = ord(char)
if ASCII_UPPERCASE_START <= code <= ASCII_UPPERCASE_END:
char = chr(code + ASCII_CASE_OFFSET)
result.append(char)

return "".join(result)
start = ASCII_UPPERCASE_START
end = ASCII_UPPERCASE_END
offset = ASCII_CASE_OFFSET

return "".join(
[
chr(code + offset) if start <= (code := ord(char)) <= end else char
for char in word
]
)


if __name__ == "__main__":
Expand Down