source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 175 | Write a Python function named `calculate_percentage` that takes two numbers as input: `part` and `whole`. The function should calculate the percentage of the `part` in relation to the `whole` and return the result. The function should handle cases where `whole` is zero by returning `None` to avoid division by zero erro... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_percentage(part: float, whole: float) -> float:
"""
Calculate the percentage of the part in relation to the whole.
Args:
part (float): The part value.
whole (float): The whole value.
Retur... |
code_exercise_27k | 176 | Write a Python function named `calculate_combinations` that takes two positive integers as input: `n` and `r`. The function should calculate the number of combinations of `n` items taken `r` at a time using the mathematical formula for combinations, which is given by \( C(n, r) = \frac{n!}{r!(n-r)!} \). The function sh... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_combinations(n: int, r: int) -> int:
"""
Calculate the number of combinations of n items taken r at a time.
This function uses the mathematical formula for combinations, which is given by:
C(n... |
code_exercise_27k | 177 | Write a Python function named `calculate_permutations` that takes two positive integers as input: `n` and `r`. The function should calculate the number of permutations of `n` items taken `r` at a time and return the result. The function should handle edge cases such as when `r` is greater than `n` or when `r` is zero.
... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_permutations(n: int, r: int) -> int:
"""
Calculate the number of permutations of n items taken r at a time.
Args:
n (int): The total number of items.
r (int): The number of items t... |
code_exercise_27k | 181 | Write a Python function named `calculate_arithmetic_mean` that takes a list of numbers as input and returns the arithmetic mean. The function should handle empty lists by returning `None` instead of raising an error. The code should start with:
```python
from typing import List, Optional
def calculate_arithmetic_mean(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def calculate_arithmetic_mean(numbers: List[float]) -> Optional[float]:
"""
Calculate the arithmetic mean of a list of numbers.
Args:
numbers (List[float]): A list of numbers for w... |
code_exercise_27k | 182 | Write a Python function named `calculate_median_sorted` that takes a sorted list of numbers as input and returns the median value. The function should handle both even and odd lengths of the list correctly. The code should start with:
```python
from typing import List, Union
def calculate_median_sorted(numbers: List[i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_median_sorted(numbers: List[int]) -> Union[float, int]:
"""
Calculate the median value from a sorted list of numbers.
Args:
numbers (List[int]): A sorted list of numbers... |
code_exercise_27k | 201 | Write a Python function named `calculate_hamming_distance` that takes two strings of equal length as input: `string1` and `string2`. The function should calculate the Hamming distance between the two strings and return the result. The Hamming distance is defined as the number of positions at which the corresponding cha... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_hamming_distance(string1: str, string2: str) -> int:
"""
Calculate the Hamming distance between two strings of equal length.
The Hamming distance is the number of positions at which the corresponding
chara... |
code_exercise_27k | 202 | Write a Python function to calculate the edit distance (Levenshtein distance) between two given strings. The function should take two strings as input and return the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_edit_distance(string1: str, string2: str) -> int:
"""
Calculate the edit distance (Levenshtein distance) between two strings.
Args:
string1 (str): The first string.
string2 (str): The second st... |
code_exercise_27k | 206 | Write a Python function to calculate the Euclidean distance between two vectors represented as lists of numbers. The function should handle vectors of the same length and return the Euclidean distance as a float. The code should start with:
```python
from typing import List
import math
def calculate_euclidean_distance... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def calculate_euclidean_distance(vector1: List[float], vector2: List[float]) -> float:
"""
Calculate the Euclidean distance between two vectors represented as lists of numbers.
Args:
... |
code_exercise_27k | 217 | Write a Python function named `calculate_present_value_perpetuity` that takes two numbers as input: `annuity_payment` and `rate`. The function should calculate the present value of a perpetuity based on the given annuity payment and interest rate, and return the result. The function should handle edge cases such as zer... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_present_value_perpetuity(annuity_payment: float, rate: float) -> float:
"""
Calculate the present value of a perpetuity based on the given annuity payment and interest rate.
Parameters:
annuity_payment (fl... |
code_exercise_27k | 218 | Write a Python function named `calculate_future_value_perpetuity` that takes two numbers as input: `annuity_payment` and `rate`. The function should calculate the future value of a perpetuity based on the given annuity payment and interest rate, and return the result. The function should handle both integer and floatin... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_future_value_perpetuity(annuity_payment: float, rate: float) -> float:
"""
Calculate the future value of a perpetuity based on the given annuity payment and interest rate.
Args:
annuity_payment (float)... |
code_exercise_27k | 219 | Write a Python function to calculate the sum of two numbers, `a` and `b`, and return the result. The function should handle both integer and floating-point inputs. The code should start with:
```python
def sum_of_two_numbers(a: int | float, b: int | float) -> int | float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_two_numbers(a: int | float, b: int | float) -> int | float:
"""
Calculate the sum of two numbers.
This function takes two numbers, `a` and `b`, and returns their sum.
Both `a` and `b` can be either integers o... |
code_exercise_27k | 220 | Write a Python function to calculate the average of a list of numbers. The function should handle the following cases:
1. If the input list is empty, the function should return 0.
2. If the input list contains numbers, the function should return the average of those numbers.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_average(numbers: List[float]) -> float:
"""
Calculate the average of a list of numbers.
Args:
numbers (List[float]): A list of numbers for which the average is to be calculated... |
code_exercise_27k | 221 | Write a Python function to count the number of vowels in a given string. The function should be case-insensitive and should handle both uppercase and lowercase vowels. The code should start with:
```python
def count_vowels(string: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels(string: str) -> int:
"""
Counts the number of vowels in a given string.
This function takes a string as input and returns the number of vowels in the string.
The function is case-insensitive and conside... |
code_exercise_27k | 222 | Write a Python function to filter a list of strings and return a new list containing only the strings that start with a vowel (either uppercase or lowercase). The function should handle an empty list and strings that do not start with a vowel. The code should start with:
```python
from typing import List
def filter_st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_strings_starting_with_vowel(strings: List[str]) -> List[str]:
"""
Filters a list of strings and returns a new list containing only the strings that start with a vowel.
Args:
strin... |
code_exercise_27k | 223 | Write a Python function to determine if a given number is a prime number. The function should return `True` if the number is prime and `False` otherwise. The function should handle edge cases such as negative numbers, 0, and 1, which are not prime numbers. The code should start with:
```python
def is_prime(number: int)... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(number: int) -> bool:
"""
Determine if a given number is a prime number.
Args:
number (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise.
... |
code_exercise_27k | 224 | Write a Python function to filter out prime numbers from a given list of integers. The function should return a new list containing only the prime numbers found in the input list. The function should handle edge cases such as an empty list or a list containing non-prime numbers.
The code should start with:
```python
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_prime_numbers(numbers: List[int]) -> List[int]:
"""
Filters out prime numbers from a given list of integers.
Args:
numbers (List[int]): A list of integers from which to filter pri... |
code_exercise_27k | 225 | Write a Python function to reverse a given string. The function should handle both empty strings and non-empty strings. The code should start with:
```python
def reverse_string(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_string(string: str) -> str:
"""
Reverses the given string.
Args:
string (str): The input string to be reversed.
Returns:
str: The reversed string. If the input is None, returns an empty st... |
code_exercise_27k | 226 | Write a Python function to reverse each string in a given list of strings. The function should return a new list containing the reversed versions of the original strings. The code should start with:
```python
from typing import List
def reverse_each_string(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_each_string(strings: List[str]) -> List[str]:
"""
Reverses each string in the given list of strings and returns a new list containing the reversed strings.
Args:
strings (List[st... |
code_exercise_27k | 228 | Write a Python function to filter out palindrome numbers from a given list of numbers. A palindrome number reads the same backward as forward. The function should return a new list containing only the palindrome numbers from the input list.
The code should start with:
```python
from typing import List
def filter_pali... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_palindrome_numbers(numbers: List[int]) -> List[int]:
"""
Filters out palindrome numbers from a given list of numbers.
Args:
numbers (List[int]): A list of integers.
Returns:
... |
code_exercise_27k | 231 | Write a Python function to calculate the factorial of a given non-negative integer. The factorial of a non-negative integer \( n \), denoted by \( n! \), is the product of all positive integers less than or equal to \( n \). The function should handle edge cases such as negative input by returning `None`.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def factorial(number: int) -> int:
"""
Calculate the factorial of a given non-negative integer.
The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.
... |
code_exercise_27k | 232 | Write a Python function to calculate the factorial of each number in a given list and return a new list containing these factorial values. The function should handle non-negative integers and return `None` for any negative input.
The code should start with:
```python
from typing import List, Optional
def calculate_fa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def calculate_factorials(numbers: List[int]) -> List[Optional[int]]:
"""
Calculate the factorial of each number in the given list and return a new list containing these factorial values.
A... |
code_exercise_27k | 234 | Write a Python function that takes a list of strings as input and returns a new list with all the vowels removed from each string. The function should handle both uppercase and lowercase vowels. The code should start with:
```python
from typing import List
def remove_vowels_from_strings(strings: List[str]) -> List[str... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_vowels_from_strings(strings: List[str]) -> List[str]:
"""
Removes all vowels from each string in the input list and returns a new list with the modified strings.
Args:
strings (Li... |
code_exercise_27k | 237 | Write a Python function to count the number of words in a given string. The function should handle various edge cases, such as empty strings, strings with only whitespace, and strings with multiple spaces between words. The function should also handle punctuation as part of words.
The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_words(string: str) -> int:
"""
Count the number of words in a given string.
This function splits the input string by any whitespace and returns the number of resulting words.
It handles various edge cases, inc... |
code_exercise_27k | 240 | Write a Python function to filter out perfect numbers from a given list of integers. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). The function should return a new list containing only the perfect numbers from the input list.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_perfect_numbers(numbers: List[int]) -> List[int]:
"""
Filters out perfect numbers from a given list of integers.
A perfect number is a positive integer that is equal to the sum of its pro... |
code_exercise_27k | 244 | Write a Python function to filter out perfect square numbers from a given list of integers. A perfect square number is an integer that is the square of an integer. The function should return a new list containing only the perfect square numbers from the input list.
The code should start with:
```python
from typing imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_perfect_squares(numbers: List[int]) -> List[int]:
"""
Filters out perfect square numbers from a given list of integers.
Args:
numbers (List[int]): A list of integers to be filtere... |
code_exercise_27k | 245 | Write a Python function to count the number of digits in a given string. The function should handle various edge cases, such as an empty string, a string with no digits, and a string with only digits. The function should also be able to handle non-string inputs by raising a `TypeError`.
The code should start with:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_digits(string: str) -> int:
"""
Counts the number of digits in a given string.
Args:
string (str): The input string to count digits from.
Returns:
int: The number of digits in the string.
... |
code_exercise_27k | 253 | Write a Python function to count the number of whitespace characters in a given string. The function should handle various types of whitespace characters, including spaces, tabs, newlines, and carriage returns. The code should start with:
```python
def count_whitespace_characters(string: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def count_whitespace_characters(string: str) -> int:
"""
Counts the number of whitespace characters in the given string.
Args:
string (str): The input string in which to count whitespace characters.
Returns:
... |
code_exercise_27k | 256 | Write a Python function to filter out narcissistic numbers from a given list of numbers. A narcissistic number (also known as a pluperfect number, an Armstrong number, or a plus perfect number) is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is a narcissi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_narcissistic_numbers(numbers: List[int]) -> List[int]:
"""
Filters out narcissistic numbers from a given list of numbers.
A narcissistic number is a number that is the sum of its own digi... |
code_exercise_27k | 257 | Write a Python function to count the number of uppercase vowels in a given string. Uppercase vowels are defined as 'A', 'E', 'I', 'O', and 'U'. The function should handle any input string, including empty strings and strings with no uppercase vowels. The code should start with:
```python
def count_uppercase_vowels(stri... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_uppercase_vowels(string: str) -> int:
"""
Counts the number of uppercase vowels in a given string.
Parameters:
string (str): The input string to count uppercase vowels from.
Returns:
int: The number o... |
code_exercise_27k | 261 | Write a Python function to determine if a given number is a circular prime. A circular prime is a prime number that remains prime under cyclic shifts of its digits. For example, 197 is a circular prime because 197, 971, and 719 are all prime numbers.
The code should start with:
```python
def is_circular_prime(number: ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_circular_prime(number: int) -> bool:
"""
Determine if a given number is a circular prime.
A circular prime is a prime number that remains prime under cyclic shifts of its digits.
Args:
number (int): The ... |
code_exercise_27k | 263 | Write a Python function to count the number of lowercase vowels in a given string. Lowercase vowels are defined as the characters 'a', 'e', 'i', 'o', and 'u'. The function should handle any input string, including empty strings and strings with no lowercase vowels. The code should start with:
```python
def count_lowerc... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_lowercase_vowels(string: str) -> int:
"""
Counts the number of lowercase vowels in a given string.
Parameters:
string (str): The input string to count the lowercase vowels from.
Returns:
int: The numb... |
code_exercise_27k | 265 | Write a Python function to determine if a given number is a happy number. A happy number is defined as a number that eventually reaches 1 when replaced by the sum of the squares of its digits, and all subsequent numbers formed by this process. If the number does not reach 1 and instead enters a cycle, it is not a happy... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_happy_number(number: int) -> bool:
"""
Determines if a given number is a happy number.
A happy number is a number that eventually reaches 1 when replaced by the sum of the squares of its digits,
and all subsequen... |
code_exercise_27k | 266 | Write a Python function to filter out happy numbers from a given list of integers. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endles... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_happy_numbers(numbers: List[int]) -> List[int]:
"""
Filters out happy numbers from a given list of integers.
A happy number is defined by the following process: Starting with any positive... |
code_exercise_27k | 271 | Write a Python function named `find_min` that takes a list of numbers as a parameter and returns the minimum number in the list. The function should handle lists of integers and floating-point numbers. The code should start with:
```python
from typing import List, Union
def find_min(numbers: List[Union[int, float]]) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_min(numbers: List[Union[int, float]]) -> Union[int, float]:
"""
Find the minimum number in a list of numbers.
Args:
numbers (List[Union[int, float]]): A list of numbers (inte... |
code_exercise_27k | 272 | Write a Python function named `count_occurrences` that takes a list of numbers and a target number as parameters, and returns the number of times the target number appears in the list. The function should be efficient and handle various types of input, including empty lists and non-existent target numbers.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def count_occurrences(numbers: List[Union[int, float]], target: Union[int, float]) -> int:
"""
Counts the number of times the target number appears in the list of numbers.
Args:
numbe... |
code_exercise_27k | 273 | Write a Python function named `reverse_string` that takes a string as a parameter and returns the reversed version of the string. The function should handle an empty string and should not use any built-in string reversal functions or methods. Instead, implement the reversal using a loop or recursion.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(string: str) -> str:
"""
Reverses the input string without using built-in reversal functions or methods.
Args:
string (str): The input string to be reversed.
Returns:
str: The reverse... |
code_exercise_27k | 274 | Write a Python function named `capitalize_words` that takes a string as a parameter and returns the string with the first letter of each word capitalized. The function should handle various edge cases, such as empty strings, strings with multiple spaces, and strings with punctuation.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
def capitalize_words(string: str) -> str:
"""
Capitalizes the first letter of each word in the given string.
Args:
string (str): The input string to be processed.
Returns:
str: The string with the first... |
code_exercise_27k | 278 | Write a Python function named `calculate_factorial` that takes an integer as a parameter and returns the factorial of that number. The factorial of a non-negative integer \( n \), denoted by \( n! \), is the product of all positive integers less than or equal to \( n \). The function should handle edge cases such as ne... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_factorial(number: int) -> int:
"""
Calculate the factorial of a given non-negative integer.
The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal ... |
code_exercise_27k | 279 | Write a Python function named `is_power_of_two` that takes an integer as a parameter and returns `True` if the number is a power of two, and `False` otherwise. A power of two is a number of the form \(2^n\), where \(n\) is an integer. The function should handle edge cases such as non-positive numbers and should be effi... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_power_of_two(number: int) -> bool:
"""
Determines if a given number is a power of two.
A power of two is a number of the form 2^n, where n is an integer.
This function uses a bitwise operation to check if the num... |
code_exercise_27k | 281 | Write a Python function named `reverse_list` that takes a list as a parameter and returns a new list with the elements in reverse order. The function should not modify the original list. The code should start with:
```python
from typing import List
def reverse_list(lst: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list(lst: List[int]) -> List[int]:
"""
Returns a new list with the elements of the input list in reverse order.
Args:
lst (List[int]): The input list to be reversed.
Returns... |
code_exercise_27k | 282 | Write a Python function named `find_missing_number` that takes a list of integers from 1 to `n` (inclusive) with exactly one number missing, and returns the missing number. The function should be efficient and handle edge cases such as an empty list or a list with only one element.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_number(numbers: List[int]) -> int:
"""
Finds the missing number in a list of integers from 1 to n (inclusive) with exactly one number missing.
Args:
numbers (List[int]): A l... |
code_exercise_27k | 283 | Write a Python function named `remove_whitespace` that takes a string as a parameter and returns the string with all leading and trailing whitespace removed. Additionally, the function should handle cases where the input string is `None` by returning an empty string.
The code should start with:
```python
def remove_wh... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace(string: str) -> str:
"""
Removes all leading and trailing whitespace from the given string.
If the input string is None, returns an empty string.
Args:
string (str): The input string from w... |
code_exercise_27k | 285 | Write a Python function named `is_pangram` that takes a string as a parameter and returns `True` if the string is a pangram, and `False` otherwise. A pangram is a sentence that contains every letter of the alphabet at least once. The function should be case-insensitive and should ignore non-alphabetic characters.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_pangram(sentence: str) -> bool:
"""
Determines if the given string is a pangram.
A pangram is a sentence that contains every letter of the alphabet at least once.
This function is case-insensitive and ignores non... |
code_exercise_27k | 287 | Write a Python function named `is_perfect_square` that takes an integer as a parameter and returns `True` if the number is a perfect square, and `False` otherwise. A perfect square is an integer that is equal to the square of another integer. The function should handle both positive and negative integers.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_perfect_square(number: int) -> bool:
"""
Determines if a given integer is a perfect square.
A perfect square is an integer that is equal to the square of another integer.
This function checks if the input number ... |
code_exercise_27k | 288 | Write a Python function named `count_words` that takes a string as a parameter and returns the number of words in the string. A word is defined as a sequence of non-space characters. The function should handle various edge cases, such as strings with multiple spaces, leading and trailing spaces, and empty strings.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_words(string: str) -> int:
"""
Counts the number of words in a given string. A word is defined as a sequence of non-space characters.
Args:
string (str): The input string to count words from.
Returns:... |
code_exercise_27k | 289 | Write a Python function named `find_odd_numbers` that takes a list of integers as a parameter and returns a new list containing only the odd numbers from the original list. The function should be efficient and handle various edge cases, such as an empty list or a list with no odd numbers.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_odd_numbers(numbers: List[int]) -> List[int]:
"""
Returns a new list containing only the odd numbers from the given list of integers.
Args:
numbers (List[int]): A list of integers f... |
code_exercise_27k | 290 | Write a Python function named `find_even_numbers` that takes a list of integers as a parameter and returns a new list containing only the even numbers from the original list. The function should handle an empty list and return an empty list in that case. The function should also handle lists with no even numbers and re... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_even_numbers(numbers: List[int]) -> List[int]:
"""
Returns a new list containing only the even numbers from the given list of integers.
Args:
numbers (List[int]): A list of integers... |
code_exercise_27k | 292 | Write a Python function named `find_longest_common_prefix` that takes a list of strings as a parameter and returns the longest common prefix among the strings. If there is no common prefix, return an empty string. The function should handle edge cases such as an empty list or a list containing strings with no common pr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_longest_common_prefix(strings: List[str]) -> str:
"""
Finds the longest common prefix among a list of strings.
Args:
strings (List[str]): A list of strings to find the longest commo... |
code_exercise_27k | 293 | Write a Python function named `find_second_largest` that takes a list of numbers as a parameter and returns the second largest number in the list. Assume the list has at least two distinct numbers. The function should handle lists with both integers and floating-point numbers. The code should start with:
```python
from... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_second_largest(numbers: List[Union[int, float]]) -> Union[int, float]:
"""
Find the second largest number in a list of numbers.
This function iterates through the list to find and re... |
code_exercise_27k | 294 | Write a Python function named `find_third_smallest` that takes a list of numbers as a parameter and returns the third smallest number in the list. Assume the list has at least three distinct numbers. The function should be efficient and handle the input constraints properly.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_third_smallest(numbers: List[int]) -> int:
"""
Finds the third smallest number in a list of at least three distinct numbers.
Args:
numbers (List[int]): A list of at least three dist... |
code_exercise_27k | 296 | Write a Python function named `find_unique_characters` that takes a string as a parameter and returns a new string containing only the unique characters from the original string. The order of the characters in the new string should be the same as their first occurrence in the original string. The function should handle... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_unique_characters(string: str) -> str:
"""
Returns a new string containing only the unique characters from the original string,
maintaining the order of their first occurrence.
Args:
string (str): The i... |
code_exercise_27k | 297 | Write a Python function named `find_missing_elements` that takes two lists as parameters, `list1` and `list2`, and returns a new list containing the elements that are present in `list1` but not in `list2`. The function should be efficient and handle cases where the lists contain duplicate elements.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_elements(list1: List[int], list2: List[int]) -> List[int]:
"""
Returns a list of elements that are present in list1 but not in list2.
Args:
list1 (List[int]): The first list... |
code_exercise_27k | 298 | Write a Python function named `find_common_elements_count` that takes two lists as parameters, `list1` and `list2`, and returns the count of common elements between the two lists. The function should be efficient and handle duplicate elements correctly.
The code should start with:
```python
from typing import List
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements_count(list1: List[int], list2: List[int]) -> int:
"""
Returns the count of common elements between two lists.
Args:
list1 (List[int]): The first list of integers.
... |
code_exercise_27k | 299 | Write a Python function named `find_missing_elements_count` that takes two lists as parameters, `list1` and `list2`, and returns the count of elements that are present in `list1` but not in `list2`. The function should handle cases where the lists contain duplicate elements and should return the correct count based on ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_elements_count(list1: List[int], list2: List[int]) -> int:
"""
Calculate the count of elements that are present in list1 but not in list2.
Args:
list1 (List[int]): The first... |
code_exercise_27k | 301 | Write a Python function named `find_missing_elements_sum` that takes two lists as parameters, `list1` and `list2`, and returns the sum of the elements that are present in `list1` but not in `list2`. The function should handle lists containing integers and floats.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_missing_elements_sum(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> Union[int, float]:
"""
Calculate the sum of the elements that are present in list1 but not in list2... |
code_exercise_27k | 302 | Write a Python function named `find_common_elements_product` that takes two lists as parameters, `list1` and `list2`, and returns the product of the common elements between the two lists. If there are no common elements, the function should return 0. The function should handle lists containing integers and floats.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_common_elements_product(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> Union[int, float]:
"""
Calculate the product of the common elements between two lists.
Args... |
code_exercise_27k | 303 | Write a Python function named `find_missing_elements_product` that takes two lists as parameters, `list1` and `list2`, and returns the product of the elements that are present in `list1` but not in `list2`. The function should handle cases where the lists contain integers or floats. If there are no missing elements, th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_missing_elements_product(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> Union[int, float]:
"""
Calculate the product of the elements that are present in list1 but not ... |
code_exercise_27k | 304 | Write a Python function named `find_common_elements_average` that takes two lists as parameters, `list1` and `list2`, and returns the average of the common elements between the two lists. If there are no common elements, the function should return 0. The function should handle lists of integers and floating-point numbe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements_average(list1: List[float], list2: List[float]) -> float:
"""
Calculate the average of the common elements between two lists.
Args:
list1 (List[float]): The first li... |
code_exercise_27k | 305 | Write a Python function named `find_missing_elements_average` that takes two lists as parameters, `list1` and `list2`, and returns the average of the elements that are present in `list1` but not in `list2`. If there are no such elements, the function should return 0.
The code should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_elements_average(list1: List[int], list2: List[int]) -> float:
"""
Calculate the average of the elements that are present in list1 but not in list2.
Args:
list1 (List[int]):... |
code_exercise_27k | 306 | Write a Python function named `find_common_elements_median` that takes two lists as parameters, `list1` and `list2`, and returns the median of the common elements between the two lists. If there are an even number of common elements, return the average of the two middle elements. If there are no common elements, return... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements_median(list1: List[int], list2: List[int]) -> float:
"""
Calculate the median of the common elements between two lists.
Args:
list1 (List[int]): The first list of in... |
code_exercise_27k | 307 | Write a Python function named `find_missing_elements_median` that takes two lists as parameters, `list1` and `list2`, and returns the median of the elements that are present in `list1` but not in `list2`. If there are an even number of missing elements, return the average of the two middle elements.
The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_elements_median(list1: List[int], list2: List[int]) -> float:
"""
Calculate the median of the elements that are present in list1 but not in list2.
Args:
list1 (List[int]): T... |
code_exercise_27k | 308 | Write a Python function named `find_common_elements_mode` that takes two lists as parameters, `list1` and `list2`, and returns the mode of the common elements between the two lists. If there are multiple modes, return the smallest mode. The function should handle cases where there are no common elements by returning `N... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
from collections import Counter
def find_common_elements_mode(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> Union[int, float, None]:
"""
Find the mode of the common elements b... |
code_exercise_27k | 316 | Write a Python function named `find_common_elements_absolute_difference` that takes two lists as parameters, `list1` and `list2`, and returns the absolute difference between the sums of the common elements between the two lists. The function should handle cases where there are no common elements by returning 0.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements_absolute_difference(list1: List[int], list2: List[int]) -> int:
"""
Calculate the absolute difference between the sums of the common elements between two lists.
Args:
... |
code_exercise_27k | 317 | Write a Python function named `find_missing_elements_absolute_difference` that takes two lists as parameters, `list1` and `list2`, and returns the absolute difference between the sums of the elements that are present in `list1` but not in `list2`. The function should handle lists containing integers or floating-point n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_elements_absolute_difference(list1: List[float], list2: List[float]) -> float:
"""
Calculate the absolute difference between the sums of the elements that are present in list1 but not in... |
code_exercise_27k | 318 | Write a Python function named `find_common_elements_product_of_squares` that takes two lists as parameters, `list1` and `list2`, and returns the product of the squares of the common elements between the two lists. The function should handle cases where there are no common elements by returning 0.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements_product_of_squares(list1: List[int], list2: List[int]) -> int:
"""
Calculate the product of the squares of the common elements between two lists.
Args:
list1 (List[i... |
code_exercise_27k | 326 | Write a Python function named `find_common_elements_geometric_mean` that takes two lists as parameters, `list1` and `list2`, and returns the geometric mean of the common elements between the two lists. The geometric mean is the nth root of the product of n numbers. The function should handle cases where there are no co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def find_common_elements_geometric_mean(list1: List[int], list2: List[int]) -> float:
"""
Calculate the geometric mean of the common elements between two lists.
Args:
list1 (List... |
code_exercise_27k | 328 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters. The function should handle various escape sequences such as `\n`, `\t`, `\r`, `\\`, `\"`, and `\'`. The code should start with:
```python
def replace_escape_characters(input... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters.
Args:
input_string (str): The input string containing escape chara... |
code_exercise_27k | 329 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`). The function should handle various escape sequences such as `'\t'`, `'\r'`, `'\b'`, `'\f'`, `'\v'`, and `'\\'`. The newline charac... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_newline(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline character ('\n').
Args:
... |
code_exercise_27k | 330 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`) and the tab character (`'\t'`). The function should handle various escape sequences such as `'\r'`, `'\b'`, `'\f'`, `'\v'`, `'\''`,... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_newline_tab(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline ('\n') and tab ('\t') characters,... |
code_exercise_27k | 331 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`), the tab character (`'\t'`), and the backslash character (`'\\'`). The function should handle various escape sequences such as `'\a... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_newline_tab_backslash(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline character ('\n'), the t... |
code_exercise_27k | 332 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`), the tab character (`'\t'`), the backslash character (`'\\'`), and the double quote character (`'\"'`). The function should handle ... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_specified(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline character ('\n'), the tab character... |
code_exercise_27k | 333 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`), the tab character (`'\t'`), the backslash character (`'\\'`), the double quote character (`'\"'`), and the single quote character ... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_special(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline character ('\n'), the tab character (... |
code_exercise_27k | 334 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`), the tab character (`'\t'`), the backslash character (`'\\'`), the double quote character (`'\"'`), the single quote character (`'\... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters_except_specified(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline ('\n'), tab ('\t'), backslash ('\\'... |
code_exercise_27k | 335 | Write a Python function that takes a string as input and returns the string with all escape characters replaced by their corresponding characters, except for the newline character (`'\n'`), the tab character (`'\t'`), the backslash character (`'\\'`), the double quote character (`'\"'`), the single quote character (`'\... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_escape_characters(input_string: str) -> str:
"""
Replaces all escape characters in the input string with their corresponding characters,
except for the newline character ('\n'), the tab character ('\t'), the back... |
code_exercise_27k | 350 | Write a Python function to find the last non-space character in a given string. If the string is empty or contains only spaces, the function should return an empty string. The function should handle strings with leading, trailing, and multiple spaces between words.
The code should start with:
```python
def get_last_no... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_last_non_space_character(input_string: str) -> str:
"""
Returns the last non-space character in the given string.
If the string is empty or contains only spaces, returns an empty string.
Args:
input_stri... |
code_exercise_27k | 351 | Write a Python function to reverse the words in a given string while maintaining the order of the words. For example, if the input string is "Hello World", the output should be "World Hello". The function should handle empty strings and strings with multiple spaces between words.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_string(input_string: str) -> str:
"""
Reverses the words in a given string while maintaining the order of the words.
Args:
input_string (str): The input string containing words to be reversed.
... |
code_exercise_27k | 353 | Write a Python function to convert all lowercase letters in a given string to uppercase while leaving all other characters (such as digits, punctuation, and spaces) unchanged. The function should handle edge cases such as an empty string or a string with no lowercase letters. The code should start with:
```python
def c... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_uppercase(input_string: str) -> str:
"""
Converts all lowercase letters in the input string to uppercase while leaving other characters unchanged.
Args:
input_string (str): The input string to be proc... |
code_exercise_27k | 355 | Write a Python function to remove all leading and trailing whitespace characters from a given string. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with:
```python
def remove_whitespace(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace(input_string: str) -> str:
"""
Removes all leading and trailing whitespace characters from the given string.
Args:
input_string (str): The input string from which to remove whitespace.
Ret... |
code_exercise_27k | 357 | Write a Python function to count the number of occurrences of a specified character in a given string. The function should handle both uppercase and lowercase characters as the same. The code should start with:
```python
def count_occurrences(input_string: str, char: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_occurrences(input_string: str, char: str) -> int:
"""
Counts the number of occurrences of a specified character in a given string,
treating uppercase and lowercase characters as the same.
Args:
input_s... |
code_exercise_27k | 359 | Write a Python function to reverse the order of words in a given string. The function should handle various edge cases, such as strings with multiple spaces, leading/trailing spaces, and empty strings. The code should start with:
```python
def reverse_words_in_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_string(input_string: str) -> str:
"""
Reverses the order of words in a given string.
This function takes a string as input and returns a new string with the words in reverse order.
It handles multip... |
code_exercise_27k | 361 | Write a Python function to replace the first occurrence of a specified word in a given string with another word. The function should handle cases where the word to be replaced is at the beginning, middle, or end of the string, and should not replace substrings that are part of other words. The function should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def replace_first_occurrence(input_string: str, old_word: str, new_word: str) -> str:
"""
Replaces the first occurrence of a specified word in the input string with another word.
Args:
input_string (str):... |
code_exercise_27k | 365 | Write a Python function to remove all digits from a given string and return the modified string. The function should handle any input string, including those with no digits, and should not modify non-digit characters. The code should start with:
```python
def remove_digits(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def remove_digits(input_string: str) -> str:
"""
Removes all digits from the given input string and returns the modified string.
Args:
input_string (str): The input string from which digits are to be removed.
... |
code_exercise_27k | 366 | Write a Python function to remove all non-alphanumeric characters from a given string. The function should return the modified string. The code should start with:
```python
def remove_non_alphanumeric(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_non_alphanumeric(input_string: str) -> str:
"""
Removes all non-alphanumeric characters from the given input string.
Args:
input_string (str): The input string from which non-alphanumeric characters will ... |
code_exercise_27k | 367 | Write a Python function to perform a Caesar cipher on a given string. The Caesar cipher shifts each letter in the string by a specified number of positions in the alphabet. Non-alphabetic characters should remain unchanged. The function should handle both uppercase and lowercase letters and should wrap around the alpha... | Here is the Python code to solve the given problem in the markdown block:
```python
def caesar_cipher(input_string: str, shift: int) -> str:
"""
Perform a Caesar cipher on the input string by shifting each letter by a specified number of positions in the alphabet.
Args:
input_string (str): The inpu... |
code_exercise_27k | 368 | Write a Python function to reverse the order of words in a given string. The function should handle various edge cases, such as strings with multiple spaces, leading/trailing spaces, and empty strings. The code should start with:
```python
def reverse_words_order(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_order(input_string: str) -> str:
"""
Reverses the order of words in a given string.
This function takes a string as input and returns a new string with all the words in reverse order.
It handles multip... |
code_exercise_27k | 373 | Write a Python function to remove all occurrences of a specified substring from a given input string. The function should handle cases where the substring is not present in the input string and should return the original string in such cases. The function should also handle empty strings and substrings appropriately.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_substring(input_string: str, substring: str) -> str:
"""
Removes all occurrences of a specified substring from the input string.
Args:
input_string (str): The input string from which the substring is to b... |
code_exercise_27k | 374 | Write a Python function to remove all occurrences of a specified character from a given string. The function should handle both single and multi-character strings and should be case-sensitive. The code should start with:
```python
def remove_character(input_string: str, char: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_character(input_string: str, char: str) -> str:
"""
Removes all occurrences of a specified character from the input string.
Args:
input_string (str): The input string from which the character is to be rem... |
code_exercise_27k | 376 | Write a Python function to remove all occurrences of a specified substring from a given input string. The function should handle cases where the substring is not found in the input string and should return the original string in such cases. The function should also handle edge cases such as empty strings and substrings... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_substring(input_string: str, substring: str) -> str:
"""
Removes all occurrences of a specified substring from the input string.
Args:
input_string (str): The input string from which the substring is to b... |
code_exercise_27k | 377 | Write a Python function to remove all leading and trailing whitespace characters from a given string. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with:
```python
def remove_whitespace(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_whitespace(input_string: str) -> str:
"""
Removes all leading and trailing whitespace characters from the given string.
Args:
input_string (str): The input string from which to remove the whitespace.
... |
code_exercise_27k | 378 | Write a Python function to remove all trailing whitespace characters from a given string. The function should return the string with all trailing whitespace removed. The code should start with:
```python
def remove_trailing_whitespace(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_trailing_whitespace(input_string: str) -> str:
"""
Removes all trailing whitespace characters from the given input string.
Args:
input_string (str): The input string from which trailing whitespace charact... |
code_exercise_27k | 379 | Write a Python function to remove all leading and trailing whitespace characters from a given string. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with:
```python
def trim_whitespace(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def trim_whitespace(input_string: str) -> str:
"""
Removes all leading and trailing whitespace characters from the given string.
Args:
input_string (str): The input string from which to remove the whitespace charact... |
code_exercise_27k | 380 | Write a Python function to clean a given string by removing all leading and trailing whitespace, and condensing all internal whitespace to a single space. The function should handle various types of whitespace characters, including spaces, tabs, and newlines.
The code should start with:
```python
def clean_string(inpu... | Here is the Python code to solve the given problem in the markdown block:
```python
def clean_string(input_string: str) -> str:
"""
Cleans the input string by removing all leading and trailing whitespace, and condensing all internal whitespace to a single space.
Args:
input_string (str): The input ... |
code_exercise_27k | 381 | Write a Python function to remove all leading and trailing whitespace from a given string while preserving all internal whitespace. The function should handle various types of whitespace characters, including spaces, tabs, and newlines.
The code should start with:
```python
def trim_whitespace(input_string: str) -> st... | Here is the Python code to solve the given problem in the markdown block:
```python
def trim_whitespace(input_string: str) -> str:
"""
Removes all leading and trailing whitespace from the input string while preserving all internal whitespace.
Args:
input_string (str): The input string from which to... |
code_exercise_27k | 382 | Write a Python function to normalize whitespace in a given string. The function should remove all leading and trailing whitespace characters and replace any sequence of internal whitespace characters with a single space. The function should be named `normalize_whitespace` and should start with:
```python
def normalize_... | Here is the Python code to solve the given problem in the markdown block:
```python
def normalize_whitespace(input_string: str) -> str:
"""
Normalizes the whitespace in the input string by removing all leading and trailing whitespace,
and replacing any sequence of internal whitespace characters with a singl... |
code_exercise_27k | 384 | Write a Python function to reverse a given string. The function should handle both normal strings and empty strings. The code should start with:
```python
def reverse_string(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_string(string: str) -> str:
"""
Reverses a given string.
Args:
string (str): The input string to be reversed.
Returns:
str: The reversed string. If the input is None, returns an empty stri... |
code_exercise_27k | 385 | Write a Python function named `remove_whitespace` that takes a string as input and returns the string with all whitespace characters removed. The function should handle various types of whitespace characters, including spaces, tabs, newlines, and carriage returns. The code should start with:
```python
def remove_whites... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_whitespace(string: str) -> str:
"""
Removes all whitespace characters from a given string.
Parameters:
string (str): The input string from which whitespace characters are to be removed.
Return... |
code_exercise_27k | 386 | Write a Python function named `replace_substring` that takes three string inputs: `original_string`, `old_substring`, and `new_substring`. The function should replace all occurrences of `old_substring` in `original_string` with `new_substring` and return the modified string. The function should handle cases where `old_... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_substring(original_string: str, old_substring: str, new_substring: str) -> str:
"""
Replaces all occurrences of a given substring in a string with a new substring.
Args:
original_string (str): The origin... |
code_exercise_27k | 388 | Write a Python function named `split_string` that takes two string inputs: `main_string` and `delimiter`. The function should split `main_string` into a list of substrings based on the `delimiter` and return the list. The function should handle cases where the `delimiter` is not found in the `main_string` and return th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def split_string(main_string: str, delimiter: str) -> List[str]:
"""
Splits a given string into a list of substrings based on a delimiter.
Args:
main_string (str): The main string to be spli... |
code_exercise_27k | 389 | Write a Python function named `join_strings` that takes two inputs: `string_list` (a list of strings) and `delimiter` (a string). The function should join the strings in `string_list` using the `delimiter` and return the concatenated string. The function should handle cases where `string_list` is empty or contains only... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def join_strings(string_list: List[str], delimiter: str) -> str:
"""
Joins a list of strings into a single string using a specified delimiter.
Args:
string_list (List[str]): The list of stri... |
code_exercise_27k | 390 | Write a Python function named `remove_duplicates` that takes a string as input and returns the string with all duplicate characters removed while preserving the order of the first occurrence of each character. The function should handle an empty string and should not use the built-in `set` function directly to remove d... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_duplicates(string: str) -> str:
"""
Removes all duplicate characters from a given string while preserving the order of the first occurrence of each character.
Args:
string (str): The input string from whi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.