source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 75,531 | Write a Python function to validate a numeric input and return a list of all prime divisors of the provided numeric value. If the input is not a positive integer, handle the exception and provide an appropriate error message. Correct the provided erroneous code that attempts to find the divisors of a number but ends up... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise.
"""
if n < 2:
... |
magic_evol_110k | 75,534 | Write a Python function to detect if the balance of a bank account falls below zero at any point given a list of deposit and withdrawal operations. The function should support both integer and floating-point operations, with an optional flag to handle floating-point numbers. If the flag is set to `False` and a floating... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def below_zero(operations: List[Union[int, float]], handle_float: bool = False) -> bool:
"""
Detects if the balance of a bank account falls below zero at any point given a list of operations.
... |
magic_evol_110k | 75,555 | Write a Python function to find the maximum and minimum element in each row of a given 2D array, compute the interval between these elements for each row, and return the total of these intervals. Additionally, identify and return the row with the greatest interval. The function should handle the case where the 2D array... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_intervals(arr: List[List[int]]) -> Tuple[List[int], int, List[int]]:
"""
Finds the maximum and minimum element in each row of a given 2D array, computes the interval between these element... |
magic_evol_110k | 75,557 | Write a Python function to swap the first and second blocks of characters in a given string, where a block is defined as a continuous sequence of the same character type (alpha, digit, special character). If the string does not have at least two different character blocks, return the original string. If the string has ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def swap_blocks(s: str) -> str:
"""
Swaps the first and second blocks of characters in a given string, where a block is defined as a continuous sequence of the same character type (alpha, digit, special character).
... |
magic_evol_110k | 75,570 | Write a Python function to remove all comments from a given C++ code while preserving whitespace and indentation for non-comment lines. Additionally, ensure the program correctly handles edge cases, such as comments inside strings. The function should start with:
```python
def remove_comments(code: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_comments(code: str) -> str:
"""
Removes all comments from a given C++ code while preserving whitespace and indentation for non-comment lines.
Args:
code (str): The C++ code from which comments need to be ... |
magic_evol_110k | 75,582 | Write a Python function to generate a parity check code for a given hexadecimal datum, adhering to both even and odd parity conventions. The function should accept a hexadecimal string and a parity type ('even' or 'odd') as inputs and return the corresponding parity bit.
The code should start with:
```python
def gener... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_parity(hex_datum: str, parity_type: str = 'even') -> int:
"""
Generate a parity check code for a given hexadecimal datum, adhering to either even or odd parity conventions.
Args:
hex_datum (str): The he... |
magic_evol_110k | 75,591 | Write a Python function to search for a specific value within a two-dimensional matrix and return its position (row and column indices) if found. If the value is not found, return a message indicating that the value is not present in the matrix. The matrix is assumed to be a list of lists, where each inner list represe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Union
def search_value_in_matrix(matrix: List[List[int]], target: int) -> Union[Tuple[int, int], str]:
"""
Searches for a specific value within a two-dimensional matrix and returns its position (... |
magic_evol_110k | 75,601 | Write a Python function to generate the first `n` numbers in the Fibonacci sequence and print each number along with its position in the sequence. The function should start with:
```python
def generate_fibonacci_sequence(n: int) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def generate_fibonacci_sequence(n: int) -> None:
"""
Generates the first n numbers in the Fibonacci sequence and prints each number along with its position.
Args:
n (int): The number of Fibonacci numbers to generate... |
magic_evol_110k | 75,609 | Write a Python function to traverse a multi-layered dictionary, including nested arrays, and return the aggregate of all numeric values within. The structure also allows strings containing numerical values. The function should handle dictionaries, lists, strings, and integers. The code should start with:
```python
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
def aggregate_numeric_values(data):
"""
Traverse a multi-layered dictionary, including nested arrays, and return the aggregate of all numeric values within.
The structure also allows strings containing numerical values.
... |
magic_evol_110k | 75,618 | Write a Python function to find the largest possible sum of a contiguous subarray from a given array of integers. The function should efficiently handle arrays with both positive and negative integers. The code should start with:
```python
from typing import List
def max_subarray_sum(arr: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(arr: List[int]) -> int:
"""
Find the largest possible sum of a contiguous subarray from a given array of integers.
Args:
arr (List[int]): The array of integers from whic... |
magic_evol_110k | 75,626 | Write a Python function to calculate the sum of all elements in a nested list, where the list can contain integers and other nested lists. The function should handle any level of nesting. The code should start with:
```python
from typing import Union, List
def sum_nested_list(nested_list: Union[List, int]) -> int:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union, List
def sum_nested_list(nested_list: Union[List, int]) -> int:
"""
Calculate the sum of all elements in a nested list, which can contain integers and other nested lists.
Args:
nested_list... |
magic_evol_110k | 75,641 | Write a Python function to calculate the average of even numbers in a given list of integers. The function should correctly handle syntax errors, logical flaws, and optimize the code to achieve the same algorithmic complexity as the provided correct code. The function should return the average of the even numbers in th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_even_average(numbers: List[int]) -> float:
"""
Calculate the average of even numbers in a given list of integers.
Args:
numbers (List[int]): The list of integers to process.
... |
magic_evol_110k | 75,649 | Write a Python function to generate a list of numbers within a specified range and filter out all even numbers. The function should accept two parameters: the start and end of the range (inclusive). The function should return a list of odd numbers within the specified range.
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 filter_odd_numbers(start: int, end: int) -> List[int]:
"""
Generate a list of odd numbers within a specified range [start, end].
Args:
start (int): The start of the range (inclusive).
... |
magic_evol_110k | 75,664 | Write a Python function to separate and return an array of balanced bracket clusters from an input string. Each cluster is a balanced group of nested brackets, and the function should handle multiple levels of nesting. The input string may contain spaces, which should be ignored. The function should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def separate_bracket_clusters(input_string: str) -> List[str]:
"""
Separates and returns an array of balanced bracket clusters from the input string.
Args:
input_string (str): The input stri... |
magic_evol_110k | 75,669 | Write a Python function to check if all elements of a list of numbers are distinct and find the product of unique elements. Additionally, return the sum of all elements in the list. The function should return a dictionary with three keys: `isDistinct`, `product`, and `sum`.
The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def check_distinct_and_calculate(numbers: List[int]) -> Dict[str, int]:
"""
Check if all elements in the list are distinct and calculate the product of unique elements.
Additionally, return the... |
magic_evol_110k | 75,672 | Write a Python function to transform a given list of numerical values into a unique structured numpy array. The array should be sorted in descending order and contain only odd numbers. The function should also handle error checking for inputs that are not lists or numerical values. The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
from typing import List
def create_unique_np_array(values: List[int]) -> np.ndarray:
"""
Transforms a given list of numerical values into a unique structured numpy array.
The array is sorted in descending... |
magic_evol_110k | 75,676 | Write a Python function to find the first duplicate element in a given list of integers. The function should return the duplicate element if found, otherwise return `None`. The function should be optimized for performance, ensuring that it runs in linear time complexity.
The code should start with:
```python
from typi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_first_duplicate(arr: List[int]) -> Optional[int]:
"""
Find the first duplicate element in a given list of integers.
Args:
arr (List[int]): The list of integers to search f... |
magic_evol_110k | 75,684 | Write a Python function to generate a dictionary where each key is the length of a string, and the corresponding value is a list of all strings from the input list that have that length. The function should handle an empty input list gracefully and ensure that each string length is a unique key in the dictionary.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def group_strings_by_length(stringlist: List[str]) -> Dict[int, List[str]]:
"""
Groups strings by their lengths into a dictionary.
Args:
stringlist (List[str]): A list of strings to be... |
magic_evol_110k | 75,687 | Write a Python function to find the extension with the highest strength for a given class name from a list of extensions. The strength of an extension is calculated as the count of uppercase letters (CAP) minus the count of lowercase letters (SM). If multiple extensions have the same strength, the one that appears earl... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def strongest_extension(class_name: str, extensions: List[str]) -> str:
"""
Finds the extension with the highest strength for a given class name from a list of extensions.
The strength of an extensi... |
magic_evol_110k | 75,688 | Write a Python function to interpret a symbolic representation of numbers stored in a dictionary. The dictionary maps symbols (letters) to lists of numbers. The function should return a new dictionary where each key is a symbol from the input dictionary, and the value is a list of strings. Each string in the list shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def interpret_symbolic_representation(symbol_dict: Dict[str, List[int]]) -> Dict[str, List[str]]:
"""
Interpret the symbolic representation of numbers stored in a dictionary.
Args:
sym... |
magic_evol_110k | 75,692 | Write a Python function to find the largest prime number from a given list of integers and return the sum of its digits. If the list contains no prime numbers, the function should return 0. The function should be efficient and handle edge cases such as an empty list or a list with no prime numbers.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise.
... |
magic_evol_110k | 75,694 | Write a Python function to compute the median value for a given collection of numerical data in the form of an array. The array may contain integers and floating-point numbers, potentially of a large size. The function should handle edge cases such as an array containing an even number of elements and an array containi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_median(array: List[float]) -> float:
"""
Computes the median value for a given collection of numerical data.
Args:
array (List[float]): The array of numerical data.
Returns:... |
magic_evol_110k | 75,695 | Write a Python function to verify if two given alpha-numeric sequences are palindrome anagrams. A palindrome anagram is a sequence that can be rearranged to form a palindrome. The function should ignore non-alphanumeric characters and be case-insensitive.
The code should start with:
```python
def are_palindrome_anagra... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_palindrome_anagrams(s1: str, s2: str) -> bool:
"""
Verifies if two given alpha-numeric sequences are palindrome anagrams.
Args:
s1 (str): The first sequence to check.
s2 (str): The second sequence to... |
magic_evol_110k | 75,708 | Write a Python function to raise each element of a given list to a specified exponent, while handling any potential `TypeError` exceptions that may occur due to non-numeric elements in the list. The function should print a message for each non-numeric element indicating that it is not a number and should not include su... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def raise_power(num_list: List[int], exp: int) -> List[int]:
"""
Raises each element of the given list to the specified exponent, handling non-numeric elements.
Args:
num_list (List[int]): T... |
magic_evol_110k | 75,710 | Write a Python function to compute the transpose of a given 2D array without using any external libraries like NumPy. The function should handle any rectangular 2D array and return the transposed array. The code should start with:
```python
from typing import List
def transpose_2d_array(arr: List[List[int]]) -> List[L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def transpose_2d_array(arr: List[List[int]]) -> List[List[int]]:
"""
Computes the transpose of a given 2D array.
Args:
arr (List[List[int]]): The input 2D array to be transposed.
Return... |
magic_evol_110k | 75,715 | Write a Python function to evaluate a mathematical expression given as a string. The function should support basic arithmetic operations (addition, subtraction, multiplication, division) and parentheses for grouping. The function should handle floating-point numbers and return the result as a float.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
def evaluate_expression(expression: str) -> float:
"""
Evaluates a mathematical expression given as a string and returns the result as a float.
Args:
expression (str): The mathematical expression to evaluate.
R... |
magic_evol_110k | 75,720 | Write a Python function to calculate the frequency of each word in a given piece of text. The function should be case-insensitive, meaning that words like "Word" and "word" should be considered the same. Additionally, the function should handle punctuation by stripping it from the words before counting.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import re
def word_frequency(text: str) -> Dict[str, int]:
"""
Calculate the frequency of each word in a given piece of text.
Args:
text (str): The input text from which to calculate word fr... |
magic_evol_110k | 75,724 | Write a Python function to find the intersection of two given sorted arrays efficiently. The function should return a list of elements that are present in both arrays, without duplicates, and in ascending order. The code should start with:
```python
from typing import List
def find_intersection_of_sorted_arrays(arr1: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection_of_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Finds the intersection of two sorted arrays and returns the result in ascending order.
Args:
arr1 (... |
magic_evol_110k | 75,741 | Write a Python function to convert a hexadecimal number into its binary representation. The function should handle both uppercase and lowercase hexadecimal digits and return the binary string without the '0b' prefix.
The code should start with:
```python
def hex_to_binary(hex_num: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def hex_to_binary(hex_num: str) -> str:
"""
Converts a hexadecimal number into its binary representation.
Args:
hex_num (str): The hexadecimal number to be converted. It can be in uppercase or lowercase.
Return... |
magic_evol_110k | 75,742 | Write a Python function to display the elements of a given multi-dimensional array along with their index positions within their respective sub-arrays. The function should iterate through each sub-array and each element within the sub-array, printing the element and its index position in the format: "Element 'element' ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def display_elements_with_indices(array: List[List[str]]) -> None:
"""
Displays each element of a multi-dimensional array along with its index position within its respective sub-array.
Args:
... |
magic_evol_110k | 75,750 | Write a Python function that processes a list of mixed integers and floating point numbers. The function should generate two separate lists: one containing the squares of all positive integers in the input list, and the other containing the square roots of all non-negative floating point numbers in the input list. The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
def process_numbers(numbers: List[float]) -> Tuple[List[int], List[float]]:
"""
Processes a list of mixed integers and floating point numbers to generate two separate lists.
The fi... |
magic_evol_110k | 75,753 | Write a Python function to determine the number of uniform strings in a given list of words. A string is considered uniform if all its characters are present in a provided `allowed` string. The function should start with:
```python
from typing import List
def count_uniform_strings(allowed: str, words: List[str]) -> in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_uniform_strings(allowed: str, words: List[str]) -> int:
"""
Counts the number of uniform strings in a given list of words.
A string is considered uniform if all its characters are present ... |
magic_evol_110k | 75,763 | Write a Python function to generate a beautiful array for a given integer `N` and a function to verify if a given array is a beautiful array. A beautiful array is defined as a permutation of the integers `1, 2, ..., N` such that for every `i < j`, there is no `k` with `i < k < j` such that `A[k] * 2 = A[i] + A[j]`.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_beautiful_array(N: int) -> List[int]:
"""
Generate a beautiful array for a given integer N.
Args:
N (int): The integer N for which to generate the beautiful array.
Returns:... |
magic_evol_110k | 75,766 | Write a Python function to calculate the cumulative product of all odd numbers in a given range [1, n]. The function should take an integer `n` as input and return the cumulative product of all odd numbers from 1 to `n`.
The code should start with:
```python
def cumulative_product_of_odds(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def cumulative_product_of_odds(n: int) -> int:
"""
Calculate the cumulative product of all odd numbers in the range [1, n].
Args:
n (int): The upper limit of the range (inclusive).
Returns:
int: The cum... |
magic_evol_110k | 75,774 | Write a Python function that checks whether the product of numbers in a list is even or not, and identifies the index of the first odd number in the list. If there are no odd numbers, the function should return `-1` for the index. The function should handle large lists efficiently by avoiding unnecessary multiplication... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def check_product_and_first_odd(numbers: List[float]) -> Tuple[bool, int]:
"""
Checks whether the product of numbers in a list is even or not, and identifies the index of the first odd number.
... |
magic_evol_110k | 75,789 | Write a Python function to safely copy a string from one variable to another using a custom implementation of `strcpy` that avoids segmentation faults. The function should handle the case where the destination string is not properly allocated. The code should start with:
```python
def safe_strcpy(src: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def safe_strcpy(src: str) -> str:
"""
Safely copies a string from the source to a new string.
Args:
src (str): The source string to be copied.
Returns:
str: A new string that is a copy of the source str... |
magic_evol_110k | 75,794 | Write a Python function to iterate over each item in a given dictionary and return a list of tuples where each tuple contains a key-value pair from the dictionary. The function should handle dictionaries with any number of key-value pairs and any type of keys and values.
The code should start with:
```python
from typi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple, Any
def dict_to_list_of_tuples(d: Dict[Any, Any]) -> List[Tuple[Any, Any]]:
"""
Converts a dictionary to a list of tuples where each tuple contains a key-value pair from the dictionary.
... |
magic_evol_110k | 75,803 | Write a Python function to perform a series of string manipulations on a given input string. The function should:
1. Remove any leading and trailing whitespace from the string.
2. Convert the string to lowercase.
3. Replace all occurrences of the word "world" with "universe".
4. Split the string into a list of words.
5... | Here is the Python code to solve the given problem in the markdown block:
```python
def manipulate_string(input_str: str) -> str:
"""
Perform a series of string manipulations on the given input string.
Args:
input_str (str): The input string to be manipulated.
Returns:
str: The final m... |
magic_evol_110k | 75,808 | Write a Python function to transform a list of dictionaries, where each dictionary contains `id` and `name` properties, into a dictionary where the keys are the `id` values and the values are the corresponding `name` values. The function should handle cases where the input list is empty or contains duplicate `id` value... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def transform_data(data: List[Dict[int, str]]) -> Dict[int, str]:
"""
Transforms a list of dictionaries, where each dictionary contains 'id' and 'name' properties,
into a dictionary where the k... |
magic_evol_110k | 75,826 | Write a Python function to find the maximum value in a given list of integers without using Python's built-in `max` function. The function should iterate through the list and keep track of the maximum value encountered so far. The function should handle edge cases such as an empty list by returning `None`.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_max_value(lst: List[int]) -> Optional[int]:
"""
Find the maximum value in a given list of integers without using Python's built-in `max` function.
Args:
lst (List[int]): T... |
magic_evol_110k | 75,827 | Write a Python function to remove all duplicate elements from a given array while maintaining the order of the original array as much as possible. The solution should not use additional data structures like sets or hash maps, and it should minimize time and space complexity. The function should start with:
```python
fr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_in_order(arr: List[int]) -> List[int]:
"""
Removes duplicate elements from the given array while maintaining the order of the original array.
Args:
arr (List[int]): The... |
magic_evol_110k | 75,834 | Write a Python function to find the length of the shortest subarray that needs to be removed from a given integer array `arr` such that the remaining elements in `arr` are non-decreasing and the sum of the remaining elements is maximum.
The function should start with:
```python
from typing import List
def find_shorte... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_shortest_subarray_to_remove(arr: List[int]) -> int:
"""
Find the length of the shortest subarray that needs to be removed from the given array
such that the remaining elements are non-decrea... |
magic_evol_110k | 75,857 | Write a Python function to count the number of distinct alphabets in a given string and find the frequency of each alphabet present in the string. The function should be case-insensitive and should ignore any special characters or numbers. The output should be a tuple where the first element is the number of distinct a... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_alphabets(string: str) -> tuple:
"""
Counts the number of distinct alphabets in a given string and finds the frequency of each alphabet.
Args:
string (str): The input string to analyze.
Returns:
... |
magic_evol_110k | 75,862 | Write a Python function that demonstrates the differences between a `while` loop and a `for` loop in Python, including their syntax and use cases. The function should also show how to implement nested loops and `break`/`continue` statements within them. The function should take an integer `n` as input and print the seq... | Here is the Python code to solve the given problem in the markdown block:
```python
def demonstrate_loops(n: int):
"""
Demonstrates the differences between a while loop and a for loop in Python,
including their syntax and use cases. Additionally, shows how to implement
nested loops and break/continue st... |
magic_evol_110k | 75,871 | Write a Python function to perform element-wise addition of two lists and return the result as a new list. The function should handle lists of different lengths by padding the shorter list with zeros. The code should start with:
```python
from typing import List
def element_wise_addition(list_a: List[int], list_b: Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_addition(list_a: List[int], list_b: List[int]) -> List[int]:
"""
Perform element-wise addition of two lists and return the result as a new list.
If the lists are of different lengths... |
magic_evol_110k | 75,891 | Write a Python function to sort a given list of numerical values in ascending order. The function should return the sorted list. The code should start with:
```python
from typing import List
def sort_numbers(numbers: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_numbers(numbers: List[int]) -> List[int]:
"""
Sorts a given list of numerical values in ascending order.
Args:
numbers (List[int]): The list of numerical values to be sorted.
R... |
magic_evol_110k | 75,911 | Write a Python function to clean a given string by removing all whitespace characters and non-alphanumeric characters (such as punctuation marks and symbols). The function should return the cleaned string. The code should start with:
```python
import re
def clean_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def clean_string(input_string: str) -> str:
"""
Cleans the input string by removing all whitespace characters and non-alphanumeric characters.
Args:
input_string (str): The string to be cleaned.
Retu... |
magic_evol_110k | 75,919 | Write a Python function to sort a given list of strings in alphabetical order. The function should handle lists of varying lengths and should return the sorted list. The code should start with:
```python
from typing import List
def sort_strings_alphabetically(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 sort_strings_alphabetically(strings: List[str]) -> List[str]:
"""
Sorts a given list of strings in alphabetical order.
Args:
strings (List[str]): The list of strings to be sorted.
R... |
magic_evol_110k | 75,925 | Write a Python function to filter and print the numbers from a given list that fall within a user-provided range. The user should input two numbers, which will serve as the lower and upper bounds for the filtering process. The function should then iterate over the list of numbers and print only those numbers that fall ... | Here is the Python code to solve the given problem in the markdown block:
```python
def filter_numbers_in_range(numlist: str, lower: int, upper: int) -> None:
"""
Filters and prints the numbers from a given list that fall within a specified range.
Args:
numlist (str): A space-separated string of nu... |
magic_evol_110k | 75,930 | Write a Python function to sort a given array of numerical entities in descending order. The function should return the sorted array. The code should start with:
```python
from typing import List
def sort_array_descending(arr: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_array_descending(arr: List[int]) -> List[int]:
"""
Sorts the given array of numerical entities in descending order.
Args:
arr (List[int]): The array of numerical entities to be sort... |
magic_evol_110k | 75,938 | Write a Python function to determine if a given number is an Armstrong number. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits. The function should handle possible exceptions and edge cases.
The code should start with:
```python
def is_armstro... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_armstrong(n: int) -> bool:
"""
Determines if a given number is an Armstrong number.
An Armstrong number is a number that is equal to the sum of its own digits
each raised to the power of the number of digits.
... |
magic_evol_110k | 75,961 | Create a Python function to find the longest common subsequence (LCS) of two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) of two given strings.
Args:
str1 (str): The first string.
str2 (str): The second ... |
magic_evol_110k | 75,990 | Write a Python function to count the number of vowels in each word of a given list of words and return a list of these counts. The function should be efficient and handle any list of words, including those with non-alphabetic characters.
The code should start with:
```python
from typing import List
def count_vowels_i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_vowels_in_words(word_list: List[str]) -> List[int]:
"""
Counts the number of vowels in each word of a given list of words.
Args:
word_list (List[str]): A list of words for which to... |
magic_evol_110k | 75,991 | Write a Python function to merge two distinct lists into a single list. The function should handle lists of different lengths and ensure that all elements from both lists are included in the merged list. The code should start with:
```python
from typing import List
def merge_lists(list_a: List, list_b: List) -> List:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_lists(list_a: List, list_b: List) -> List:
"""
Merges two distinct lists into a single list.
Args:
list_a (List): The first list to be merged.
list_b (List): The second lis... |
magic_evol_110k | 75,993 | Write a Python function to determine whether there is a path between two nodes in an undirected graph such that each edge on the path has a distance strictly less than a given limit and the total weight of the nodes on the path is less than a given weight. The graph is defined by an edge list, where each edge has a dis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import heapq
def check_existence_of_edge_length_limited_paths(n: int, edgeList: List[List[int]], nodeWeights: List[int], queries: List[List[int]]) -> List[bool]:
"""
Determine whether there is a path bet... |
magic_evol_110k | 75,994 | Write a Python function to generate a list of all numbers from 0 to a given upper limit `n` that are divisible by both 3 and 5. The function should be efficient and use list comprehension for the implementation.
The code should start with:
```python
from typing import List
def generate_divisible_numbers(n: int) -> Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_divisible_numbers(n: int) -> List[int]:
"""
Generate a list of all numbers from 0 to n that are divisible by both 3 and 5.
Args:
n (int): The upper limit (inclusive) for the ran... |
magic_evol_110k | 76,005 | Write a Python function to validate if a given non-empty string can be parsed to a positive integer less than or equal to 100, convert it to an integer, and then print the next 20 prime numbers starting from that integer. The function should be multi-threaded to ensure efficient computation. Implement your own function... | Here is the Python code to solve the given problem in the markdown block:
```python
import threading
def is_prime(num: int) -> bool:
"""
Check if a given number is prime.
Args:
num (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise.
... |
magic_evol_110k | 76,012 | Write a Python function to display all odd numbers within a specified range. The function should take two integers, `start` and `end`, as input and print all odd numbers between `start` (inclusive) and `end` (inclusive). If `start` is greater than `end`, the function should print an error message and return immediately... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_odd_numbers(start: int, end: int) -> None:
"""
Prints all odd numbers between the given start and end values (inclusive).
Args:
start (int): The starting value of the range (inclusive).
end (int): ... |
magic_evol_110k | 76,015 | Write a Python function to find the smallest positive number in a given array of integers. The function should operate in O(n log n) time complexity. The array may contain both negative and positive numbers. If no positive number is found, the function should return `None`.
The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_smallest_positive(nums: List[int]) -> Optional[int]:
"""
Find the smallest positive number in a given array of integers.
Args:
nums (List[int]): The array of integers to s... |
magic_evol_110k | 76,018 | Write a Python function to calculate the sum of each row in a given two-dimensional array and return the maximum element among these sums. The function should handle any rectangular two-dimensional array of integers.
The code should start with:
```python
from typing import List
def max_sum_of_rows(arr: List[List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_sum_of_rows(arr: List[List[int]]) -> int:
"""
Calculate the sum of each row in a given two-dimensional array and return the maximum sum.
Args:
arr (List[List[int]]): A two-dimensiona... |
magic_evol_110k | 76,020 | Write a Python function to find the longest unique increasing subsequence in a given list of integers. The subsequence should not contain any duplicates and must maintain the original order in the array. The function should return the subsequence as a list.
The code should start with:
```python
from typing import List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def longest_unique_increasing_subsequence(array: List[int]) -> List[int]:
"""
Find the longest unique increasing subsequence in a given list of integers.
Args:
array (List[int]): The list of... |
magic_evol_110k | 76,038 | Write a Python function to determine the sum of the three real numbers that are excluded from the domain of the function \( f(x) = \frac{1}{1+\frac{1}{1+\frac{1}{x}}} \). The function should identify the excluded numbers, explain why they are not included in the function's domain, and return their sum.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_excluded_numbers(f) -> (int, str):
"""
Determine the sum of the three real numbers that are excluded from the domain of the function f(x) = 1/(1+1/(1+1/x)).
Args:
f (function): The function f(x) = 1/(1+1/... |
magic_evol_110k | 76,044 | Write a Python function to find the longest palindromic subsequence in a given string. The function should return the length of the longest palindromic subsequence.
The code should start with:
```python
def longest_palindromic_subseq(s: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_palindromic_subseq(s: str) -> int:
"""
Calculate the length of the longest palindromic subsequence in a given string.
Args:
s (str): The input string.
Returns:
int: The length of the longest... |
magic_evol_110k | 76,066 | Write a Python function to perform a binary search on a sequence that is not strictly ascending but is generally increasing (i.e., it can have equal values next to each other). The function should find the first occurrence of a target value in the sequence.
The code should start with:
```python
from typing import List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_first_occurrence(sequence: List[int], target: int) -> int:
"""
Find the first occurrence of a target value in a sequence that is generally increasing but not strictly ascending.
Args:
... |
magic_evol_110k | 76,094 | Create a Python function that takes a list of dictionaries representing web development frameworks and returns a dictionary where the keys are the programming languages and the values are lists of framework names that use that language. The function should handle cases where the input list is empty or contains dictiona... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def group_frameworks_by_language(frameworks: List[Dict[str, Any]]) -> Dict[str, List[str]]:
"""
Groups web development frameworks by their programming languages.
Args:
frameworks ... |
magic_evol_110k | 76,110 | Write a Python function to sort a list of strings using the bubble sort algorithm. The function should ensure that the comparison between strings is case-insensitive, meaning that 'Apple' and 'apple' should be considered equal. The function should also handle lists with duplicate strings and empty lists.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def bubble_sort_case_insensitive(lst: List[str]) -> List[str]:
"""
Sorts a list of strings using the bubble sort algorithm with case-insensitive comparison.
Args:
lst (List[str]): The list o... |
magic_evol_110k | 76,117 | Write a Python function to rotate a 3D cube represented as a series of 2D matrices by 90 degrees around its central axis. The rotation should be performed layer by layer, starting from the outermost layer inward. The function should not use any in-built functions or libraries for matrix manipulation or rotation.
The c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rotate_3d_cube(cube: List[List[List[int]]]) -> List[List[List[int]]]:
"""
Rotates a 3D cube represented as a series of 2D matrices by 90 degrees around its central axis.
Args:
cube (List... |
magic_evol_110k | 76,126 | Write a Python function to find all valid email addresses in a given text that comply with RFC 5322 standards. The function should return a list of valid email addresses found in the text.
The code should start with:
```python
import re
from typing import List
def find_valid_emails(text: str) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import List
def find_valid_emails(text: str) -> List[str]:
"""
Finds all valid email addresses in the given text that comply with RFC 5322 standards.
Args:
text (str): The text in which to sea... |
magic_evol_110k | 76,129 | Write a Python function to extract Unicode code points from a given string and return them as a list of integers. The function should handle any string input, including empty strings and strings with special characters. The code should start with:
```python
from typing import List
def extract_unicode_code_points(input... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_unicode_code_points(input_string: str) -> List[int]:
"""
Extracts Unicode code points from a given string and returns them as a list of integers.
Args:
input_string (str): The st... |
magic_evol_110k | 76,134 | Write a Python function to calculate the number of days a given amount of dog food will last, given the daily consumption rate of the dog. The function should take the weight of the dog food in pounds and the daily consumption rate in ounces as inputs, and return the number of days the food will last. Assume that 1 pou... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_days_of_food(weight_pounds: float, daily_consumption_ounces: float) -> int:
"""
Calculate the number of days a given amount of dog food will last, given the daily consumption rate of the dog.
Args:
wei... |
magic_evol_110k | 76,136 | Write a Python function to calculate the transpose of a multi-dimensional array without using any in-built transpose functions. The function should be able to handle arrays of any dimensionality. The code should start with:
```python
import numpy as np
def custom_transpose(arr: np.ndarray) -> np.ndarray:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def custom_transpose(arr: np.ndarray) -> np.ndarray:
"""
Calculate the transpose of a multi-dimensional array without using in-built transpose functions.
Args:
arr (np.ndarray): The input multi-d... |
magic_evol_110k | 76,138 | Write a Python function to remove redundant repeated elements from a given two-dimensional list (nested lists) while preserving the original order of the unique elements in each sub-list. The function should handle edge cases such as an empty list or a list of empty lists. 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
from collections import OrderedDict
def remove_redundant_elements(lst: List[List[int]]) -> List[List[int]]:
"""
Removes redundant repeated elements from a given two-dimensional list while preserving the ... |
magic_evol_110k | 76,149 | Write a Python function to create and update a dictionary with a key "location" that stores a tuple containing coordinates in the form of latitude and longitude. The function should allow updating the coordinates and returning the updated dictionary.
The code should start with:
```python
def update_location(loc_dict: ... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_location(loc_dict: dict, new_coords: tuple) -> dict:
"""
Updates the 'location' key in the given dictionary with new coordinates and returns the updated dictionary.
Args:
loc_dict (dict): The dictionary c... |
magic_evol_110k | 76,154 | Write a Python function to sort a dictionary by its keys and then sort each individual value (which is a list of strings) alphabetically. The dictionary contains integer keys with corresponding values as a list of strings. The function should return the sorted dictionary.
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 Dict, List
def sort_dictionary_by_keys_and_values(dictionary: Dict[int, List[str]]) -> Dict[int, List[str]]:
"""
Sorts a dictionary by its keys and then sorts each individual value (a list of strings) alphabe... |
magic_evol_110k | 76,163 | Write a Python function to filter out non-prime numbers from a given list and return a new list containing only the prime numbers. The function should efficiently determine if a number is prime by checking divisibility up to the square root of the number.
The code should start with:
```python
from typing import List
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_primes(nums: List[int]) -> List[int]:
"""
Filters out non-prime numbers from the given list and returns a new list containing only the prime numbers.
Args:
nums (List[int]): The l... |
magic_evol_110k | 76,166 | Write a Python function to convert each element in a given numerical string array into integers and then calculate their running total. The function should return a list of integers representing the running total of the converted integers.
The code should start with:
```python
from typing import List
def calculate_ru... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_running_total(lst: List[str]) -> List[int]:
"""
Converts each element in a given numerical string array into integers and calculates their running total.
Args:
lst (List[str]):... |
magic_evol_110k | 76,175 | Write a Python function to generate a list of prime numbers that are less than a given positive integer `n`. The function should efficiently determine whether each number less than `n` is prime and return a list of all such prime numbers.
The code should start with:
```python
from typing import List
def prime_less_th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def prime_less_than(n: int) -> List[int]:
"""
Generate a list of prime numbers that are less than the given positive integer n.
Args:
n (int): The positive integer up to which prime numbers ... |
magic_evol_110k | 76,178 | Write a Python function to sort a list of non-negative integers in ascending order using the Counting Sort algorithm. The function should not use any pre-existing sorting techniques and should sort the list in O(n) time complexity. The code should start with:
```python
from typing import List
def counting_sort(arr: Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def counting_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of non-negative integers in ascending order using the Counting Sort algorithm.
Args:
arr (List[int]): The list of non-negativ... |
magic_evol_110k | 76,182 | Write a Python function to count the number of squarefree numbers below a given positive integer `N`. A number is considered squarefree if it is not divisible by the square of any prime number. The function should efficiently determine this count for large values of `N`.
The code should start with:
```python
def count... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_squarefree_numbers(N: int) -> int:
"""
Count the number of squarefree numbers below a given positive integer N.
A number is squarefree if it is not divisible by the square of any prime number.
Args:
N... |
magic_evol_110k | 76,184 | Write a Python function to count the number of elements in a given list of integers that are greater than zero. The function should handle an empty list and return 0 in that case. The code should start with:
```python
from typing import List
def count_positive_numbers(nums: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def count_positive_numbers(nums: List[int]) -> int:
"""
Counts the number of elements in the given list that are greater than zero.
Args:
nums (List[int]): The list of integers to be evalu... |
magic_evol_110k | 76,189 | Write a Python function to format and display the contents of a given dictionary in a specific way. The function should take a dictionary as input and return a formatted string that lists each key-value pair on a new line, followed by the entire dictionary in its original form. The format for each key-value pair should... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def format_dictionary(dictionary: Dict) -> str:
"""
Formats the contents of a dictionary into a specific string format.
Args:
dictionary (Dict): The dictionary to be formatted.
Returns:... |
magic_evol_110k | 76,192 | Write a Python function to calculate the greatest common divisor (GCD) of two given integers using the Euclidean algorithm. The function should handle both positive and negative integers, and should return the absolute value of the GCD.
The code should start with:
```python
def gcd(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def gcd(a: int, b: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm.
Args:
a (int): The first integer.
b (int): The second integer.
Returns:
... |
magic_evol_110k | 76,194 | Write a Python function that sorts a collection of both integers and decimals using a binary search tree (BST) methodology. The sorted list should follow a unique sequence pattern: starting with the smallest value, followed by the largest of the remainder, then the minimal value not yet indexed, and so forth. The funct... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def unique_BST_sort(lst: List[float]) -> List[float]:
"""
Given a mixed list of integers and decimals, return the list sorted in a specific order using a binary search tree (BST) methodology.
The sor... |
magic_evol_110k | 76,199 | Write a Python function to generate the next lexicographical permutation of a given sequence. The function should return the next permutation if it exists, otherwise, it should return a message indicating that the sequence is already sorted in non-ascending order.
The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def next_lexicographical_permutation(sequence: List[int]) -> Union[List[int], str]:
"""
Generate the next lexicographical permutation of the given sequence.
Args:
sequence (List[int])... |
magic_evol_110k | 76,202 | Write a Python function to transfigure each character in a given string by substituting it with the succeeding character in the alphabet. If the character is a letter, it should be replaced by the next letter in the alphabet (with 'z' or 'Z' wrapping around to 'a' or 'A', respectively). Non-alphabetic characters should... | Here is the Python code to solve the given problem in the markdown block:
```python
def transfigure_string(text: str) -> str:
"""
Transfigures each character in the given string by substituting it with the succeeding character in the alphabet.
Non-alphabetic characters remain unchanged.
Args:
t... |
magic_evol_110k | 76,209 | Write a Python function to generate the first `n` prime numbers using the Sieve of Eratosthenes method. The function should return a list of the first `n` prime numbers. The code should start with:
```python
from typing import List
def generate_n_primes(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def generate_n_primes(n: int) -> List[int]:
"""
Generate the first n prime numbers using the Sieve of Eratosthenes method.
Args:
n (int): The number of prime numbers to generate.... |
magic_evol_110k | 76,211 | Write two Python functions to solve the following problems:
1. **find_smallest_index**: This function should return the index of the smallest number in a given list of floats.
2. **find_nearest_to_smallest**: This function should return the index of the number in the list that is nearest to the smallest number. If ther... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_smallest_index(lst: List[float]) -> int:
"""
Returns the index of the smallest number in the given list.
Args:
lst (List[float]): The list of floats from which to find the smallest ... |
magic_evol_110k | 76,213 | Write a Python function to convert an HTML string from uppercase to lowercase. The function should take an HTML string as input and return a new string where all the characters are in lowercase. The function should handle any HTML tags and content within the tags.
The code should start with:
```python
def convert_html... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_html_to_lowercase(html_code_in_uppercase: str) -> str:
"""
Converts an HTML string from uppercase to lowercase.
Args:
html_code_in_uppercase (str): The HTML string in uppercase.
Returns:
str... |
magic_evol_110k | 76,219 | Write a Python function to calculate the minimum number of mutually exclusive time periods required to encapsulate the complete span of a given array of time periods. Each time period is represented as a list of two integers, where the first integer is the start time and the second integer is the end time. The function... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def min_periods(intervals: List[List[int]]) -> int:
"""
Calculate the minimum number of mutually exclusive time periods required to encapsulate the complete span of a given array of time periods.
Ar... |
magic_evol_110k | 76,227 | Write a Python function to safely and efficiently erase a key-value pair from a dictionary, including handling nested dictionaries. The function should ensure that the key is removed from both the top-level dictionary and any nested dictionaries. The function should also handle cases where the key does not exist in the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, Dict
def remove_key_from_dict(d: Dict[Any, Any], key: Any) -> Dict[Any, Any]:
"""
Safely removes a key-value pair from the dictionary, including any nested dictionaries.
Args:
d (Dict[Any, A... |
magic_evol_110k | 76,228 | Write a Python function to merge a list of distinct words into a single string, where each word is separated by a comma and a space. The function should handle lists of varying lengths, including empty lists. The code should start with:
```python
from typing import List
def merge_words(words: List[str]) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_words(words: List[str]) -> str:
"""
Merges a list of distinct words into a single string, with each word separated by a comma and a space.
Args:
words (List[str]): A list of distin... |
magic_evol_110k | 76,229 | Write a Python function to convert a list of pressure readings from Pascal to Bar. The function should take a list of integers representing pressure readings in Pascal and return a list of corresponding pressure readings in Bar. The conversion factor from Pascal to Bar is 1 Pascal = 0.00001 Bar.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def convert_pressure_list_to_bar(pressures_in_pascal: List[int]) -> List[float]:
"""
Converts a list of pressure readings from Pascal to Bar.
Args:
pressures_in_pascal (List[int]): A list of... |
magic_evol_110k | 76,233 | Write a Python function to evaluate and determine which of the given mathematical expressions accurately reflects the value of the multiplication of 4 times 9. The function should take a list of expressions as input and return the index of the correct expression. If multiple expressions are correct, return the index of... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_correct_expression(expressions: List[str]) -> int:
"""
Evaluate and determine which of the given mathematical expressions accurately reflects the value of the multiplication of 4 times 9.
A... |
magic_evol_110k | 76,242 | Write a Python function named `merge_and_sort_lists` that takes three arguments: two lists of numbers (which can be integers or floats) and a boolean indicating the sorting order (True for ascending, False for descending). The function should merge these two lists into a single list, remove any duplicates, and sort the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def merge_and_sort_lists(list1: List[Union[int, float]], list2: List[Union[int, float]], ascending: bool = True) -> List[Union[int, float]]:
"""
Merges two lists of numbers, removes duplicates, an... |
magic_evol_110k | 76,244 | Write a Python function to identify and return a list of numbers from a given array of integers that are both prime and greater than 20. The function should use a helper function to check if a number is prime.
The code should start with:
```python
from typing import List
def find_primes_greater_than_20(numbers: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(num: int) -> bool:
"""
Check if a number is prime.
Args:
num (int): The number to check.
Returns:
bool: True if the number is prime, False otherwise.
"""
if... |
magic_evol_110k | 76,249 | Write a Python function to sort a given list of names alphabetically in ascending order. The function should handle lists of varying lengths and should return the sorted list. The code should start with:
```python
from typing import List
def sort_names(names: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_names(names: List[str]) -> List[str]:
"""
Sorts a given list of names alphabetically in ascending order.
Args:
names (List[str]): The list of names to be sorted.
Returns:
... |
magic_evol_110k | 76,273 | Write a Python function that takes an array of integers and a number, adds the number to each element of the array, and then sorts the resulting array in descending order. The function should handle edge cases such as an empty array or a number that is zero. The code should start with:
```python
from typing import List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def add_and_sort_array(arr: List[int], num: int) -> List[int]:
"""
Adds a given number to each element of an array and then sorts the resulting array in descending order.
Args:
arr (List[int... |
magic_evol_110k | 76,276 | Write a Python function that takes either two complex numbers or a list of complex numbers as input. The function should first verify if the inputs are indeed complex numbers. If a list is provided, it should contain at least two elements. The function should then calculate the absolute difference between each consecut... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_absolute_difference(cnum1: complex, cnum2: complex) -> float:
"""
Calculate the absolute difference between two complex numbers.
Args:
cnum1 (complex): The first complex... |
magic_evol_110k | 76,277 | Write a Python function to round a given floating-point number to the nearest hundredth. The function should take a single floating-point number as input and return the rounded value as a floating-point number.
The code should start with:
```python
def round_to_nearest_hundredth(number: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def round_to_nearest_hundredth(number: float) -> float:
"""
Rounds a given floating-point number to the nearest hundredth.
Args:
number (float): The floating-point number to be rounded.
Returns:
float: ... |
magic_evol_110k | 76,283 | Write a Python function to convert a given string of alphanumeric characters into its corresponding hexadecimal representation. Each character in the string should be converted to its hexadecimal equivalent based on its ASCII value. The function should handle both numeric and alphabetic characters.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
def to_hexadecimal(s: str) -> str:
"""
Converts a given string of alphanumeric characters into its corresponding hexadecimal representation.
Args:
s (str): The input string to be converted.
Returns:
str... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.