diff --git a/DIRECTORY.md b/DIRECTORY.md index cbbed67b5456..b6abdae03ddd 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/strings/lower.py b/strings/lower.py index d66dcd3b7a4e..61b37af4d895 100644 --- a/strings/lower.py +++ b/strings/lower.py @@ -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__":