source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 1,866 | Write a Python function to determine if a given number is a perfect square. A perfect square is a number that can be expressed as the square of an integer. The function should return `True` if the number is a perfect square and `False` otherwise. The function should handle both positive and negative integers.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_perfect_square_number(number: int) -> bool:
"""
Determines if a given number is a perfect square.
A perfect square is a number that can be expressed as the square of an integer.
This function checks if the given ... |
code_exercise_27k | 1,867 | Write a Python function called `find_perfect_squares` that takes a list of integers as input and returns a new list containing only the perfect square numbers from the original list. A perfect square number is an integer that is the square of an integer. The function should use a helper function `is_perfect_square` to ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def is_perfect_square(num: int) -> bool:
"""
Check if a given number is a perfect square.
Args:
num (int): The number to check.
Returns:
bool: True if the number is ... |
code_exercise_27k | 1,868 | Write a Python function to determine if a given integer is a power of two. The function should return `True` if the number is a power of two, and `False` otherwise. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def is_power_of_two(number: int) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_power_of_two(number: int) -> bool:
"""
Determine if a given integer is a power of two.
Args:
number (int): The integer to be checked.
Returns:
bool: True if the number is a power of two, False ot... |
code_exercise_27k | 1,869 | Write a Python function called `find_powers_of_two` that takes a list of integers as input and returns a new list containing only the numbers that are powers of two from the original list. The function should use a helper function `is_power_of_two` to determine if a number is a power of two.
The starter code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_power_of_two(num: int) -> bool:
"""
Check if a given number is a power of two.
Args:
num (int): The number to check.
Returns:
bool: True if the number is a power of two, ... |
code_exercise_27k | 1,870 | Write a Python function to generate the first n Fibonacci numbers. The function should handle edge cases such as n being 0 or negative, and should return an empty list in such cases. The function should also handle the case where n is 1 by returning a list containing only the first Fibonacci number.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_fibonacci_numbers(n: int) -> List[int]:
"""
Generate and return a list of the first n Fibonacci numbers.
Args:
n (int): The number of Fibonacci numbers to generate.
Returns:
... |
code_exercise_27k | 1,871 | Write a Python function to calculate the factorial of a given non-negative integer using an iterative approach. The function should handle edge cases such as zero and large numbers efficiently. The code should start with:
```python
def find_factorial_number(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_factorial_number(number: int) -> int:
"""
Calculate and return the factorial of a given non-negative integer.
Args:
number (int): The non-negative integer to calculate the factorial of.
Returns:
... |
code_exercise_27k | 1,872 | Write a Python function called `find_factorial_list_number` that takes a list of integers as input and returns a new list containing the factorial of each number in the original list. The function should use a helper function `find_factorial_number` to compute the factorial of a single integer. The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_factorial_number(n: int) -> int:
"""
Calculate the factorial of a given integer.
Args:
n (int): The integer for which to calculate the factorial.
Returns:
int: The fact... |
code_exercise_27k | 1,873 | Write a Python function to calculate the sum of the digits of a given integer. The function should handle both positive and negative integers. The code should start with:
```python
def sum_of_digits(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def sum_of_digits(number: int) -> int:
"""
Calculate the sum of the digits of a given integer.
Args:
number (int): The integer whose digits are to be summed.
Returns:
int: The sum of the digits of the... |
code_exercise_27k | 1,875 | Write a Python function to find the reverse of a given integer. The function should handle both positive and negative integers. If the input is a negative number, the function should return the reverse of the absolute value of the number with a negative sign. The function should also handle edge cases such as zero and ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_reverse_number(number: int) -> int:
"""
Calculate and return the reverse of a given integer.
Args:
number (int): The integer to reverse.
Returns:
int: The reversed integer. If the input... |
code_exercise_27k | 1,876 | Write a Python function called `find_reverse_list_number` that takes a list of integers as input and returns a new list containing the reverse of each number in the original list. The function should handle both positive and negative integers correctly, reversing the digits while preserving the sign.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_reverse_list_number(numbers: List[int]) -> List[int]:
"""
Calculate and return a new list containing the reverse of each number in a given list.
Parameters:
numbers (List[int]): A l... |
code_exercise_27k | 1,877 | Write a Python function to determine if a given integer is a palindrome. A palindrome number is a number that reads the same backward as forward. The function should return `True` if the number is a palindrome and `False` otherwise. The function should handle both positive and negative integers.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_number(number: int) -> bool:
"""
Determine if a given integer is a palindrome.
Args:
number (int): The integer to be checked.
Returns:
bool: True if the number is a palindrome, False o... |
code_exercise_27k | 1,878 | Write a Python function called `find_palindrome_list_number` that takes a list of integers as input and returns a new list containing `True` or `False` indicating whether each number in the original list is a palindrome or not. A number is considered a palindrome if it reads the same backward as forward.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_palindrome_list_number(numbers: List[int]) -> List[bool]:
"""
Check if each number in a given list is a palindrome and return a new list containing True or False for each number.
Args:
... |
code_exercise_27k | 1,879 | Write a Python function to convert a binary number represented as a string to its decimal (base-10) representation. The function should handle binary strings of any length, including those with leading zeros. The function should start with:
```python
def binary_to_decimal(binary_str: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_decimal(binary_str: str) -> int:
"""
Convert a binary number represented as a string to its decimal (base-10) representation.
Args:
binary_str (str): The binary number to be converted, represented as a... |
code_exercise_27k | 1,881 | Write a Python function to convert a given decimal number to its binary representation as a string. The function should handle both positive and negative integers, and should return the binary representation without the '0b' prefix that Python's built-in `bin()` function includes. The function should also handle the sp... | Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_binary(decimal: int) -> str:
"""
Convert a given decimal number to its binary representation as a string.
Args:
decimal (int): The decimal number to be converted.
Returns:
str: The binary... |
code_exercise_27k | 1,883 | Write a Python function to convert a given hexadecimal number (in the form of a string) to its decimal representation as an integer. The function should handle both uppercase and lowercase hexadecimal characters and should be able to process hexadecimal numbers with or without the '0x' prefix.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_hexadecimal_to_decimal_number(hexadecimal: str) -> int:
"""
Convert a given hexadecimal number (in the form of a string) to its decimal representation as an integer.
Args:
hexadecimal (str): The hexadec... |
code_exercise_27k | 1,884 | Write a Python function called `find_hexadecimal_to_decimal_list_number` that takes a list of hexadecimal numbers (in the form of strings) as input and returns a new list containing the decimal representation of each hexadecimal number as integers. The function should use Python's built-in `int` function with base 16 t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_hexadecimal_to_decimal_list_number(hexadecimal_list: List[str]) -> List[int]:
"""
Convert each hexadecimal number in a given list (in the form of strings) to its decimal representation as intege... |
code_exercise_27k | 1,885 | Write a Python function to convert an octal number (represented as a string) to its decimal representation. The function should handle octal numbers with valid characters (0-7) and return the corresponding decimal integer. The function should start with:
```python
def octal_to_decimal(octal: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def octal_to_decimal(octal: str) -> int:
"""
Convert a given octal number (in the form of a string) to its decimal representation as an integer.
Args:
octal (str): The octal number to be converted. It should contain... |
code_exercise_27k | 1,886 | Write a Python function called `find_octal_to_decimal_list_number` that takes a list of octal numbers (in the form of strings) as input and returns a new list containing the decimal representation of each octal number as integers. The function should use a helper function `find_octal_to_decimal_number` to convert each ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_octal_to_decimal_number(octal_str):
"""
Convert a single octal number (in the form of a string) to its decimal representation.
Parameters:
octal_str (str): A string representing an octal number.
Re... |
code_exercise_27k | 1,888 | Write a Python function to count the number of negative numbers in a given list of integers. The function should handle an empty list and return 0 in such cases. The function should also handle lists with all positive numbers and return 0 in such cases. The function should be efficient and handle large lists.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_negative_numbers(numbers: List[int]) -> int:
"""
Counts the number of negative numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
... |
code_exercise_27k | 1,889 | Write a Python function to count the number of even numbers in a given list of integers. The function should be named `count_even_numbers` and should take a list of integers as input. The function should return an integer representing the count of even numbers in the list.
The code should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_even_numbers(numbers: List[int]) -> int:
"""
Counts the number of even numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
int... |
code_exercise_27k | 1,890 | Write a Python function to count the number of odd numbers in a given list of integers. The function should be named `count_odd_numbers` and should take a single parameter, which is a list of integers. The function should return an integer representing the count of odd numbers in the list.
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 count_odd_numbers(numbers: List[int]) -> int:
"""
Counts the number of odd numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
int: ... |
code_exercise_27k | 1,891 | Write a Python function to count the number of zeros in a given list of integers. The function should handle an empty list and return 0 in that case. The function should also handle non-empty lists and count the occurrences of the integer 0.
The code should start with:
```python
from typing import List
def count_zero... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_zeros(numbers: List[int]) -> int:
"""
Counts the number of zeros in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
int: The count of... |
code_exercise_27k | 1,892 | 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 or a string with no digits. The function should be efficient and easy to understand.
The code should start with:
```python
def count_digits(string: str) -> int:
```
| 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. If None, it is treated as an empty string.
Returns:
in... |
code_exercise_27k | 1,897 | Write a Python function to count the number of uppercase letters in a given string. The function should handle an empty string and strings with no uppercase letters. The code should start with:
```python
def count_uppercase(string: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def count_uppercase(string: str) -> int:
"""
Counts the number of uppercase letters in a given string.
Args:
string (str): The input string to count uppercase letters from.
Returns:
int: The number of... |
code_exercise_27k | 1,900 | Write a Python function to count the number of unique elements in a given list. The function should handle lists with various types of elements, including integers, strings, and other data types. The function should return the count of unique elements as an integer.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def count_unique_elements(lst: List[Any]) -> int:
"""
Counts the number of unique elements in a given list.
Args:
lst (List[Any]): A list containing elements of any type.
Returns:
... |
code_exercise_27k | 1,903 | Write a Python function to count the number of palindromic substrings in a given string. A palindromic substring is a contiguous sequence of characters within the string that reads the same forwards and backwards. The function should return the total count of such substrings.
The code should start with:
```python
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_palindromic_substrings(s: str) -> int:
"""
Count the number of palindromic substrings in the given string.
Args:
s (str): The input string.
Returns:
int: The total count of palindromic substri... |
code_exercise_27k | 1,906 | Write a Python function to count the number of trailing zeros in the factorial of a given integer `n`. The function should be efficient and handle large values of `n` appropriately. The code should start with:
```python
def count_trailing_zeros_in_factorial(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_trailing_zeros_in_factorial(n: int) -> int:
"""
Counts the number of trailing zeros in the factorial of a given integer n.
Args:
n (int): The integer for which to count the trailing zeros in its factorial.... |
code_exercise_27k | 1,907 | Write a Python function to count the number of '1's in the binary representation of a given integer. The function should handle both positive and negative integers. The code should start with:
```python
def count_binary_ones(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_binary_ones(n: int) -> int:
"""
Counts the number of '1's in the binary representation of a given integer.
Args:
n (int): The integer whose binary '1's count is to be determined.
Returns:
int:... |
code_exercise_27k | 1,908 | Write a Python function to count the number of consecutive sequences of ones in a given list of integers. A consecutive sequence of ones is defined as a sequence where all the elements are ones and they appear consecutively without any other number in between. The function 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
def count_consecutive_ones(numbers: List[int]) -> int:
"""
Counts the number of consecutive sequences of ones in a given list of integers.
Args:
numbers (List[int]): A list of integers.
... |
code_exercise_27k | 1,910 | Write a Python function to count the number of sublists within a given list. A sublist is defined as a list that is an element of another list. The function should handle nested lists and count all levels of sublists. The code should start with:
```python
from typing import List
def count_sublists(lst: List) -> int:
`... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def count_sublists(lst: List) -> int:
"""
Counts the number of sublists within a given list. A sublist is defined as a list that is an element of another list.
Args:
lst (List): The list i... |
code_exercise_27k | 1,911 | Write a Python function to count the number of pairs of positive numbers in a given list of integers. A pair of positive numbers is defined as a pair where both numbers in the pair are greater than zero. The function should be efficient and avoid unnecessary computations.
The code should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_positive_pairs(numbers: List[int]) -> int:
"""
Counts the number of pairs of positive numbers in a given list of integers.
Parameters:
numbers (List[int]): A list of integers.
Ret... |
code_exercise_27k | 1,912 | Write a Python function to count the number of pairs of even numbers in a given list of integers. A pair of even numbers is defined as two numbers in the list that are both divisible by 2. The function should start with:
```python
from typing import List
def count_even_pairs(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_even_pairs(numbers: List[int]) -> int:
"""
Counts the number of pairs of even numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
... |
code_exercise_27k | 1,913 | Write a Python function to count the number of common elements between two lists. The function should efficiently handle the comparison and return the count of elements that appear in both lists. The code should start with:
```python
from typing import List
def count_common_elements(list1: List[int], list2: List[int])... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_common_elements(list1: List[int], list2: List[int]) -> int:
"""
Counts the number of common elements between two lists.
Args:
list1 (List[int]): The first list of integers.
... |
code_exercise_27k | 1,916 | Write a Python function to count the number of leading zeros in each binary string from a given list of binary strings. The function should return a list where each element corresponds to the count of leading zeros in the respective binary string.
The code should start with:
```python
from typing import List
def coun... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_leading_zeros(strings: List[str]) -> List[int]:
"""
Counts the number of leading zeros in each binary string from a given list of binary strings.
Args:
strings (List[str]): A list ... |
code_exercise_27k | 1,918 | Write a Python function to count the number of non-overlapping occurrences of a substring in a given string. The function should be case-sensitive and should not count overlapping occurrences of the substring.
The code should start with:
```python
def count_non_overlapping_occurrences(string: str, substring: str) -> i... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_non_overlapping_occurrences(string: str, substring: str) -> int:
"""
Counts the number of non-overlapping occurrences of a substring in a given string.
Args:
string (str): The string in which to search for... |
code_exercise_27k | 1,919 | Write a Python function to count the number of strings in a given list that start with a specified substring. The function should be named `count_substring_starts` and should take two parameters: a list of strings and a substring. The function should return an integer representing the count of strings in the list that ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts(strings: List[str], substring: str) -> int:
"""
Counts the number of strings in a given list that start with a specified substring.
Args:
strings (List[str]): A li... |
code_exercise_27k | 1,922 | Write a Python function called `count_substring_matches` that takes in a list of strings and a substring as input and returns the count of strings in the list that exactly match the substring. The function should be case-sensitive.
The code should start with:
```python
from typing import List
def count_substring_matc... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_matches(strings: List[str], substring: str) -> int:
"""
Counts the number of strings in the list that exactly match the given substring.
Args:
strings (List[str]): A list... |
code_exercise_27k | 1,923 | Write a Python function called `count_substring_starts_with_digit` that takes in a list of strings as input and returns the count of strings in the list that start with a digit (0-9). The function should handle an empty list and strings that are empty or do not start with a digit. The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_digit(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with a digit (0-9).
Args:
strings (List[str]): A list of strings to ... |
code_exercise_27k | 1,925 | Write a Python function called `count_substring_contains_digit` that takes in a list of strings as input and returns the count of strings in the list that contain at least one digit (0-9). The function should efficiently determine if a string contains a digit and count such strings.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_digit(strings: List[str]) -> int:
"""
Counts the number of strings in the given list that contain at least one digit (0-9).
Args:
strings (List[str]): A list of ... |
code_exercise_27k | 1,927 | Write a Python function called `count_substring_starts_with_letter` that takes in a list of strings as input and returns the count of strings in the list that start with a letter (a-z or A-Z). The function should handle an empty list and strings that are empty or do not start with a letter. 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 count_substring_starts_with_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the given list that start with a letter (a-z or A-Z).
Args:
strings (List[str]): A list... |
code_exercise_27k | 1,928 | Write a Python function called `count_substring_ends_with_letter` that takes in a list of strings as input and returns the count of strings in the list that end with a letter (a-z or A-Z). The function should handle an empty list and strings of varying lengths. The code should start with:
```python
from typing import L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with a letter (a-z or A-Z).
Args:
strings (List[str]): A list of string... |
code_exercise_27k | 1,929 | Write a Python function to count the number of strings in a given list that contain at least one letter (a-z or A-Z). The function should efficiently determine if a string contains any alphabetic character and return the count of such strings.
The code should start with:
```python
from typing import List
def count_su... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_letter(strings: List[str]) -> int:
"""
Counts the number of strings in a given list that contain at least one letter (a-z or A-Z).
Args:
strings (List[str]): A l... |
code_exercise_27k | 1,931 | Write a Python function called `count_substring_starts_with_whitespace` that takes in a list of strings as input and returns the count of strings in the list that start with a whitespace character (space, tab, newline, etc.). The function should handle an empty list and strings that are empty or do not start with a whi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_whitespace(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with a whitespace character.
Args:
strings (List[str]): A list ... |
code_exercise_27k | 1,932 | Write a Python function called `count_substring_ends_with_whitespace` that takes in a list of strings as input and returns the count of strings in the list that end with a whitespace character (space, tab, newline, etc.). The function should handle an empty list and strings with no trailing whitespace characters. The c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_whitespace(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with a whitespace character.
Args:
strings (List[str]): A list of s... |
code_exercise_27k | 1,934 | Write a Python function called `count_substring_matches_whitespace` that takes in a list of strings as input and returns the count of strings in the list that consist entirely of whitespace characters (space, tab, newline, etc.). The function should handle an empty list and strings with mixed characters appropriately.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_matches_whitespace(strings: List[str]) -> int:
"""
Counts the number of strings in the list that consist entirely of whitespace characters.
Args:
strings (List[str]): A l... |
code_exercise_27k | 1,935 | Write a Python function called `count_substring_starts_with_special` that takes in a list of strings as input and returns the count of strings in the list that start with a special character (non-alphanumeric and non-whitespace characters). The function should handle an empty list and strings with no special characters... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with a special character (non-alphanumeric and non-whitespace characters).
... |
code_exercise_27k | 1,936 | Write a Python function called `count_substring_ends_with_special` that takes in a list of strings as input and returns the count of strings in the list that end with a special character (non-alphanumeric and non-whitespace characters). The function should handle an empty list and strings with no special characters at ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with a special character (non-alphanumeric and non-whitespace characters).
Arg... |
code_exercise_27k | 1,937 | Write a Python function called `count_substring_contains_special` that takes in a list of strings as input and returns the count of strings in the list that contain at least one special character (non-alphanumeric and non-whitespace characters). The function should be efficient and handle edge cases such as empty strin... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_special(strings: List[str]) -> int:
"""
Counts the number of strings in a list that contain at least one special character (non-alphanumeric and non-whitespace characters).
... |
code_exercise_27k | 1,938 | Write a Python function called `count_substring_matches_special` that takes in a list of strings as input and returns the count of strings in the list that consist entirely of special characters (non-alphanumeric and non-whitespace characters). The function should start with:
```python
from typing import List
def coun... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_matches_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that consist entirely of special characters (non-alphanumeric and non-whitespace characters).
... |
code_exercise_27k | 1,939 | Write a Python function called `count_substring_starts_with_uppercase` that takes in a list of strings as input and returns the count of strings in the list that start with an uppercase letter (A-Z). The function should handle an empty list and strings that are empty or contain only non-alphabetic characters. The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_uppercase(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with an uppercase letter (A-Z).
Args:
strings (List[str]): A lis... |
code_exercise_27k | 1,944 | Write a Python function called `count_substring_ends_with_lowercase` that takes in a list of strings as input and returns the count of strings in the list that end with a lowercase letter (a-z). The function should handle an empty list and strings with no characters by returning 0. 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 count_substring_ends_with_lowercase(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with a lowercase letter (a-z).
Args:
strings (List[str]): A list of ... |
code_exercise_27k | 1,947 | Write a Python function called `count_substring_starts_with_digit_or_letter` that takes in a list of strings as input and returns the count of strings in the list that start with either a digit (0-9) or a letter (a-z or A-Z). The function should handle an empty list and strings that are empty or contain only whitespace... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_digit_or_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with either a digit (0-9) or a letter (a-z or A-Z).
Args:
... |
code_exercise_27k | 1,948 | Write a Python function called `count_substring_ends_with_digit_or_letter` that takes in a list of strings as input and returns the count of strings in the list that end with either a digit (0-9) or a letter (a-z or A-Z). The function should handle an empty list and strings of varying lengths. The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_digit_or_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with either a digit (0-9) or a letter (a-z or A-Z).
Args:
stri... |
code_exercise_27k | 1,949 | Write a Python function called `count_substring_contains_digit_or_letter` that takes in a list of strings as input and returns the count of strings in the list that contain either a digit (0-9) or a letter (a-z or A-Z). The function should be case-insensitive and should ignore any non-alphanumeric characters.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_digit_or_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the list that contain either a digit (0-9) or a letter (a-z or A-Z).
Args:
string... |
code_exercise_27k | 1,950 | Write a Python function called `count_substring_matches_digit_or_letter` that takes in a list of strings as input and returns the count of strings in the list that consist entirely of either digits (0-9) or letters (a-z or A-Z). The function should be case-insensitive, meaning it should treat 'a' and 'A' as the same.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_matches_digit_or_letter(strings: List[str]) -> int:
"""
Counts the number of strings in the list that consist entirely of either digits (0-9) or letters (a-z or A-Z).
Args:
... |
code_exercise_27k | 1,951 | Write a Python function called `count_substring_starts_with_whitespace_or_special` that takes in a list of strings as input and returns the count of strings in the list that start with either a whitespace character (space, tab, newline, etc.) or a special character (non-alphanumeric and non-whitespace characters).
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_whitespace_or_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with either a whitespace character or a special character.
A... |
code_exercise_27k | 1,952 | Write a Python function called `count_substring_ends_with_whitespace_or_special` that takes in a list of strings as input and returns the count of strings in the list that end with either a whitespace character (space, tab, newline, etc.) or a special character (non-alphanumeric and non-whitespace characters). The func... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_whitespace_or_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with either a whitespace character or a special character.
Args:... |
code_exercise_27k | 1,954 | Write a Python function called `count_substring_matches_whitespace_or_special` that takes in a list of strings as input and returns the count of strings in the list that consist entirely of either whitespace characters (space, tab, newline, etc.) or special characters (non-alphanumeric and non-whitespace characters). T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_matches_whitespace_or_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that consist entirely of either whitespace characters or special characters.
... |
code_exercise_27k | 1,955 | Write a Python function called `count_substring_starts_with_lowercase_or_uppercase` that takes in a list of strings as input and returns the count of strings in the list that start with either a lowercase letter (a-z) or an uppercase letter (A-Z). The function should handle an empty list and strings that are empty or d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_lowercase_or_uppercase(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with either a lowercase letter (a-z) or an uppercase letter (A-Z... |
code_exercise_27k | 1,956 | Write a Python function called `count_substring_ends_with_lowercase_or_uppercase` that takes in a list of strings as input and returns the count of strings in the list that end with either a lowercase letter (a-z) or an uppercase letter (A-Z). The function should handle an empty list and strings of varying lengths.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_ends_with_lowercase_or_uppercase(strings: List[str]) -> int:
"""
Counts the number of strings in the list that end with either a lowercase letter (a-z) or an uppercase letter (A-Z).
... |
code_exercise_27k | 1,957 | Write a Python function called `count_substring_contains_lowercase_or_uppercase` that takes in a list of strings as input and returns the count of strings in the list that contain either a lowercase letter (a-z) or an uppercase letter (A-Z). The function should be efficient and handle various edge cases, such as empty ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_lowercase_or_uppercase(strings: List[str]) -> int:
"""
Counts the number of strings in the list that contain either a lowercase letter (a-z) or an uppercase letter (A-Z).
... |
code_exercise_27k | 1,961 | Write a Python function called `count_substring_contains_digit_or_special` that takes in a list of strings as input and returns the count of strings in the list that contain either a digit (0-9) or a special character (non-alphanumeric and non-whitespace characters). The function should be efficient and handle various ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_contains_digit_or_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that contain either a digit (0-9) or a special character (non-alphanumeric and non-w... |
code_exercise_27k | 1,963 | Write a Python function called `count_substring_starts_with_letter_or_special` that takes in a list of strings as input and returns the count of strings in the list that start with either a letter (a-z or A-Z) or a special character (non-alphanumeric and non-whitespace characters). The function should handle an empty l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with_letter_or_special(strings: List[str]) -> int:
"""
Counts the number of strings in the list that start with either a letter (a-z or A-Z) or a special character (non-alphanu... |
code_exercise_27k | 1,971 | Write a Python function to count the number of strings in a list that start with a given substring. The function should be efficient and handle edge cases such as an empty list or an empty substring.
The code should start with:
```python
from typing import List
def count_substring_starts_with(strings: List[str], subs... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_starts_with(strings: List[str], substring: str) -> int:
"""
Counts the number of strings in a list that start with a given substring.
Args:
strings (List[str]): A list of... |
code_exercise_27k | 1,977 | Write a Python function named `find_min_dict` that takes a dictionary of lists as input and returns a dictionary containing the minimum value from each list. If a list is empty, the corresponding key in the output dictionary should have a value of `None`.
The code should start with:
```python
from typing import Dict, ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Union
def find_min_dict(dictionary: Dict[str, List[Union[int, float]]]) -> Dict[str, Union[int, float, None]]:
"""
This function takes a dictionary of lists as input and returns a dictionary conta... |
code_exercise_27k | 2,013 | Write a Python function named `find_max` that takes in a list of numbers as input and returns the maximum value from the list. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_max(numbers: List[int]) -> Optional[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_max(numbers: List[int]) -> Optional[int]:
"""
Find the maximum value in a list of integers.
Args:
numbers (List[int]): A list of integers from which to find the maximum va... |
code_exercise_27k | 2,014 | Write a Python function named `find_max_index` that takes in a list of numbers as input and returns the index of the maximum value in the list. If there are multiple occurrences of the maximum value, return the index of the first occurrence. The function should handle lists of integers and floating-point numbers. The c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_index(numbers: List[float]) -> int:
"""
Find the index of the maximum value in a list of numbers.
Args:
numbers (List[float]): A list of numbers (integers or floating-point numb... |
code_exercise_27k | 2,019 | Write a Python function named `find_max_difference` that takes in a list of numbers as input and returns the maximum difference between any two numbers in the list. The function should be efficient and avoid using nested loops to improve performance.
The code should start with:
```python
from typing import List
def f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_difference(numbers: List[int]) -> int:
"""
Calculate the maximum difference between any two numbers in the given list.
Args:
numbers (List[int]): The list of integers from which... |
code_exercise_27k | 2,020 | Write a Python function named `find_most_frequent_element` that takes in a list of elements as input and returns the element that occurs the most frequently in the list. If there is a tie for the most frequent element, the function should return the first element that reaches the maximum frequency.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
from collections import Counter
def find_most_frequent_element(elements: List[Any]) -> Any:
"""
Find the element that occurs the most frequently in the given list.
Args:
elements (List[... |
code_exercise_27k | 2,023 | Write a Python function named `find_max_consecutive` that takes in a list of integers as input and returns the length of the longest sequence of consecutive numbers in the list. A sequence is defined as a series of numbers where each number is exactly one more than the previous number.
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 find_max_consecutive(numbers: List[int]) -> int:
"""
Find the length of the longest sequence of consecutive numbers in the given list.
Args:
numbers (List[int]): A list of integers.
... |
code_exercise_27k | 2,024 | Write a Python function named `find_max_subarray_sum` that takes in a list of integers as input and returns the maximum sum of any contiguous subarray within the list. The function should efficiently compute the result using the Kadane's algorithm, which has a time complexity of O(n).
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_subarray_sum(nums: List[int]) -> int:
"""
Find the maximum sum of any contiguous subarray within the given list of integers.
Args:
nums (List[int]): The list of integers from wh... |
code_exercise_27k | 2,026 | Write a Python function named `find_max_prime` that takes in a list of integers as input and returns the largest prime number from the list. If no prime number is found, the function should return `None`. The function should include a helper function `is_prime` to determine if a number is prime.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def is_prime(number: int) -> bool:
"""
Check if a given number is prime.
Args:
number (int): The number to check for primality.
Returns:
bool: True if the number is pr... |
code_exercise_27k | 2,027 | Write a Python function named `find_max_length_word` that takes in a string as input and returns the length of the longest word in the string. Assume that the input string only contains alphabetic characters and spaces. If the string is empty, return 0. The function should handle strings with multiple spaces between wo... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_word(string: str) -> int:
"""
Returns the length of the longest word in the given string.
Args:
string (str): The input string containing alphabetic characters and spaces.
Returns:
i... |
code_exercise_27k | 2,028 | Write a Python function named `find_max_common_prefix` that takes in a list of strings as input 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 with a single string.
The code should star... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_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 common prefix fro... |
code_exercise_27k | 2,030 | Write a Python function named `find_max_even` that takes in a list of integers as input and returns the largest even number from the list. If no even number is found, the function should return `None`. The function should handle cases where the input list is empty or contains no even numbers.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_max_even(numbers: List[int]) -> Optional[int]:
"""
Finds the largest even number in a given list of integers.
Args:
numbers (List[int]): A list of integers from which to f... |
code_exercise_27k | 2,032 | Write a Python function named `find_max_sum_even` that takes in a list of integers as input and returns the maximum sum of any two even numbers from the list. If no two even numbers are found, return `None`. The function should be efficient and avoid unnecessary computations.
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, Optional
def find_max_sum_even(numbers: List[int]) -> Optional[int]:
"""
Finds the maximum sum of any two even numbers from the given list.
Args:
numbers (List[int]): The list of integers f... |
code_exercise_27k | 2,034 | Write a Python function named `find_max_length_palindrome` that takes in a string as input and returns the length of the longest palindrome substring within the string. If the string is empty, return 0. The function should efficiently find the longest palindrome substring using a dynamic programming approach or an expa... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_palindrome(string: str) -> int:
"""
Find the length of the longest palindrome substring within the given string.
Args:
string (str): The input string to search for the longest palindrome substrin... |
code_exercise_27k | 2,036 | Write a Python function named `find_max_length_vowel` that takes in a string as input and returns the length of the longest substring that consists only of vowels (a, e, i, o, u). If the string is empty or does not contain any vowels, return 0. The function should be case-insensitive.
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_vowel(string: str) -> int:
"""
Find the length of the longest substring consisting only of vowels in the given string.
Args:
string (str): The input string to search for the longest vowel substri... |
code_exercise_27k | 2,037 | Write a Python function named `find_max_length_digit` that takes in a string as input and returns the length of the longest substring that consists only of digits (0-9). If the string is empty or does not contain any digits, return 0. The function should start with:
```python
def find_max_length_digit(string: str) -> i... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_digit(string: str) -> int:
"""
Find the length of the longest substring consisting only of digits in the given string.
Args:
string (str): The input string to search for the longest digit substri... |
code_exercise_27k | 2,038 | Write a Python function named `find_max_length_alpha` that takes in a string as input and returns the length of the longest substring that consists only of alphabetic characters (a-z or A-Z). If the string is empty or does not contain any alphabetic characters, return 0.
The code should start with:
```python
def find_... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_alpha(string: str) -> int:
"""
Find the length of the longest substring consisting only of alphabetic characters (a-z or A-Z) in the given string.
Args:
string (str): The input string to search f... |
code_exercise_27k | 2,048 | Write a Python function named `find_max_length_custom` that takes in a string and a custom set of characters as input, and returns the length of the longest substring that consists only of characters from the custom set. If the string is empty or does not contain any characters from the custom set, return 0.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_max_length_custom(string: str, custom_set: set) -> int:
"""
Find the length of the longest substring that consists only of characters from the custom set.
Args:
string (str): The input string to search for ... |
code_exercise_27k | 2,054 | Write a Python function named `find_max_length_custom_multiple_ignore_case_special_whitespace_numbers` that takes in a string and multiple custom sets of characters as input, and returns the length of the longest substring that consists only of characters from any of the custom sets, ignoring the case of the characters... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set
def find_max_length_custom_multiple_ignore_case_special_whitespace_numbers(string: str, custom_sets: List[Set[str]]) -> int:
"""
Find the length of the longest substring that consists only of charac... |
code_exercise_27k | 2,089 | Write a Python function to calculate the product of two numbers using a recursive approach. The function should handle both integer and floating-point inputs. The code should start with:
```python
def recursive_multiplication(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def recursive_multiplication(a: int, b: int) -> int:
"""
Calculate the product of two numbers using a recursive approach.
Args:
a (int): The first number.
b (int): The second number.
Returns:
in... |
code_exercise_27k | 2,090 | Write a Python function named `safe_division` that takes two parameters, `a` and `b`, and returns the quotient of dividing `a` by `b`. The function should handle the case where `b` is zero by returning `None`. Additionally, the function should handle cases where `a` or `b` are not numeric types by returning `None`. The... | Here is the Python code to solve the given problem in the markdown block:
```python
def safe_division(a, b):
"""
Safely divides two numbers, handling cases where the divisor is zero or the inputs are not numeric.
Parameters:
a (int or float): The dividend.
b (int or float): The divisor.
Return... |
code_exercise_27k | 2,091 | Write a Python function to calculate the power of a given base raised to an exponent using an iterative approach. The function should handle both positive and negative exponents, as well as zero exponents. The code should start with:
```python
def power_iterative(base: int, exponent: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def power_iterative(base: int, exponent: int) -> int:
"""
Calculate the power of a given base raised to an exponent using an iterative approach.
Args:
base (int): The base number.
exponent (int): The expon... |
code_exercise_27k | 2,092 | Write a Python function to calculate the absolute value of a given number. The function should handle both integers and floating-point numbers. The code should start with:
```python
def absolute_value(num: int | float) -> int | float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def absolute_value(num: int | float) -> int | float:
"""
Calculate the absolute value of a given number.
Args:
num (int | float): The number for which to calculate the absolute value.
Returns:
int | flo... |
code_exercise_27k | 2,094 | Write a Python function named `floor_division` that takes two parameters, `a` and `b`, and returns the largest integer that is less than or equal to the quotient of dividing `a` by `b`. The function should handle both integer and floating-point inputs. The code should start with:
```python
def floor_division(a: float, ... | Here is the Python code to solve the given problem in the markdown block:
```python
def floor_division(a: float, b: float) -> int:
"""
Returns the largest integer that is less than or equal to the quotient of dividing 'a' by 'b'.
Args:
a (float): The dividend.
b (float): The divisor.
R... |
code_exercise_27k | 2,095 | Write a Python function named `ceil_division` that takes two parameters, `a` and `b`, and returns the smallest integer that is greater than or equal to the quotient of dividing `a` by `b`. The function should handle both integer and floating-point inputs. The code should start with:
```python
import math
def ceil_divi... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def ceil_division(a: int, b: int) -> int:
"""
Calculate the smallest integer greater than or equal to the quotient of dividing 'a' by 'b'.
Args:
a (int): The dividend.
b (int): The divisor.
... |
code_exercise_27k | 2,096 | Write a Python function named `find_maximum` that takes two parameters, `a` and `b`, and returns the maximum of the two numbers. The function should handle both integers and floating-point numbers. The code should start with:
```python
def find_maximum(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_maximum(a: int, b: int) -> int:
"""
This function takes two parameters, 'a' and 'b', and returns the maximum of the two numbers.
Parameters:
a (int or float): The first number.
b (int or float): The second ... |
code_exercise_27k | 2,097 | Write a Python function named `find_minimum` that takes two parameters, `a` and `b`, and returns the minimum of the two numbers. The function should handle both integer and floating-point numbers. The code should start with:
```python
def find_minimum(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_minimum(a: int, b: int) -> int:
"""
Returns the minimum of two numbers.
Args:
a (int or float): The first number.
b (int or float): The second number.
Returns:
int or float: The minimum... |
code_exercise_27k | 2,098 | Write a Python function to calculate the average of a list of numbers. The function should handle the case where the list is empty by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_average(numbers: List[float]) -> Optional[float]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List, Optional
def find_average(numbers: List[float]) -> Optional[float]:
"""
Calculate the average of a list of numbers.
Args:
numbers (List[float]): A list of numbers.
Returns:
O... |
code_exercise_27k | 2,100 | Write a Python function to calculate the factorial of a given non-negative integer `n`. The factorial of a non-negative integer `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 should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_factorial(n: int) -> int:
"""
Calculate the factorial of a given non-negative integer n.
The factorial of a non-negative integer n is the product of all positive integers
less than or equal to n. For example, 5... |
code_exercise_27k | 2,101 | Write a Python function to determine if a given number is prime. The function should return `True` if the number is prime and `False` otherwise. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself.
The code should start with:
```python
def is_prime(num: in... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(num: int) -> bool:
"""
Determines if a given number is prime.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Args:
num (int): The number to... |
code_exercise_27k | 2,102 | Write a Python function named `is_even` that takes one parameter, `num`, and returns `True` if the number is even, and `False` otherwise. The function should be able to handle both positive and negative integers. The code should start with:
```python
def is_even(num: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_even(num: int) -> bool:
"""
Determines if a given integer is even.
Args:
num (int): The integer to check for evenness.
Returns:
bool: True if the integer is even, False otherwise.
"""
ret... |
code_exercise_27k | 2,103 | Write a Python function named `is_odd` that takes one parameter, `num`, and returns `True` if the number is odd, and `False` otherwise. The function should handle both positive and negative integers.
The code should start with:
```python
def is_odd(num: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_odd(num: int) -> bool:
"""
Determines if the given number is odd.
Args:
num (int): The number to check for oddness.
Returns:
bool: True if the number is odd, False otherwise.
"""
# Check ... |
code_exercise_27k | 2,104 | Write a Python function to determine if a given word is a palindrome. A palindrome is a word that reads the same forwards and backwards. The function should take a single parameter, `word`, which is a string, and return a boolean value indicating whether the word is a palindrome.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(word: str) -> bool:
"""
Determine if the given word is a palindrome.
A palindrome is a word that reads the same forwards and backwards.
Args:
word (str): The word to check.
Returns:
... |
code_exercise_27k | 2,105 | Write a Python function to calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm. The function should be named `find_gcd` and should take two parameters, `a` and `b`, and return the GCD of the two numbers. The GCD is the largest positive integer that divides both `a` and `b` without ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_gcd(a: int, b: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm.
The Euclidean algorithm is based on the principle that the GCD of two numbers also divides ... |
code_exercise_27k | 2,106 | Write a Python function named `find_lcm` that takes two parameters, `a` and `b`, and returns the least common multiple (LCM) of the two numbers. The LCM is the smallest positive integer that is divisible by both `a` and `b`. The function should use the greatest common divisor (GCD) to compute the LCM. The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_gcd(a: int, b: int) -> int:
"""
Compute the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
Args:
a (int): The first number.
b (int): The second number.
Returns:
... |
code_exercise_27k | 2,108 | Write a Python function named `find_average_of_digits` that takes one parameter, `num`, and returns the average of the digits in the number. If the number is negative, ignore the negative sign. The function should handle edge cases such as zero and single-digit numbers. The code should start with:
```python
def find_av... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_average_of_digits(num: int) -> float:
"""
Calculate the average of the digits in a given number. If the number is negative, the negative sign is ignored.
Args:
num (int): The number whose digits' average is... |
code_exercise_27k | 2,109 | Write a Python function named `find_sum_of_digits` that takes one parameter, `num`, and returns the sum of the digits in the number. If the number is negative, ignore the negative sign. The function should handle both positive and negative integers. The code should start with:
```python
def find_sum_of_digits(num: int)... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_sum_of_digits(num: int) -> int:
"""
Calculate the sum of the digits in the given number. If the number is negative, the negative sign is ignored.
Args:
num (int): The number whose digits' sum is to be calcu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.