source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_evol_110k
66,113
Implement a Python function to sort a list of floating-point numbers using the bucket sort algorithm. Additionally, incorporate insertion sort within the bucket sort to sort the elements within each bucket. The function should handle lists of floating-point numbers ranging from 0 to 1. 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 insertion_sort(bucket: List[float]) -> List[float]: """ Sorts a list of floating-point numbers using the insertion sort algorithm. Args: bucket (List[float]): The list of floating-point ...
magic_evol_110k
66,115
Write a Python function to calculate the greatest common divisor (GCD) of a list of non-negative integers. The function should handle edge cases such as lists containing zeros and lists with fewer than two elements. The function should efficiently compute the GCD for any number of integers. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def highest_common_factor(numbers: List[int]) -> int: """ Calculate the greatest common divisor (GCD) of a list of non-negative integers. Args: numbers (List[int]): A list of non...
magic_evol_110k
66,116
Write a Python function to convert punctuation marks (., ,, ?, !) in a given text into corresponding text phrases while ensuring that contractions and possessive forms are not mistakenly converted. The function should also handle situations where the same punctuation mark has different meanings based on the context in ...
Here is the Python code to solve the given problem in the markdown block: ```python import re def convert_punctuations(text: str) -> str: """ Converts punctuation marks (., ,, ?, !) in the given text into corresponding text phrases while ensuring that contractions and possessive forms are not mistakenly co...
magic_evol_110k
66,122
Write a Python function to evaluate a postfix expression. The postfix expression is given as a list of tokens, where each token is either an integer or an operator (`+`, `-`, `*`, `/`). The function should return the result of the evaluated postfix expression. 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 evaluate_postfix_expression(tokens: List[str]) -> int: """ Evaluates a postfix expression given as a list of tokens. Args: tokens (List[str]): A list of tokens representing the postfix e...
magic_evol_110k
66,155
Write a Python function to intertwine two distinct strings by alternating their characters. If the strings are of different lengths, append the remaining characters of the longer string to the result. The function should start with: ```python def intertwine_strings(str1: str, str2: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def intertwine_strings(str1: str, str2: str) -> str: """ Intertwines two strings by alternating their characters. If the strings are of different lengths, appends the remaining characters of the longer string to the result. ...
magic_evol_110k
66,160
Write a Python function to find all words of a given length from an iterable. The function should validate that all elements of the iterable are strings before processing. If a non-string element is found, the function should inform the user of the index of the first non-string element and continue processing the remai...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Iterable, List, Any def find_words_of_length(iterable: Iterable[Any], length: int) -> List[str]: """ Find all words of a given length from an iterable. Args: iterable (Iterable[Any]): An iterable...
magic_evol_110k
66,186
Write a Python function to implement the FizzBuzz game for numbers from 1 to n. The function should replace numbers divisible by 3 with the word "Fizz", numbers divisible by 5 with the word "Buzz", and numbers divisible by both 3 and 5 with the word "FizzBuzz". The function should only print one result for each number ...
Here is the Python code to solve the given problem in the markdown block: ```python def fizz_buzz(n: int) -> None: """ Implements the FizzBuzz game for numbers from 1 to n. For each number in the range: - If the number is divisible by both 3 and 5, print "FizzBuzz". - If the number is divisible by ...
magic_evol_110k
66,195
Write a Python function to check if a given string is a palindrome, considering case insensitivity and ignoring non-alphabetical characters, including spaces and punctuation marks. The function should return `True` if the string is a palindrome and `False` otherwise. The code should start with: ```python def is_palindr...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Check if the given string is a palindrome, considering case insensitivity and ignoring non-alphabetical characters. Args: s (str): The input string to check. Returns: ...
magic_evol_110k
66,209
Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should be case-insensitive and should handle both lowercase and upperc...
Here is the Python code to solve the given problem in the markdown block: ```python def are_anagrams(string1: str, string2: str) -> bool: """ Determines if two given strings are anagrams of each other. Args: string1 (str): The first string to compare. string2 (str): The second string to com...
magic_evol_110k
66,212
Write a Python function to reshape a 2D NumPy array into a 3D array with an additional dimension of size 1. The function should ensure that the input array is 2D and handle the reshaping process correctly. The code should start with: ```python import numpy as np def reshape_to_3d(array: np.ndarray) -> np.ndarray: ```
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def reshape_to_3d(array: np.ndarray) -> np.ndarray: """ Reshape a 2D NumPy array into a 3D array with an additional dimension of size 1. Args: array (np.ndarray): A 2D NumPy array to be reshaped....
magic_evol_110k
66,218
Write a Python function to convert a collection of grayscale images into a four-dimensional tensor suitable for use in a Capsule Network. Each image in the collection is of size 24x24 pixels. The function should handle the reshaping of the images into the required tensor format. The code should start with: ```python i...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def convert_to_4d_tensor(images: List[np.ndarray]) -> np.ndarray: """ Converts a collection of grayscale images into a four-dimensional tensor suitable for a Capsule Network. Args...
magic_evol_110k
66,226
Write a Python function to extract the first quartet (four consecutive numerical values) from a given numerical string using regular expressions. The function should return the extracted quartet as a string. If no quartet is found, the function should return an empty string. The code should start with: ```python impor...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_first_quartet(num_string: str) -> str: """ Extracts the first quartet (four consecutive numerical values) from a given numerical string using regular expressions. Args: num_string (str): The n...
magic_evol_110k
66,232
Write a Python function to shuffle a given list of floating-point numbers while identifying and correcting any issues with the sequence. The function should handle entries not conforming to the floating-point number format by converting them to a standard floating-point number or removing them from the list. The functi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def shuffle_and_correct_floats(numbers: List[float]) -> List[float]: """ Shuffles a given list of floating-point numbers and corrects any issues with the sequence. Handles entries not c...
magic_evol_110k
66,243
Write a Python function to verify if a given integer is a palindrome number. The function should return `True` for palindrome numbers, including negative integers and zero, and `False` for non-palindrome integers. The function should handle negative numbers by ignoring the negative sign when checking for palindromes. ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome_number(n: int) -> bool: """ Determines if a given integer is a palindrome number. Args: n (int): The integer to check for palindrome property. Returns: bool: True if the integer is a p...
magic_evol_110k
66,258
Write a Python function to ensure that a given string containing backslashes (`\`) is printed exactly as it is, without any escape sequences being interpreted. The function should handle both single and double quotes within the string. The code should start with: ```python def print_literal_string(s: str) -> None: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def print_literal_string(s: str) -> None: """ Prints the given string exactly as it is, without interpreting any escape sequences. Args: s (str): The string to be printed. Returns: None """ # Ch...
magic_evol_110k
66,262
Write a Python function to generate a matrix where each row corresponds to an array formed by multiplying a different power of 2 (starting from 1 and going up to the length of the initial array) with each number in the initial array. If the initial array has fewer elements than the maximum length (4 in this case), pad ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_matrix(arr: List[int]) -> List[List[int]]: """ Generates a matrix where each row corresponds to an array formed by multiplying a different power of 2 (starting from 1 and going up to the...
magic_evol_110k
66,277
Write a Python function to analyze the frequency of individual letters in a list of words. The function should have options to: 1. Consider case sensitivity (e.g., 'A' and 'a' are counted as different characters). 2. Include or disregard special characters and numbers. 3. Return the frequency of all characters or list ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union from collections import Counter from string import ascii_letters def letter_frequency(words: List[str], consider_case: bool = True, include_special_chars: bool = False, sorted_by_freq: bool = False) -> Un...
magic_evol_110k
66,280
Write a Python function to compute the Euclidean distance from a single reference point to every other point in a given list of points. The function should return a list of distances corresponding to each point in the input list. The code should start with: ```python from typing import List, Tuple import math def com...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def compute_euclidean_distances(ref_point: Tuple[float, float], points: List[Tuple[float, float]]) -> List[float]: """ Compute the Euclidean distance from a reference point to every ot...
magic_evol_110k
66,295
Write a Python function to calculate the nth power of any given number x without using any built-in exponent or power functions. The function should handle both positive and negative integer values for n. The code should start with: ```python def power(x: float, n: int) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def power(x: float, n: int) -> float: """ Calculate the nth power of a given number x without using built-in exponent or power functions. Args: x (float): The base number. n (int): The exponent. Returns...
magic_evol_110k
66,296
Write a Python function to create and return a nested dictionary representing a pet's information. The dictionary should include the following keys and values: - 'pet': a dictionary containing - 'species': a string representing the species of the pet - 'properName': a string representing the pet's proper name - '...
Here is the Python code to solve the given problem in the markdown block: ```python def create_pet_info(species: str, proper_name: str, lifespan_in_years: int) -> dict: """ Creates and returns a nested dictionary representing a pet's information. Args: species (str): The species of the pet. ...
magic_evol_110k
66,308
Write a Python function to find the second maximum and second minimum numbers in a given list of integers without using any built-in functions, libraries, or sorting algorithms. The function should return a tuple containing the second maximum and second minimum numbers. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_second_max_min(numbers: List[int]) -> Tuple[int, int]: """ Find the second maximum and second minimum numbers in a given list of integers. Args: numbers (List[int]): The list...
magic_evol_110k
66,316
Write a Python function to determine the frequency of characters in a given string, excluding spaces. The function should return a dictionary where the keys are characters and the values are their respective frequencies. The code should start with: ```python from collections import Counter def character_frequency(inpu...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import Counter def character_frequency(input_string: str) -> dict: """ Calculate the frequency of each character in the given string, excluding spaces. Args: input_string (str): The input string fo...
magic_evol_110k
66,325
Write a Python function to swap two strings such that the shorter string is always assigned to the first variable and the longer string is assigned to the second variable. If both strings have the same length, they should remain unchanged. The function should return the two strings in a tuple. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python def swap_strings(string1: str, string2: str) -> tuple: """ Swaps two strings such that the shorter string is assigned to the first variable and the longer string is assigned to the second variable. If both strings have the s...
magic_evol_110k
66,327
Write a Python function to generate a list of words from a given block of text that contain the substring "al", ensuring case insensitivity. The function should also handle special characters and symbols appropriately. The code should start with: ```python from typing import List import re def find_words_with_substrin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def find_words_with_substring(text: str) -> List[str]: """ Generate a list of words from a given block of text that contain the substring "al", ensuring case insensitivity. Args: t...
magic_evol_110k
66,342
Write a Python function to calculate the sum of all odd numbers in a given list. The function should efficiently iterate through the list and sum only the odd numbers. The code should start with: ```python from typing import List def sum_of_odds(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_odds(numbers: List[int]) -> int: """ Calculate the sum of all odd numbers in the given list. Args: numbers (List[int]): A list of integers. Returns: int: The sum of a...
magic_evol_110k
66,343
Write a Python function to count the number of even numbers in a given list of integers. The function should efficiently iterate through the list and count the even numbers. The code should start with: ```python from typing import List def count_even_numbers(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_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...
magic_evol_110k
66,353
Write a Python function to simulate the blinking/flashing/highlighting of a browser tab in the taskbar using JavaScript. The function should generate a JavaScript snippet that changes the favicon of the browser tab every `interval` seconds to indicate new activity. The function should accept the path to the new favicon...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_blink_script(favicon_path: str, interval: int) -> str: """ Generates a JavaScript snippet that changes the favicon of the browser tab every `interval` seconds. Args: favicon_path (str): The path to the ...
magic_evol_110k
66,354
Write a Python function to retrieve the last two elements of a given array without using any inbuilt or library functions. The array may contain both integers and strings. The function should handle arrays of any length, including cases where the array has fewer than two elements. 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, Tuple, Union def get_last_two_elements(arr: List[Union[int, str]]) -> Tuple[Union[int, str], Union[int, str]]: """ Retrieves the last two elements of a given array without using any inbuilt or library f...
magic_evol_110k
66,361
Write a Python function to standardize a floating-point number according to a specific cryptocurrency display format. The function should take a floating-point number as input and return a string formatted to 8 decimal places, similar to the Bitcoin denomination protocol. The function should handle both positive and ne...
Here is the Python code to solve the given problem in the markdown block: ```python def format_cryptocurrency(value: float) -> str: """ Formats a floating-point number to 8 decimal places, suitable for cryptocurrency display. Args: value (float): The floating-point number to be formatted. Retu...
magic_evol_110k
66,362
Write a Python function to compute the factorial of a given prime number and return the result. The function should validate if the input number is a prime number before computing its factorial. If the input is not a prime number, the function should return `None`. The code should start with: ```python import math de...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(number: int) -> bool: """ Helper function to check if a number is prime. Args: number (int): The number to check for primality. Returns: bool: True if the number is prime, Fals...
magic_evol_110k
66,367
Write a Python function to solve a quadratic equation of the form \( ax^2 + bx + c = 0 \) and return the roots in the form of complex numbers. The function should handle both real and complex roots. The code should start with: ```python import cmath def solve_quadratic_equation(a: float, b: float, c: float) -> list: `...
Here is the Python code to solve the given problem in the markdown block: ```python import cmath def solve_quadratic_equation(a: float, b: float, c: float) -> list: """ Solve a quadratic equation of the form ax^2 + bx + c = 0 and return the roots as complex numbers. Args: a (float): Coefficient of...
magic_evol_110k
66,376
Write a Python function that concatenates an array of individual characters into a singular, continuous string. The function should handle both alphabetic and non-alphabetic characters, including special characters and numbers. Additionally, the function should identify and correct erroneous entries, such as `None` or ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def concatenate_characters(chars: List[Union[str, int, float, None]]) -> str: """ Concatenates an array of individual characters into a singular, continuous string. Handles alphabetic and non-...
magic_evol_110k
66,378
Write a Python function to classify numbers in three given arrays into three categories: 'prime', 'composite', and 'neither'. A number is classified as 'prime' if it is a prime number, 'composite' if it is greater than 1 and not prime, and 'neither' if it is 1. The function should return a dictionary with keys 'prime',...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ ...
magic_evol_110k
66,391
Write a Python function to reverse a given list of integers using slicing. The function should return the reversed list. The code should start with: ```python from typing import List def reverse_list(input_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(input_list: List[int]) -> List[int]: """ Reverses the given list of integers using slicing. Args: input_list (List[int]): The list of integers to be reversed. Returns: ...
magic_evol_110k
66,400
Write a Python function to extract a substring from a given string using start and end indices. The function should handle cases where the start or end indices are out of bounds by adjusting them to the nearest valid index. If the start index is greater than the end index, the function should return an empty string. Th...
Here is the Python code to solve the given problem in the markdown block: ```python def safe_slice(string: str, start: int, end: int) -> str: """ Extracts a substring from a given string using start and end indices, handling out-of-bounds indices. Args: string (str): The input string to be sliced. ...
magic_evol_110k
66,404
Write a Python function to find the longest contiguous substring of a distinct character in a given string. The function should handle Unicode characters effectively and use an iterative approach. The code should start with: ```python def longest_substring(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def longest_substring(input_string: str) -> str: """ Finds the longest contiguous substring of a distinct character in the given string. Args: input_string (str): The input string to search for the longest substring...
magic_evol_110k
66,423
Write a Python function to calculate the GPA (Grade Point Average) for a student based on a list of grades. Each grade is represented as a tuple containing the subject and the grade letter (A, B, C, D, F). The function should convert the grade letters to their corresponding numeric values (A=4, B=3, C=2, D=1, F=0) and ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_gpa(grades: List[Tuple[str, str]]) -> float: """ Calculate the Grade Point Average (GPA) for a student based on a list of grades. Args: grades (List[Tuple[str, str]]): A...
magic_evol_110k
66,429
Write a Python function to implement Dijkstra's algorithm for finding the shortest path from a given start node to all other nodes in a weighted graph. The graph is represented as an adjacency list where each node points to a dictionary of its neighbors and the corresponding edge weights. The function should correctly ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union def dijkstras_shortest_path(graph: Dict[str, Dict[str, int]], start_node: str) -> Dict[str, int]: """ Calculate the shortest path from the start node to all other nodes in a weighted graph using D...
magic_evol_110k
66,435
Write a Python function to reverse the order of words in a given string, excluding any specified target word, and return the result as a list. The string may contain words separated by commas, spaces, or both. The function should handle punctuation by treating commas and periods as spaces. 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 reverse_string_words(s: str, target: str) -> List[str]: """ Reverses the order of words in a given string, excluding any specified target word, and returns the result as a list. Args: s ...
magic_evol_110k
66,441
Write a Python function to find the latest step at which there exists a group of ones of length exactly `m` in a binary string that is constructed based on the given array `arr` and array `b`. The binary string starts with all bits set to zero, and at each step `i`, the bit at position `arr[i]` is set to `1` if `b[i]` ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_latest_group_of_size_m(arr: List[int], b: List[int], m: int) -> int: """ Find the latest step at which there exists a group of ones of length exactly `m` in a binary string. Args: a...
magic_evol_110k
66,462
Write a Python function that reduces a given non-unique list of elements (which can include integers and strings) to a maximum of 5 unique elements by consistently dismissing the least frequent elements. The function should handle erroneous data and be robust enough to handle edge cases, such as data type corruption an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union from collections import Counter def downsize_list(data: List[Union[int, str]]) -> List[Union[int, str]]: """ Reduces the given list to a maximum of 5 unique elements by dismissing the least freque...
magic_evol_110k
66,470
Write a Python function to validate a list of email addresses based on the following rules using a regular expression: 1. The email address must start with a letter (a-z, A-Z). 2. Special characters like underscores (_), periods (.), and hyphens (-) can occur after the first character only. 3. The domain name may conta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def validate_emails(emails: List[str]) -> List[str]: """ Validates a list of email addresses based on the specified rules and returns a list of valid emails. Args: emails (List[str...
magic_evol_110k
66,477
Write a Python function to reverse a given list in-place. The function should modify the original list without using additional data structures or creating a new list. The code should start with: ```python from typing import List def reverse_list_in_place(lst: List[int]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list_in_place(lst: List[int]) -> None: """ Reverses the given list in-place. Args: lst (List[int]): The list to be reversed. Returns: None: The function modifies the...
magic_evol_110k
66,486
Write a Python function to find all words in a given list that appear at least `n` times. The function should return a list of these words. The code should start with: ```python from typing import List def find_frequent_words(words: List[str], n: int) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_frequent_words(words: List[str], n: int) -> List[str]: """ Find all words in the given list that appear at least `n` times. Args: words (List[str]): The list of words to analyze. ...
magic_evol_110k
66,489
Write a Python function to calculate the weighted average of ratings for each item based on given attributes and their respective weights. The function should take a list of dictionaries as input, where each dictionary contains an `item_code`, an `attribute_code`, and a `grade`. Additionally, it should take a dictionar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import defaultdict def calculate_weighted_average(data: List[Dict[str, any]], weights: Dict[str, float]) -> Dict[int, float]: """ Calculate the weighted average of ratings for each...
magic_evol_110k
66,508
Write a Python function to calculate the area of different types of triangles based on the given dimensions. The function should be able to handle equilateral, isosceles, and scalene triangles. The function should start with: ```python from typing import Union def triangle_area(triangle_type: str, *args: Union[int, fl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union import math def triangle_area(triangle_type: str, *args: Union[int, float]) -> float: """ Calculate the area of a triangle based on its type and given dimensions. Args: triangle_type (str):...
magic_evol_110k
66,523
Write a Python function to convert a given non-negative integer from decimal to binary representation without using Python's built-in `bin()` function. The function should handle edge cases such as zero and should return the binary representation as a string. The code should start with: ```python def decimal_to_binary...
Here is the Python code to solve the given problem in the markdown block: ```python def decimal_to_binary(n: int) -> str: """ Converts a given non-negative integer from decimal to binary representation. Args: n (int): The non-negative integer to be converted. Returns: str: The binary r...
magic_evol_110k
66,524
Write a Python function to count the occurrences of each alphabetic character in a given string. The function should return a dictionary where the keys are the characters and the values are their respective counts. The function should handle edge cases such as null input and strings consisting only of special character...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_characters(input_string: str) -> Dict[str, int]: """ Counts the occurrences of each alphabetic character in the given string. Args: input_string (str): The string to count characte...
magic_evol_110k
66,529
Write a Python function to find the second highest number among five given integers without using sorting functions. Implement a logic to compare the integers directly. The function should start with: ```python def find_second_highest(integer_1: int, integer_2: int, integer_3: int, integer_4: int, integer_5: int) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python def find_second_highest(integer_1: int, integer_2: int, integer_3: int, integer_4: int, integer_5: int) -> int: """ Find the second highest number among five given integers without using sorting functions. Args: int...
magic_evol_110k
66,533
Write a Python function to calculate the minimum value in a 2D array which may contain different data types. The function should handle cases where the 2D array contains non-numeric data types by ignoring them. The function should return `None` if the 2D array contains no numeric values. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def find_min_in_matrix(matrix: List[List[Union[int, float, str]]]) -> Union[int, float, None]: """ Calculate the minimum value in a 2D array which may contain different data types. Non-numeric...
magic_evol_110k
66,553
Write a Python function to manage a hierarchical structure of animals and their items, where each animal and item has a name and a value. The function should allow adding animals and their items, and then print the animals and their items sorted by their values. The structure should be flexible to handle any number of ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def add_animal_and_items(animals: List[Dict[str, Union[str, float, List[Dict[str, Union[str, float]]]]]]) -> None: """ Adds animals and their items to a hierarchical structure and prints the...
magic_evol_110k
66,558
Write a Python function to determine if all odd-indexed elements in a given list are odd numbers. The function should return `True` if all odd-indexed elements are odd, and `False` otherwise. The code should start with: ```python from typing import List def all_odd_indexed_elements_are_odd(lst: List[int]) -> bool: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def all_odd_indexed_elements_are_odd(lst: List[int]) -> bool: """ Determines if all odd-indexed elements in the given list are odd numbers. Args: lst (List[int]): The list of integers to be ...
magic_evol_110k
66,567
Write a Python function to find the total number of continuous subarrays whose sum equals to `k` in a given array of integers `nums`. The function should not use any built-in functions or libraries, and it should be optimized for performance. The code should start with: ```python def subarray_sum_equals_k(nums: list, k...
Here is the Python code to solve the given problem in the markdown block: ```python def subarray_sum_equals_k(nums: list, k: int) -> int: """ Calculate the total number of continuous subarrays whose sum equals to `k`. Args: nums (list): A list of integers. k (int): The target sum. Retu...
magic_evol_110k
66,569
Write a Python function to check if a given string ends with a specified suffix. The function should return `True` if the string ends with the suffix, and `False` otherwise. The code should start with: ```python def has_suffix(string: str, suffix: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def has_suffix(string: str, suffix: str) -> bool: """ Check if the given string ends with the specified suffix. Args: string (str): The string to check. suffix (str): The suffix to check for at the end of ...
magic_evol_110k
66,570
Write a Python function to solve the "Two Sum" problem efficiently. Given an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. You may assume that each input would have exactly one solution, and you may not use the same element twice. The function...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def two_sum(nums: List[int], target: int) -> List[int]: """ Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. Args: ...
magic_evol_110k
66,572
Write a Python function to invert the digits of a given integer. The function should handle both positive and negative integers. If the input integer is negative, the function should invert the digits while preserving the negative sign. The function should return the inverted integer. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python def invert_digits(n: int) -> int: """ Inverts the digits of a given integer. If the integer is negative, the negative sign is preserved. Args: n (int): The integer whose digits are to be inverted. Returns: ...
magic_evol_110k
66,580
Write a Python function to extract the node with the smallest value from a given array that satisfies a specified condition function and is greater than or equal to a given threshold. The function should return the node value and its index in the format `[smallest_value, index]`. If multiple nodes have the smallest val...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable, Union def pluck(arr: List[int], cond_fn: Callable[[int], bool], thresh: int) -> Union[List[Union[int, None]], List[int]]: """ Extracts the node with the smallest value from a given array that ...
magic_evol_110k
66,587
Write a Python function to filter a list of strings and return a new list containing only the strings with a length greater than a specified threshold. The function should handle an empty list and non-string elements gracefully by ignoring them. The code should start with: ```python from typing import List def filter...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_strings_by_length(strings: List[str], threshold: int) -> List[str]: """ Filters a list of strings and returns a new list containing only the strings with a length greater than the specified th...
magic_evol_110k
66,621
Write a Python function that accepts a dictionary where the keys are English words and the values are their French translations. The function should return the English word (key) that has the maximum number of consonant letters. If there is a tie between multiple words, the function should return the word with the high...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import re def find_word_with_max_consonants(dictionary: Dict[str, str]) -> str: """ Finds the English word in the dictionary with the maximum number of consonant letters. If there is a tie, returns t...
magic_evol_110k
66,622
Write a Python function to calculate the product of the absolute values of a list of numerical entities, considering the closest integer value less than or equal to each number in their absolute forms. The function should handle both positive and negative numbers, and floating-point values. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def multiply_abs_values(lst: List[float]) -> int: """ Calculate the product of the absolute values of a list of numerical entities, considering the closest integer value less than or equa...
magic_evol_110k
66,634
Write a Python function to identify the largest numerical value and its corresponding indices from a list of whole numbers. If the largest number appears more than once, the function should return all the indices where the largest number is located. The function should not use any built-in Python function for fetching ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def get_max_value_and_indices(num_list: List[int]) -> List[Tuple[int, int]]: """ Identifies the largest numerical value and its corresponding indices from a list of whole numbers. If the large...
magic_evol_110k
66,636
Write a Python function to calculate the total time that Ashe is in a poisoned condition given Teemo's attacking time series, the poisoning duration per attack, and the recovery time. The function should return the total poisoned time. The code should start with: ```python from typing import List def total_poisoned_t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def total_poisoned_time(time_series: List[int], duration: int, recovery_time: int) -> int: """ Calculate the total time that Ashe is in a poisoned condition given Teemo's attacking time series, the p...
magic_evol_110k
66,641
Write a Python function to enumerate and return all feasible trajectories traversing from the top-left vertex to the bottom-right vertex within a matrix comprised of `M` rows and `N` columns. Movement is only possible in a downward or rightward direction. The function should return a list of strings, where each string ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def enumerate_paths(M: int, N: int) -> List[str]: """ Enumerate all feasible trajectories traversing from the top-left vertex to the bottom-right vertex within a matrix comprised of M rows and N colu...
magic_evol_110k
66,644
Write a Python function to convert a list of hexadecimal numbers to their equivalent octal numbers. The function should handle a list of up to 15 hexadecimal numbers and return a list of their corresponding octal representations. The code should start with: ```python from typing import List def hex_list_to_oct_list(he...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hex_list_to_oct_list(hex_values: List[str]) -> List[str]: """ Converts a list of hexadecimal numbers to their equivalent octal numbers. Args: hex_values (List[str]): A list of hexadecima...
magic_evol_110k
66,651
Write a Python function to dynamically set the `WebServiceNamespace` based on the current environment (dev, staging, or production). The function should take the environment as a parameter and return the appropriate namespace URL. The environment can be one of the following strings: "dev", "staging", or "production". I...
Here is the Python code to solve the given problem in the markdown block: ```python def get_web_service_namespace(environment: str) -> str: """ Returns the WebServiceNamespace based on the current environment. Args: environment (str): The current environment, which can be "dev", "staging", or "prod...
magic_evol_110k
66,652
Write a Python function to perform basic arithmetic operations (addition, subtraction, multiplication, and division) on two integers and return the results as a dictionary. The function should also handle cases where the second integer is zero for division, raising a custom exception `ZeroDivisionError` with a specific...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict class CustomZeroDivisionError(Exception): """Custom exception for division by zero.""" pass def arithmetic_operations(a: int, b: int) -> Dict[str, int]: """ Perform basic arithmetic operations o...
magic_evol_110k
66,659
Write a Python function to calculate the number of participants each team should receive when dividing a given number of participants evenly among a specified number of teams. If the division results in a remainder, the function should return the integer part of the division and indicate the number of participants left...
Here is the Python code to solve the given problem in the markdown block: ```python def divide_participants(total_participants: int, num_teams: int) -> tuple: """ Calculate the number of participants each team should receive when dividing a given number of participants evenly among a specified number of teams. ...
magic_evol_110k
66,675
Write a Python function to convert a day of the year (1-365 or 1-366 for leap years) into its corresponding date in the format `DD-MMM-YYYY` and another function to convert a given date back into the day of the year format. The functions should handle leap years and validate the input such that incorrect date values an...
Here is the Python code to solve the given problem in the markdown block: ```python import datetime def is_valid_year(year: int) -> bool: """Validate if a year is within the range 1900-2100.""" return 1900 <= year <= 2100 def is_valid_day(day: int, year: int) -> bool: """Validate if a day is within the ra...
magic_evol_110k
66,677
Write a Python function `check_prime_hash` that verifies if a number is a prime number using a hash table for optimization. Additionally, develop an auxiliary function `generate_hash` that computes the hash of a number. The `check_prime_hash` function should return `True` for prime numbers and `False` for non-prime num...
Here is the Python code to solve the given problem in the markdown block: ```python # Global variable used for hash table of prime numbers hash_table = {} def generate_hash(n: int) -> int: """ A hash function that generates a unique hash value. This value is key in the hash table. Hash is calculated by tak...
magic_evol_110k
66,681
Write a Python function to construct a dictionary from a list of tuples, where each tuple contains a key-value pair. The function should handle cases where the input list might be empty or contain invalid tuples (e.g., tuples with more than two elements). If an invalid tuple is encountered, it should be skipped. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def construct_dictionary(data: List[Tuple[str, int]]) -> Dict[str, int]: """ Constructs a dictionary from a list of tuples, where each tuple contains a key-value pair. Invalid tuples (th...
magic_evol_110k
66,683
Write a Python function to extract and return a list of unique even integers from an unordered collection of numerical values. The function should ensure that each unique even integer appears only once in the output list, in the order of their first appearance. The function should handle various edge cases, such as rep...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def unique_even_numbers(collection: List[Union[int, float, str]]) -> List[int]: """ Extracts and returns a list of unique even integers from an unordered collection of numerical values. Args:...
magic_evol_110k
66,690
Write a Python function to flatten an n-dimensional array and sort the elements in the flattened array in ascending order. The function should handle cases where some elements of the array could be strings. The function should return the flattened and sorted array with numbers first, followed by strings. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def flatten_and_sort_array(array: List[Union[int, float, str, List]]) -> List[Union[int, float, str]]: """ Flattens an n-dimensional array and sorts the elements in the flattened array in ascendin...
magic_evol_110k
66,698
Write a Python function to separate a sequence of integers into two reversed sub-sequences: one containing prime numbers and the other containing composite numbers. The function should return a tuple containing the reversed list of prime numbers and the reversed list of composite numbers. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ ...
magic_evol_110k
66,736
Write a Python function to verify if all rows in a given 2-dimensional NumPy array are identical. The function should be efficient and idiomatic, avoiding the mixing of Python lists with NumPy arrays. The code should start with: ```python import numpy as np def are_all_rows_identical(arr: np.ndarray) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def are_all_rows_identical(arr: np.ndarray) -> bool: """ Verify if all rows in a given 2-dimensional NumPy array are identical. Args: arr (np.ndarray): A 2-dimensional NumPy array. Returns: ...
magic_evol_110k
66,741
Write a Python function to compute the greatest common divisor (GCD) of two non-negative integers using the Binary GCD algorithm. The function should handle edge cases where either or both integers are zero. The code should start with: ```python def binary_gcd(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def binary_gcd(a: int, b: int) -> int: """ Compute the greatest common divisor (GCD) of two non-negative integers using the Binary GCD algorithm. Args: a (int): The first non-negative integer. b (int): The s...
magic_evol_110k
66,743
Write a Python function to construct a 5x5 NumPy array of random floating-point numbers between -3.0 and 7.0. Then, locate all negative values and replace them with their absolute value. Finally, set all values over 5.0 to the matrix's mean. The code should start with: ```python import numpy as np def process_array()...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def process_array() -> np.ndarray: """ Constructs a 5x5 NumPy array of random floating-point numbers between -3.0 and 7.0. Replaces all negative values with their absolute values and sets all values over ...
magic_evol_110k
66,744
Write a Python function to convert a binary string to its decimal equivalent and another function to convert a decimal number to its binary string representation. Each function should handle invalid input gracefully by returning an appropriate error message. The code should start with: ```python def binary_to_decimal(...
Here is the Python code to solve the given problem in the markdown block: ```python def binary_to_decimal(binary_str: str) -> str: """ Converts a binary string to its decimal equivalent. Args: binary_str (str): The binary string to convert. Returns: str: The decimal equivalent as a str...
magic_evol_110k
66,752
Write a Python function to find the minimum value in a given array of integers without using the built-in `min()` function. The function should iterate through the array and keep track of the smallest value encountered. The code should start with: ```python from typing import List def find_minimum_value(arr: List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_minimum_value(arr: List[int]) -> int: """ Find the minimum value in a given array of integers without using the built-in min() function. Args: arr (List[int]): The array of integers...
magic_evol_110k
66,753
Write a Python function to determine the total number of unique subarrays in a given array. A subarray is defined as a contiguous segment of the original array. The function should be efficient and capable of handling arrays with up to 10^3 elements. The array may contain repeated elements. 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_unique_subarrays(arr: List[int]) -> int: """ Calculate the total number of unique subarrays in a given array. Args: arr (List[int]): The input array for which to count the subarray...
magic_evol_110k
66,755
Write a Python function to generate and print a 7x7 multiplication table in reverse order, starting from 49 down to 1. Each cell in the table should display the product of the row and column indices, formatted as a two-digit number. The function should not return any value but should print the table directly to the con...
Here is the Python code to solve the given problem in the markdown block: ```python def print_reverse_multiplication_table(): """ Generates and prints a 7x7 multiplication table in reverse order, starting from 49 down to 1. Each cell in the table displays the product of the row and column indices, formatted...
magic_evol_110k
66,758
Write a Python function to reverse the elements of a given list without using built-in functions like `reverse()` or `reversed()`, and without modifying the original list. The function should use a for loop to achieve this. The code should start with: ```python from typing import List def reverse_list(lst: List[int])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(lst: List[int]) -> List[int]: """ Reverses the elements of a given list without using built-in functions and without modifying the original list. Args: lst (List[int]): The ...
magic_evol_110k
66,764
Write a Python function to find the common elements between two given lists. The function should return a list of common elements in ascending order. The code should start with: ```python from typing import List def find_common_elements(list1: List[int], list2: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(list1: List[int], list2: List[int]) -> List[int]: """ Finds the common elements between two lists and returns them in ascending order. Args: list1 (List[int]): The f...
magic_evol_110k
66,765
Write a Python function to create and display an array of `n` integers initialized to zero. The function should ensure that the array is correctly initialized and display each element of the array. Additionally, the function should include a comprehensive explanation of the initial erroneous code provided and how it wa...
Here is the Python code to solve the given problem in the markdown block: ```python def initialize_and_display_array(n: int) -> None: """ Initializes an array of `n` integers to zero and displays each element. Args: n (int): The number of elements in the array. Returns: None: The funct...
magic_evol_110k
66,780
Write a Python function to extract even numbers from three given lists, merge them into a single list, and sort the merged list in increasing order. The function should not perform any unrelated or complex tasks. The code should start with: ```python from typing import List def get_even_numbers_sorted(l1: List[int], l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_even_numbers_sorted(l1: List[int], l2: List[int], l3: List[int]) -> List[int]: """ Extracts even numbers from three given lists, merges them into a single list, and sorts the merged list in incre...
magic_evol_110k
66,782
Write a Python function to filter a list of integers based on specific criteria and return the sum and the highest number that meet the criteria. The criteria are: 1. The number must be greater than 10. 2. The first digit of the number must be odd. 3. The last digit of the number must be odd. 4. The number must be a pr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def special_filter(nums: List[int], limit: int) -> Tuple[int, int]: """ Filters a list of integers based on specific criteria and returns the sum and the highest number that meet the c...
magic_evol_110k
66,787
Write a Python function to find and return the positions of all occurrences of a specified number in a given list. The function should return a list of indices where the specified number appears. The code should start with: ```python from typing import List def find_positions(lst: List[int], number: int) -> List[int]:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_positions(lst: List[int], number: int) -> List[int]: """ Finds and returns the positions of all occurrences of a specified number in a given list. Args: lst (List[int]): The list of...
magic_evol_110k
66,790
Write a Python function to count the number of lowercase letters in a given string. The function should iterate through each character in the string and count only the lowercase alphabetic characters. The function should return the total count of such characters. The code should start with: ```python def count_lowerca...
Here is the Python code to solve the given problem in the markdown block: ```python def count_lowercase_letters(s: str) -> int: """ Counts the number of lowercase letters in a given string. Args: s (str): The input string to be examined. Returns: int: The total number of lowercase lett...
magic_evol_110k
66,799
Write a Python function to calculate the product of all numerical entities within a nested list. The list may contain other lists, and these lists may also include lists, ad infinitum. The function should handle non-numeric entities by disregarding them. The code should start with: ```python from typing import Union, L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List def multiply_nested_list_values(l: Union[List, int, float]) -> Union[int, float]: """ Calculate the product of all numerical entities within a nested list. Args: l (Union[List, int, f...
magic_evol_110k
66,800
Write a Python function to search for a specific word in a list of words and print a message indicating whether the word was found or not. If the word is found, the function should print "Done" and stop searching. If the word is not found after checking all the words, the function should print "Word not found". The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def search_word(words: List[str], target: str) -> None: """ Searches for a specific word in a list of words and prints a message indicating whether the word was found or not. Args: words (Li...
magic_evol_110k
66,803
Write a Python function to remove all empty strings from a given list of strings. The function should return a new list that contains only the non-empty strings from the original list. The code should start with: ```python from typing import List def remove_empty_strings(strings: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_empty_strings(strings: List[str]) -> List[str]: """ Removes all empty strings from the given list of strings. Args: strings (List[str]): The list of strings from which to remove e...
magic_evol_110k
66,809
Write a Python function to identify and return the occurrences of the word "phoenix" showing up at the start of a paragraph in a given text. The function should use regular expressions to perform this task. The text may contain multiple paragraphs separated by newline characters. The function should return a list of pa...
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def find_phoenix_paragraphs(text: str) -> List[str]: """ Identify and return paragraphs that start with the word "phoenix" in a given text. Args: text (str): The input text contain...
magic_evol_110k
66,814
Write a Python function to calculate the maximum profit that can be achieved by buying and selling a stock within a given period. The stock prices are provided in a list where each element represents the stock price at a specific time. The function should determine the best day to buy and the best day to sell to maximi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(stock_prices: List[int]) -> int: """ Calculate the maximum profit that can be achieved by buying and selling a stock within a given period. Args: stock_prices (List[int]): A l...
magic_evol_110k
66,821
Write a Python function to implement the Caesar Cipher encryption technique. The function should take a string `text` and an integer `shift` as inputs and return the encrypted string. The Caesar Cipher shifts each alphabetic character in the text by a specified number of positions in the alphabetical order. Non-alphabe...
Here is the Python code to solve the given problem in the markdown block: ```python def caesar_cipher(text: str, shift: int) -> str: """ Encrypts the given text using the Caesar Cipher technique. The Caesar Cipher shifts each alphabetic character in the text by a specified number of positions in the alphab...
magic_evol_110k
66,833
Write a Python function to match sentences that contain the word "dog", followed by any number of characters except the letters "x" and "y", and ending with the word "cat" followed by a number between 1 and 10 inclusive, which is not a prime number. The function should return `True` if the sentence matches the pattern,...
Here is the Python code to solve the given problem in the markdown block: ```python import re def match_sentence(sentence: str) -> bool: """ Matches sentences that contain the word "dog", followed by any number of characters except "x" and "y", and ending with the word "cat" followed by a non-prime number ...
magic_evol_110k
66,834
Write two Python functions. The first function should concatenate two input strings with a space in between. The second function should take the output of the first function and concatenate the two strings with a common character that exists in both strings. If no common character exists, raise a `ValueError`. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_strings(string1: str, string2: str) -> str: """ Concatenate two strings with a space in between. Args: string1 (str): The first string. string2 (str): The second string. Returns: ...
magic_evol_110k
66,838
Write a Python function to concatenate two strings with a specified delimiter and return the resulting string. The function should handle cases where the delimiter is an empty string. The code should start with: ```python def concatenate_with_delimiter(string1: str, string2: str, delimiter: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_with_delimiter(string1: str, string2: str, delimiter: str) -> str: """ Concatenates two strings with a specified delimiter and returns the resulting string. Args: string1 (str): The first string to c...
magic_evol_110k
66,842
Write a Python function to generate all possible permutations of the linguistic sequence "lmnopqr" and sort these permutations into disjoint sets based on the maximum number of consecutive elements present in each permutation. The function should continue generating the next subset until no more permutations with the t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import itertools def get_max_consecutive_length(seq: str) -> int: """ Calculate the maximum length of consecutive characters in a given sequence. Args: seq (str): The sequence of chara...
magic_evol_110k
66,869
Write a Python function to optimize the runtime and memory usage of a given function that doubles each element in a list. Additionally, implement error handling to account for potential issues with the input. The function should return a generator that yields the doubled values one by one. The starter code is: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python def optimized_function(my_list): """ Optimizes the runtime and memory usage of a function that doubles each element in a list. Returns a generator that yields the doubled values one by one. Args: my_list (list):...
magic_evol_110k
66,874
Write a Python function to duplicate each word in a given string a specified number of times. The function should take a string of text and a numerical figure as input parameters and return a manipulated version of the original text where each individual word is duplicated according to the given numerical figure. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def duplicate_words(text: str, num: int) -> str: """ Duplicates each word in the given text a specified number of times. Args: text (str): The input string containing the words to be duplicated. num (int): T...
magic_evol_110k
66,881
Write a Python function to sort a list of numbers without using Python's built-in `sort` function. The function should implement a sorting algorithm of your choice. Additionally, identify and fix the error in the provided erroneous code. The code should start with: ```python from typing import List def custom_sort(nu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_sort(numbers: List[int]) -> List[int]: """ Sorts a list of numbers using the Selection Sort algorithm. Args: numbers (List[int]): The list of numbers to be sorted. Returns: ...