source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
31,086
Write a Python function to generate a list of unique elements from a given list of integers. The function should efficiently remove duplicates while preserving the order of the first occurrence of each element. The code should start with: ```python from typing import List def generate_unique_elements(nums: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_unique_elements(nums: List[int]) -> List[int]: """ Generates a list of unique elements from the given list of integers, preserving the order of the first occurrence of each element. Arg...
evol_instruct_66k
31,087
Write a Python function that generates a list of strings representing numbers from 1 to 500, replacing any number divisible by 5 with the string "Five". The function should return this list. The code should start with: ```python from typing import List def generate_number_list() -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_number_list() -> List[str]: """ Generates a list of strings representing numbers from 1 to 500, replacing any number divisible by 5 with "Five". Returns: List[str]: A list of st...
evol_instruct_66k
31,130
Write a Python function to find all perfect numbers within a given range from 0 to n. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). The function should return a list of all such perfect numbers. 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_perfect_numbers(n: int) -> List[int]: """ Find all perfect numbers within the range from 0 to n. Args: n (int): The upper limit of the range (inclusive). Returns: List[...
evol_instruct_66k
31,139
Write a Python function to arrange a given numeric array of integers such that all elements less than or equal to a specified upper limit `N` are sorted in ascending order, while elements greater than `N` are excluded. The function should return the sorted sub-array. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def arrange_array(arr: List[int], N: int) -> List[int]: """ Arranges the given numeric array such that all elements less than or equal to N are sorted in ascending order, while elements greater than ...
evol_instruct_66k
31,158
Write a Python function to calculate the average movie rating based on ratings from different sources. The ratings are stored in a dictionary within a dictionary that contains information about the movie. The function should handle the case where the ratings dictionary might contain invalid keys or values. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def calculate_average_rating(movie_info: Dict) -> float: """ Calculate the average movie rating based on ratings from different sources. Args: movie_info (dict): A dictionary containing movi...
evol_instruct_66k
31,173
Write a Python function to verify if a given array is sorted in ascending order. The function should return `True` if the array is sorted, and `False` otherwise. The code should start with: ```python from typing import List def is_sorted_ascending(arr: List[int]) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_sorted_ascending(arr: List[int]) -> bool: """ Verify if the given array is sorted in ascending order. Args: arr (List[int]): The array to be checked. Returns: bool: True ...
evol_instruct_66k
31,175
Write a Python function to perform a Fibonacci search on a sorted array to find the index of a target element. The Fibonacci search is a comparison-based technique that uses Fibonacci numbers to search for an element in a sorted array. The function should return the index of the target element if it exists in the array...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def fibonacci_search(arr: List[int], target: int) -> int: """ Perform a Fibonacci search on a sorted array to find the index of a target element. Args: arr (List[int]): A sorted list of inte...
evol_instruct_66k
31,176
Write a Python function to generate and return a list of all even numbers within a given range `[start, end]`. The function should ensure that only even numbers are included in the result. The code should start with: ```python from typing import List def get_even_numbers(start: int, end: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_even_numbers(start: int, end: int) -> List[int]: """ Generate and return a list of all even numbers within the given range [start, end]. Args: start (int): The starting number of the...
evol_instruct_66k
31,177
Write a Python function to replace the vowel characters in a given string with random alphabetic characters, ensuring that all letters of the alphabet have an approximately equal chance of replacing any given vowel. The string may contain alphanumeric and special characters. The code should start with: ```python import...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def replace_vowels_with_random_alphabet(s: str) -> str: """ Replace the vowel characters in a given string with random alphabetic characters. Args: s (str): The input string containing a...
evol_instruct_66k
31,180
Write a Python function that uses a lambda function to calculate the product of two arbitrarily provided numerical entities. The function should be named `product_lambda` and should return the lambda function. The lambda function should take two arguments and return their product. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python def product_lambda(): """ Returns a lambda function that calculates the product of two numbers. Returns: function: A lambda function that takes two arguments and returns their product. """ return lambda num1...
evol_instruct_66k
31,214
Write a Python function to calculate the factorial of a given non-negative integer using an iterative approach. The function should handle edge cases such as zero and large numbers efficiently. The code should start with: ```python def factorial_iterative(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def factorial_iterative(n: int) -> int: """ Calculate the factorial of a given non-negative integer using an iterative approach. Args: n (int): The non-negative integer for which to calculate the factorial. R...
evol_instruct_66k
31,240
Write a Python function to perform a recursive decrement operation starting from a given integer value and stopping when it reaches 0. The function should handle non-integer and negative inputs by raising a `ValueError`. The function should also print the current value at each step. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python def recursive_decrement(value: int) -> int: """ Perform a recursive decrement operation starting from a given integer value and stopping when it reaches 0. The function prints the current value at each step and raises a Valu...
evol_instruct_66k
31,244
Write a Python function to determine all prime numbers within the range of 1 to 10000, excluding both endpoints, using the Sieve of Eratosthenes algorithm. Additionally, create a function to verify if a given number is a prime using the same algorithm. The code should start with: ```python from typing import List def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_primes_in_range(n: int) -> List[int]: """ Find all prime numbers within the range of 1 to n, excluding both endpoints. Args: n (int): The upper limit of the range (exclusive). ...
evol_instruct_66k
31,254
Write a Python function to calculate the Euclidean distance between two points in a three-dimensional Cartesian coordinate system. The function should handle potential errors for invalid points and provide meaningful, informative outputs in such cases. The code should start with: ```python from typing import Tuple def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import math def euclidean_distance(point1: Tuple[float, float, float], point2: Tuple[float, float, float]) -> float: """ Calculate the Euclidean distance between two points in a three-dimensional Cartes...
evol_instruct_66k
31,255
Write a Python function to sort a list of unique fruit names in reverse alphabetical order. The function should take a list of strings as input and return a new list with the strings sorted in reverse alphabetical order. The original list should not be modified. The code should start with: ```python from typing import...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sort_fruits_reverse_alphabetical(fruits: List[str]) -> List[str]: """ Sorts a list of unique fruit names in reverse alphabetical order. Args: fruits (List[str]): A list of unique fruit...
evol_instruct_66k
31,256
Write a Python function that calculates the age five years from now, ensuring that the input is an integer. If the input is not an integer, the function should raise a `TypeError` with a specific error message. The function should start with: ```python def calculate_age_in_five_years(age: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_age_in_five_years(age: int) -> int: """ Calculate the age five years from now, ensuring the input is an integer. Args: age (int): The current age, which should be an integer. Returns: int:...
evol_instruct_66k
31,266
Write a Python function to add a specified constant to each element of a given list of integers. The function should return a new list with the modified elements. The code should start with: ```python from typing import List def add_constant_to_list(lst: List[int], const: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_constant_to_list(lst: List[int], const: int) -> List[int]: """ Adds a specified constant to each element of a given list of integers. Args: lst (List[int]): The list of integers to w...
evol_instruct_66k
31,269
Write a Python function to update the value of a specific key in a dictionary based on the presence of another key. If the key "c" is present in the dictionary, update its value to "cherries". Otherwise, update the value of the key "a" to "apples". The function should start with: ```python from typing import Dict def ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def update_dict_value(my_dict: Dict[str, str]) -> Dict[str, str]: """ Update the value of a specific key in the dictionary based on the presence of another key. If the key "c" is present in the dict...
evol_instruct_66k
31,274
Write a Python function to generate a list of strings based on a given pattern. The function should take an integer `n` as input and return a list of `n` strings, where each string follows the pattern "WordX", with `X` being the 1-based index of the string in the list. For example, if `n` is 3, the function should retu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_word_list(n: int) -> List[str]: """ Generates a list of strings based on a given pattern. Args: n (int): The number of strings to generate. Returns: List[str]: A li...
evol_instruct_66k
31,283
Write a Python function that checks if a given numerical value exceeds 10 and returns the string 'Success' if it does. If the numerical value does not exceed 10, return the string 'Failure'. The function should handle both integer and floating-point inputs. The code should start with: ```python def check_success(numer...
Here is the Python code to solve the given problem in the markdown block: ```python def check_success(numerical_value: float) -> str: """ Checks if the given numerical value exceeds 10 and returns 'Success' if it does, otherwise returns 'Failure'. Args: numerical_value (float): The numerical value ...
evol_instruct_66k
31,285
Write a Python function to calculate the sum of all elements in a given list of integers. The function should be efficient and handle lists of varying sizes. The code should start with: ```python from typing import List def sum_of_elements(arr: 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_elements(arr: List[int]) -> int: """ Calculate the sum of all elements in a given list of integers. Args: arr (List[int]): The list of integers to sum. Returns: int...
evol_instruct_66k
31,292
Write a Python function to compute the divergence between the maximum (apex) and minimum (nadir) integers within a given list. The function should also return the indices of the first occurrence of the apex and nadir integers. The function should efficiently handle scenarios where the list may contain identical integer...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Optional def compute_divergence_and_indices(arr: List[int]) -> Optional[Tuple[int, int, int]]: """ Computes the divergence between the maximum (apex) and minimum (nadir) integers in a list, a...
evol_instruct_66k
31,293
Write a Python function to substitute every numerical value present within a specified string with the symbol designated as a hash (`#`). The function should use regular expressions to identify and replace all numerical digits in the input string. The code should start with: ```python import re def substitute_numeric...
Here is the Python code to solve the given problem in the markdown block: ```python import re def substitute_numerical_values(s: str) -> str: """ Substitutes every numerical value present within the specified string with the hash symbol (#). Args: s (str): The input string containing numerical val...
evol_instruct_66k
31,299
Write a Python function to combine two lists by index using the `zip` function and calculate the product of the paired elements. The resulting list should contain the products of the paired elements. The function should handle lists of different lengths by truncating the longer list to the length of the shorter list. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_products(list1: List[int], list2: List[int]) -> List[int]: """ Calculate the product of paired elements from two lists using the zip function. Args: list1 (List[int]): The firs...
evol_instruct_66k
31,300
Write a Python function to remove duplicate entries from a tuple and reorder the entries in ascending order. The function should be optimized for time complexity. The code should start with: ```python from typing import Tuple def remove_duplicates_and_reorder(tup: Tuple[int]) -> Tuple[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def remove_duplicates_and_reorder(tup: Tuple[int]) -> Tuple[int]: """ Removes duplicate entries from a tuple and reorders the entries in ascending order. Args: tup (Tuple[int]): The input t...
evol_instruct_66k
31,305
Write a Python function to flatten a given tri-dimensional array and count the frequency of each numeric element, while gracefully handling any non-numeric elements by excluding them from the count. The function should return a dictionary where the keys are the numeric elements and the values are their respective frequ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def flatten_3D_matrix(matrix: List[List[List[object]]]) -> Dict[object, int]: """ Flattens a tri-dimensional array and counts the frequency of each numeric element, while excluding non-numeric ...
evol_instruct_66k
31,307
Write a Python function to perform a complex arithmetic computation using bitwise shift operators on two given integers, and return the result. The function should take two integers as input and return the result of the computation. The computation involves shifting the first integer to the left by the number of bits s...
Here is the Python code to solve the given problem in the markdown block: ```python def complex_arithmetic_computation(a: int, b: int) -> int: """ Perform a complex arithmetic computation using bitwise shift operators on two given integers. The computation involves shifting the first integer to the left by...
evol_instruct_66k
31,335
Write a Python function to perform the Hadamard product (element-wise multiplication) on two 4x4 matrices. The function should ensure that both matrices are of the correct dimensions before performing the operation. The code should start with: ```python from typing import List def hadamard_product(matrix1: List[List[i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hadamard_product(matrix1: List[List[int]], matrix2: List[List[int]]) -> List[List[int]]: """ Perform the Hadamard product (element-wise multiplication) on two 4x4 matrices. Args: matrix1...
evol_instruct_66k
31,345
Write a Python function to remove all whitespace characters from a given input string. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with: ```python def remove_whitespace(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def remove_whitespace(input_string: str) -> str: """ Removes all whitespace characters from the given input string. Args: input_string (str): The input string from which to remove whitespace characters. ...
evol_instruct_66k
31,347
Write a Python function to generate a list of factorials for numbers from 1 to a given number `n`. The function should return a list where each element at index `i` is the factorial of the number `i+1`. The code should start with: ```python from typing import List def generate_factorial_list(n: int) -> List[int]: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_factorial_list(n: int) -> List[int]: """ Generate a list of factorials for numbers from 1 to the given number n. Args: n (int): The upper limit for generating factorials. R...
evol_instruct_66k
31,373
Write a Python function to count the occurrences of each character in a given string for a specified list of characters. The function should be memory efficient, as the string can contain up to 1,000,000 characters. The function should return a dictionary with the characters as keys and their respective counts as value...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_character_occurrences(char_list: List[str], string: str) -> Dict[str, int]: """ Counts the occurrences of each character in the given string for a specified list of characters. Args:...
evol_instruct_66k
31,376
Write a Python function to calculate the Least Common Multiple (LCM) of a given list of integers efficiently. The list may contain up to 10^3 elements, each ranging between 1 and 10^9. The function should be optimized for performance, considering the constraints provided. 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 import math def lcm_of_list(numbers: List[int]) -> int: """ Calculate the Least Common Multiple (LCM) of a list of integers efficiently. Args: numbers (List[int]): A list of integers for whi...
evol_instruct_66k
31,389
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The function should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid. Args: m (int): The number of row...
evol_instruct_66k
31,390
Write a Python function to reverse the order of characters in a given string. The function should take a single parameter, which is the string to be reversed, and return the reversed string. The code should start with: ```python def reverse_string(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(s: str) -> str: """ Reverses the order of characters in the given string. Args: s (str): The string to be reversed. Returns: str: The reversed string. """ # Use slicing to rev...
evol_instruct_66k
31,391
Write a Python function to create a dictionary where each director and movie pair is matched according to the corresponding rating in the ratings list. The function should take three lists as input: `movies_list`, `directors_list`, and `ratings_list`. Each list contains the same number of elements, where each element c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_director_movie_rating_dict(movies_list: List[str], directors_list: List[str], ratings_list: List[float]) -> Dict[tuple, float]: """ Creates a dictionary where each director and movie pai...
evol_instruct_66k
31,393
Write a Python function to create a random 3D array with the provided dimensions. The function should accept three integers representing the number of layers, rows, and columns, and return a 3D NumPy array filled with random floating-point numbers between 0 and 1. The code should start with: ```python import numpy as ...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_random_3d_array(layers: int, rows: int, columns: int) -> np.ndarray: """ Create a random 3D array with the specified dimensions. Args: layers (int): The number of layers in the 3D arra...
evol_instruct_66k
31,401
Write a Python function to calculate the cumulative sum of an array of numerical integers, where each positive number is multiplied by its 1-based index before being added to the sum. Negative numbers should be ignored. The code should start with: ```python from typing import List def cumulative_sum_with_index(array:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_sum_with_index(array: List[int]) -> int: """ Calculate the cumulative sum of an array where each positive number is multiplied by its 1-based index before being added to the sum. Args...
evol_instruct_66k
31,410
Write a Python function to combine two dictionaries into a single dictionary. If both dictionaries have the same key, the value from the second dictionary should overwrite the value from the first dictionary. The function should handle any number of dictionaries provided as input. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def combine_dictionaries(*dicts: Dict[Any, Any]) -> Dict[Any, Any]: """ Combines multiple dictionaries into a single dictionary. If there are overlapping keys, the value from the latter dictiona...
evol_instruct_66k
31,430
Write a Python function to calculate the factorial values for the first twenty positive integers following a given starting integer, and store the results in a dictionary where the keys are the integers and the values are their corresponding factorial values. The function should start with: ```python from typing import...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import math def calculate_factorials(start: int) -> Dict[int, int]: """ Calculate the factorial values for the first twenty positive integers following a given starting integer. Args: start ...
evol_instruct_66k
31,436
Write a Python function to generate the mirrored sequence of a given list. The mirrored sequence is defined as the original list followed by its reverse. For example, the mirrored sequence of `[1, 2, 3]` is `[1, 2, 3, 3, 2, 1]`. The function should handle lists of any length, including empty lists. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def mirrored_sequence(seq: List[int]) -> List[int]: """ Generate the mirrored sequence of a given list. The mirrored sequence is defined as the original list followed by its reverse. Args: ...
evol_instruct_66k
31,437
Write a Python function to generate 5 random numbers between 0 and 1 with a precision of 10 decimal places, ensuring that the sum of all generated numbers is less than 2. The function should also return the generated numbers sorted in descending order. The random number generator should be set with a seed of 123 for re...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_random_numbers() -> List[float]: """ Generates 5 random numbers between 0 and 1 with a precision of 10 decimal places, ensuring that their sum is less than 2. The numbers a...
evol_instruct_66k
31,448
Write a Python function to identify and list all the unique vowels in a given string, along with their occurrence count. The function should return a dictionary where the keys are the vowels and the values are their respective counts. The function should be case-insensitive, meaning both uppercase and lowercase vowels ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_vowels(s: str) -> Dict[str, int]: """ Counts the occurrences of each vowel in the given string. Args: s (str): The input string to analyze. Returns: Dict[str, int]: A ...
evol_instruct_66k
31,449
Write a Python function to reverse the elements of an array within a specified index range in-place. The function should modify the input array directly without creating additional data structures for the reversed elements. The function should start with: ```python from typing import List def reverse_elements_in_range...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_elements_in_range(arr: List[int], start_index: int, end_index: int) -> None: """ Reverses the elements of the array within the specified index range in-place. Args: arr (List[int...
evol_instruct_66k
31,458
Write a Python function to perform a binary search on a sorted array to find the index of a specified element `x`. If the element is not found, return `-1`. The function should be efficient and leverage the properties of a sorted array to minimize the number of comparisons. 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 def binary_search(array: List[int], x: int) -> int: """ Perform a binary search on a sorted array to find the index of the element `x`. Args: array (List[int]): A sorted list of integers. ...
evol_instruct_66k
31,459
Write a Python function to find the common elements between two lists of integers. The function should return a list of unique common elements in the order they appear in the first list. The code should start with: ```python from typing import List def find_common_elements(arr1: List[int], arr2: 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(arr1: List[int], arr2: List[int]) -> List[int]: """ Find the common elements between two lists of integers and return them in the order they appear in the first list. Args: ...
evol_instruct_66k
31,468
Write a Python function to create a dictionary where the keys are the unique lexical items (words) from a given sentence, and the values are the counts of vowel phonemes in each corresponding lexical item. The sentence may contain punctuation and should be processed to remove it. The function should be case-insensitive...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import string def count_vowel_phonemes(sentence: str) -> Dict[str, int]: """ Creates a dictionary where the keys are the unique lexical items from the given sentence, and the values are the counts of...
evol_instruct_66k
31,477
Write a Python function to sort a list of positive integers based on the length of their binary representation in ascending order. If two or more integers have the same binary length, they should be sorted by their decimal values in ascending order. The function should start with: ```python from typing import List def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_by_binary_length(arr: List[int]) -> List[int]: """ Sorts a list of positive integers based on the length of their binary representation in ascending order. If two or more integers have the s...
evol_instruct_66k
31,479
Write a Python function to generate an associative array (dictionary) where the keys are integers from 1 to `n` (inclusive) and the values are the squares of the corresponding keys. The function should handle the case where `n` is less than 1 by returning an empty dictionary. The code should start with: ```python def ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_squares_dict(n: int) -> dict: """ Generates a dictionary where the keys are integers from 1 to n (inclusive) and the values are the squares of the corresponding keys. Args: n (int): The upper limit ...
evol_instruct_66k
31,481
Write a Python function to create a one-dimensional list with precisely ten elements, all of them being integer type and initialized individually to a numeric null value (i.e., zero). The function should then return this list. Additionally, write a separate function to display each element's value in the list. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_zero_list() -> List[int]: """ Create a list with 10 elements, all initialized to 0. Returns: List[int]: A list with 10 elements, all set to 0. """ return [0] * 10 def dis...
evol_instruct_66k
31,482
Write a Python function to generate a two-dimensional sparse matrix of size `n x n` from a provided list of numerical values and a separate list indicating the indices at which these values need to be placed. The remaining elements in the matrix should be zero. The function should also validate that the provided values...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import numpy as np def generate_sparse_matrix(n: int, numbers: List[int], indices: List[Tuple[int, int]]) -> np.ndarray: """ Generates a two-dimensional sparse matrix of size n x n from a provided...
evol_instruct_66k
31,491
Write a Python function to determine all prime numbers up to a given integer `n` using the Sieve of Eratosthenes algorithm. The function should return a list of all prime numbers less than or equal to `n`. The code should start with: ```python from typing import List def sieve_of_eratosthenes(n: int) -> List[int]: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sieve_of_eratosthenes(n: int) -> List[int]: """ Find all prime numbers up to a given integer n using the Sieve of Eratosthenes algorithm. Args: n (int): The upper limit up to which to fi...
evol_instruct_66k
31,492
Write a Python function to safely convert a floating-point number to a short integer, considering the following constraints and additional requirements: 1. The function should accept a floating-point number as input. 2. The floating-point number should be manually rounded to the nearest integer and stored as a short i...
Here is the Python code to solve the given problem in the markdown block: ```python def safe_float_to_short(value: float) -> int: """ Safely converts a floating-point number to a short integer. Args: value (float): The floating-point number to be converted. Returns: int: The rounded sh...
evol_instruct_66k
31,495
Write a Python function to generate a list of the first `n` cube numbers using a list comprehension. The function should take an integer `n` as input and return a list of the first `n` cube numbers. The code should start with: ```python def generate_cubed_numbers(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_cubed_numbers(n: int) -> List[int]: """ Generate a list of the first n cube numbers using a list comprehension. Args: n (int): The number of cube numbers to generate. Retur...
evol_instruct_66k
31,500
Write a Python function to implement the Sieve of Eratosthenes algorithm and find all the prime numbers within a given range [n, m]. The function should return a list of all prime numbers in the specified range. The code should start with: ```python from typing import List def find_primes_in_range(n: int, m: int) -> ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_primes_in_range(n: int, m: int) -> List[int]: """ Find all prime numbers within the given range [n, m] using the Sieve of Eratosthenes algorithm. Args: n (int): The lower bound of t...
evol_instruct_66k
31,510
Write a Python function to validate if a given string meets the criteria of being a linguistic unit. The criteria are: 1. The string must have a minimum of five characters. 2. The string must be constructed exclusively from lowercase components of the English alphabet. The function should return `True` if the string m...
Here is the Python code to solve the given problem in the markdown block: ```python import re def is_linguistic_unit(s: str) -> bool: """ Validate if a given string is a linguistic unit based on the following criteria: 1. The string must have a minimum of five characters. 2. The string must be construc...
evol_instruct_66k
31,562
Write a Python function to find the maximum of three numbers using a ternary conditional expression. The function should not use any prebuilt functions or methods (such as `max()`), and it should avoid using if-else statements. The code should start with: ```python def find_max_of_three(a: int, b: int, c: int) -> int: ...
Here is the Python code to solve the given problem in the markdown block: ```python def find_max_of_three(a: int, b: int, c: int) -> int: """ Find the maximum of three numbers using a ternary conditional expression. Args: a (int): The first number. b (int): The second number. c (int...
evol_instruct_66k
31,587
Write a Python function to return a new list with each item raised to the power of 3 from an existing list. The function should handle lists of integers and floats. The code should start with: ```python from typing import List def cube_list(lst: List[float]) -> List[float]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cube_list(lst: List[float]) -> List[float]: """ Returns a new list with each item in the input list raised to the power of 3. Args: lst (List[float]): The input list of numbers (integers...
evol_instruct_66k
31,591
Write a Python function to sort a list of mixed graphic-symbol characters in ascending ASCII value order using the Merge Sort algorithm. The function should be able to handle a list of characters that includes letters, digits, and special symbols. The code should start with: ```python from typing import List def sort_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_mixed_characters(data: List[str]) -> List[str]: """ Sorts a list of mixed graphic-symbol characters in ascending ASCII value order using the Merge Sort algorithm. Args: data (List[s...
evol_instruct_66k
31,597
Write a Python function to calculate the modulus of two positive integers `n1` and `n2`. The function should return the result of the modulus operation `n1 % n2`. The code should start with: ```python def calculate_modulus(n1: int, n2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_modulus(n1: int, n2: int) -> int: """ Calculate the modulus of two positive integers n1 and n2. Args: n1 (int): The dividend, a positive integer. n2 (int): The divisor, a positive integer. ...
evol_instruct_66k
31,598
Write a Python function to calculate the product of all odd elements in a given list of integers. The function should return the product as an integer. If the list contains no odd elements, the function should return 1. The code should start with: ```python from typing import List def product_of_odds(lst: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_odds(lst: List[int]) -> int: """ Calculate the product of all odd elements in the given list. Args: lst (List[int]): The list of integers from which to calculate the product o...
evol_instruct_66k
31,604
Write a Python function to find the longest common prefix among an array of strings. The function should be case-sensitive and should handle arrays containing up to 105 strings, each with up to 100 characters. The code should start with: ```python from typing import List def longest_common_prefix(strings: List[str]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def longest_common_prefix(strings: List[str]) -> str: """ Find the longest common prefix among an array of strings. Args: strings (List[str]): A list of strings to find the longest common pr...
evol_instruct_66k
31,647
Write a Python function to validate that a list of date strings are in strictly increasing order. The function should handle erroneous input by returning `False` if any date string is invalid. The function should also ensure that the dates are in the correct format (`YYYY-MM-DD`). 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 from datetime import datetime def validate_dates_in_order(date_list: List[str]) -> bool: """ Validates that a list of date strings are in strictly increasing order and are in the correct format (YYYY-MM-...
evol_instruct_66k
31,656
Write a Python function to generate a three-dimensional tensor with specified dimensions `x`, `y`, and `z`, where each element in the tensor is a stochastic value selected from a predefined list of integers ranging from 0 to 20. The function should return the generated tensor. The code should start with: ```python imp...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def generate_3d_tensor(x: int, y: int, z: int) -> np.ndarray: """ Generates a three-dimensional tensor with dimensions x, y, and z, where each element is a stochastic value selected from a predefined list...
evol_instruct_66k
31,661
Write a Python function that handles discretionary keyword attributes and universal pre-determined values while demonstrating competence in complex optional arguments manipulations. The function should accept three parameters: `parameter1`, `parameter2`, and `parameter3`. If `parameter2` is not provided, it should defa...
Here is the Python code to solve the given problem in the markdown block: ```python def specialized_method(parameter1, parameter2=None, parameter3="standard_value"): """ Manipulates the input parameters based on specific conditions and returns the modified values. Args: parameter1: The primary inpu...
evol_instruct_66k
31,663
Write a Python function to determine the minimum of five numbers without using the built-in `min` function. The function should compare the numbers manually to find the smallest one. The code should start with: ```python def find_min_of_five(a: int, b: int, c: int, d: int, e: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_min_of_five(a: int, b: int, c: int, d: int, e: int) -> int: """ Determine the minimum of five given integers without using the built-in min function. Args: a (int): The first integer. b (int): The s...
evol_instruct_66k
31,672
Write a Python function to transform a list of fruit names into a list of their corresponding uppercase versions. The function should handle any list of strings, not just fruit names. The code should start with: ```python from typing import List def transform_to_uppercase(input_list: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def transform_to_uppercase(input_list: List[str]) -> List[str]: """ Transforms a list of strings into a list of their corresponding uppercase versions. Args: input_list (List[str]): A list o...
evol_instruct_66k
31,697
Write a Python function to generate the Fibonacci sequence up to the n-th term using recursion. The function should handle cases where the input is not a positive integer and should ensure that the recursion limit is not exceeded. The function should start with: ```python def fibonacci_sequence(n: int) -> List[int]: ``...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import sys def fibonacci_sequence(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the n-th term using recursion. Args: n (int): The number of terms in the Fibonacci sequenc...
evol_instruct_66k
31,703
Write a Python function to determine if a given integer `y` is present in a dictionary's values. If `y` is found, print a message indicating its presence and terminate the search. The function should use a for loop to iterate through the dictionary's items and should not use a while loop or a tuple. The code should st...
Here is the Python code to solve the given problem in the markdown block: ```python def find_value_in_dictionary(dictionary: dict, y: int) -> None: """ Determines if the given integer `y` is present in the values of the provided dictionary. If found, prints a message indicating its presence and terminates t...
evol_instruct_66k
31,711
Write a Python function to find the longest common subsequence (LCS) among three given strings. The function should handle special characters, numerical values, and Unicode characters. It should also have a time complexity better than O(n^3). Additionally, the function should raise a `TypeError` with a descriptive erro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def longest_common_subsequence(x: str, y: str, z: str) -> int: """ Find the length of the longest common subsequence among three given strings. Args: x (str): The first string. y (s...
evol_instruct_66k
31,724
Write a Python function to apply a given mathematical operation to each element of a list and return the resulting list. The mathematical operation should be a function that takes a single argument and returns a single value. The function should be able to handle any list of integers and any mathematical operation that...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def apply_operation(data: List[int], operation: Callable[[int], int]) -> List[int]: """ Applies a given mathematical operation to each element of a list and returns the resulting list. Arg...
evol_instruct_66k
31,736
Write a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the LCS as a string. The code should start with: ```python def longest_common_subsequence(str1: str, str2: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def longest_common_subsequence(str1: str, str2: str) -> str: """ Finds the longest common subsequence (LCS) between two given strings. Args: str1 (str): The first input string. str2 (str): The second input s...
evol_instruct_66k
31,744
Write a Python function to generate a list of squares of numbers from 0 to n (inclusive) without using list comprehension, for loops, or the built-in `map()` function. Instead, use a recursive approach to build the list. The code should start with: ```python from typing import List def generate_squares(n: int) -> Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_squares(n: int) -> List[int]: """ Generate a list of squares of numbers from 0 to n (inclusive) using a recursive approach. Args: n (int): The upper limit (inclusive) for genera...
evol_instruct_66k
31,745
Write a Python function to compute the set difference between two sets. The function should take two sets as input and return a new set containing elements that are in the first set but not in the second set. The code should start with: ```python def set_difference(set1: set, set2: set) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python def set_difference(set1: set, set2: set) -> set: """ Compute the set difference between two sets. Args: set1 (set): The first set. set2 (set): The second set. Returns: set: A new set containing ...
evol_instruct_66k
31,754
Write a Python function to remove the highest number from a given string containing comma-separated numerical values and return a new string with the remaining values, retaining the comma delimiters. The function should handle the input string in a case-insensitive manner and ensure that the output string maintains the...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_max_num(str_nums: str) -> str: """ Removes the highest number from a given string containing comma-separated numerical values and returns a new string with the remaining values, retaining the comma delimiters. ...
evol_instruct_66k
31,773
Write a Python function to compute the Least Common Multiple (LCM) of two given integers using the Euclidean algorithm for finding the Greatest Common Divisor (GCD). The function should be efficient and clearly explain the logic path. The code should start with: ```python def compute_lcm(x: int, y: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def compute_lcm(x: int, y: int) -> int: """ Compute the Least Common Multiple (LCM) of two integers using the Euclidean algorithm for GCD. Args: x (int): The first integer. y (int): The second integer. ...
evol_instruct_66k
31,780
Write a Python function to segregate the elements of a given integer array into two distinct categories: even numbers and odd numbers. The function should return a tuple containing two lists: the first list should contain all the even numbers, and the second list should contain all the odd numbers. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def segregate_numbers(arr: List[int]) -> Tuple[List[int], List[int]]: """ Segregates the elements of a given integer array into even and odd numbers. Args: arr (List[int]): The input ...
evol_instruct_66k
31,782
Write a Python function to remove all occurrences of a specified character from a given string. The function should return the modified string. The code should start with: ```python def remove_character(string: str, char: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def remove_character(string: str, char: str) -> str: """ Removes all occurrences of a specified character from a given string. Args: string (str): The input string from which the character is to be removed. ...
evol_instruct_66k
31,786
Write a Python function to remove all spaces from a given string. The function should handle strings of varying lengths, including empty strings. The code should start with: ```python def remove_spaces(string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def remove_spaces(string: str) -> str: """ Removes all spaces from the given string. Args: string (str): The input string from which spaces are to be removed. Returns: str: The input string with all s...
evol_instruct_66k
31,791
Write a Python function to compose an HTTP POST request that transmits information to an API. The information must be conveyed in JSON format, encapsulating a unique identifier for the user (`user_id`) and a numerical score value (`score`). The function should return the JSON payload as a string. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python import json def compose_http_post_request(user_id: int, score: int) -> str: """ Composes an HTTP POST request payload in JSON format. Args: user_id (int): The unique identifier for the user. score (int): Th...
evol_instruct_66k
31,796
Write a Python function to sort the elements in an array from largest to smallest without using any built-in sort functions. The function should implement the Bubble Sort algorithm. The code should start with: ```python from typing import List def sort_descending(array: 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_descending(array: List[int]) -> List[int]: """ Sorts the elements in the given array from largest to smallest using the Bubble Sort algorithm. Args: array (List[int]): The array of ...
evol_instruct_66k
31,797
Write a Python function to find the length of the longest substring without repeating characters in a given string. The function should efficiently handle the input string and return the length of the longest substring with unique characters. The code should start with: ```python def length_of_longest_substring(s: str...
Here is the Python code to solve the given problem in the markdown block: ```python def length_of_longest_substring(s: str) -> int: """ Find the length of the longest substring without repeating characters in the given string. Args: s (str): The input string to analyze. Returns: int: T...
evol_instruct_66k
31,813
Write a Python function to pick a random word from a given list of strings, ensuring that the same word does not get chosen consecutively more than twice. The function should maintain a history of the last two chosen words to enforce this rule. The code should start with: ```python from typing import List import rando...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def get_random_word(words: List[str], last_two: List[str] = []) -> str: """ Picks a random word from a given list of strings, ensuring that the same word does not get chosen consecutively m...
evol_instruct_66k
31,822
Write a Python function to categorize a collection of dictionaries with a common key into distinct groups based on the value of that key. The function should return a dictionary where the keys are the distinct values of the common key and the values are lists of dictionaries that share the same value for that key. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def categorize_dictionaries(lst: List[Dict[str, Any]], key: str) -> Dict[Any, List[Dict[str, Any]]]: """ Categorizes a collection of dictionaries into distinct groups based on the value of a s...
evol_instruct_66k
31,823
Write a Python function to generate a dictionary from a given list where the keys are the elements of the list and the values are their corresponding indices. The function should handle lists of any length and ensure that the dictionary is correctly formed. 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, Dict def list_to_dict(lst: List[str]) -> Dict[str, int]: """ Generates a dictionary from a list of strings where each string is a key and its index is the value. Args: lst (List[str]): The ...
evol_instruct_66k
31,826
Write a Python function to verify if a 2D array has mirrored pairs both horizontally and vertically. A mirrored pair means that the array is symmetric both horizontally and vertically. The array dimension should remain within 10x10. The code should start with: ```python from typing import List def is_mirrored_array(a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_mirrored_array(arr: List[List[int]]) -> bool: """ Verify if a 2D array has mirrored pairs both horizontally and vertically. Args: arr (List[List[int]]): The 2D array to be checked. ...
evol_instruct_66k
31,856
Write a Python function to count the frequency of distinct non-vowel alphabetic characters in a given alphanumeric ASCII text sequence. The function should return a dictionary where the keys are the non-vowel alphabetic characters and the values are their respective frequencies. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict from collections import Counter def count_non_vowel_characters(text: str) -> Dict[str, int]: """ Count the frequency of distinct non-vowel alphabetic characters in the given text. Args: text...
evol_instruct_66k
31,877
Write a Python function to find the maximum value in the specified n'th column of a given matrix, where the matrix is represented as a list of lists. The function should handle matrices of varying sizes and ensure that the specified column index is within the bounds of the matrix. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_value_in_column(matrix: List[List[int]], n: int) -> int: """ Find the maximum value in the specified n'th column of a given matrix. Args: matrix (List[List[int]]): A 2D list represen...
evol_instruct_66k
31,912
Write a Python function to print the elements of a given list in a specific format. Each element should be printed on a new line, followed by its index in the list. The index should be zero-based and enclosed in parentheses. The code should start with: ```python from typing import List def print_elements_with_index(i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_elements_with_index(input_list: List[int]) -> None: """ Prints each element of the input list followed by its index in parentheses. Args: input_list (List[int]): The list of intege...
evol_instruct_66k
31,913
Write a Python function to determine if a given integer is an even number. The function should return `True` if the number is even and `False` otherwise. The code should start with: ```python def is_num_even(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_num_even(num: int) -> bool: """ Determines if a given integer is an even number. Args: num (int): The integer to check for evenness. Returns: bool: True if the number is even, False otherwise. ...
evol_instruct_66k
31,915
Write a Python function to create a two-dimensional matrix of dimensions `n` by `m` populated solely with zero values. The function should handle cases where `n` or `m` are zero, and it should return an empty list in such cases. The code should start with: ```python from typing import List def create_zero_matrix(n: in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_zero_matrix(n: int, m: int) -> List[List[int]]: """ Create a two-dimensional matrix of dimensions n by m filled with zero values. Args: n (int): The number of rows in the matrix. ...
evol_instruct_66k
31,923
Write a Python function to parse and validate URLs according to the specified formats, and extract the following components: protocol, domain, path, query parameters (as key-value pairs), and fragment. The function should return a dictionary with these components. The dictionary should handle cases where any of these c...
Here is the Python code to solve the given problem in the markdown block: ```python import re def parse_url(url_str: str) -> dict: """ Parses and validates a URL according to specified formats, and extracts the following components: protocol, domain, path, query parameters (as key-value pairs), and fragmen...
evol_instruct_66k
31,935
Write a Python function to generate a sequence of numbers from 1 to a given positive integer `n`, inclusive. The function should return a list of these numbers. Ensure that the function handles edge cases such as `n` being zero or negative. The code should start with: ```python from typing import List def generate_se...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_sequence(n: int) -> List[int]: """ Generate a sequence of numbers from 1 to n (inclusive). Args: n (int): The upper limit of the sequence. Returns: List[int]: A lis...
evol_instruct_66k
31,943
Write a Python function to sort a list of strings alphabetically, considering both case-sensitive and case-insensitive sorting. The function should return a tuple containing two lists: the first list sorted in a case-sensitive manner, and the second list sorted in a case-insensitive manner. 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 sort_strings(strings: List[str]) -> Tuple[List[str], List[str]]: """ Sorts a list of strings alphabetically in both case-sensitive and case-insensitive manners. Args: strings (Lis...
evol_instruct_66k
31,945
Write a Python function to compare two strings for equality and provide the index positions where the two strings differ. The function should handle case sensitivity and report differences even if the strings are of different lengths. The function should return a list of indices where the characters in the two strings ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compare_strings(str1: str, str2: str) -> List[int]: """ Compares two strings and returns a list of indices where the characters in the two strings differ. Handles case sensitivity and differences...
evol_instruct_66k
31,947
Write a Python function to determine if a given string is a valid IPv4 address. An IPv4 address is a string that consists of four decimal numbers, each ranging from 0 to 255, separated by dots. The function should return `True` if the string is a valid IPv4 address, and `False` otherwise. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_ipv4(ip: str) -> bool: """ Determines if the given string is a valid IPv4 address. Args: ip (str): The string to be checked for IPv4 validity. Returns: bool: True if the string is a valid I...
evol_instruct_66k
31,957
Write a Python function to calculate the cumulative total of all elements in a given list of integers. The function should return the cumulative total as an integer. The code should start with: ```python from typing import List def calculate_cumulative_total(array: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_cumulative_total(array: List[int]) -> int: """ Calculate the cumulative total of all elements in a given list of integers. Args: array (List[int]): A list of integers for which...
evol_instruct_66k
31,961
Write a Python function to filter out an array of strings and return only those strings that contain prime numbers. The function should use the Sieve of Eratosthenes algorithm to generate a list of prime numbers up to a certain limit and then check if any of these prime numbers are substrings of the input strings. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sieve_of_eratosthenes(n: int) -> List[int]: """ Generate a list of prime numbers up to a given limit using the Sieve of Eratosthenes algorithm. Args: n (int): The upper limit for generat...
evol_instruct_66k
31,962
Write a Python function to determine if a given string contains only digits. The function should return `True` if the string consists entirely of numeric characters, and `False` otherwise. The code should start with: ```python def contains_only_digits(input_string: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def contains_only_digits(input_string: str) -> bool: """ Determines if the given string contains only digits. Args: input_string (str): The string to be checked. Returns: bool: True if the string contai...
evol_instruct_66k
31,968
Write a Python function to convert a measurement of pressure from atmospheres (atm) to pascals (Pa). The conversion factor from atmospheres to pascals is 1 atm = 101325 Pa. The function should take a single argument representing the pressure in atmospheres and return the pressure in pascals. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_atm_to_pa(atm: float) -> float: """ Convert a measurement of pressure from atmospheres (atm) to pascals (Pa). Args: atm (float): The pressure in atmospheres. Returns: float: The pressure in ...
evol_instruct_66k
31,971
Write a Python function to implement a sorting algorithm for an array of integer elements that only needs one iteration. The algorithm should handle potential duplicates and negative numbers in the array. The code should start with: ```python from typing import List def one_pass_sort(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 one_pass_sort(arr: List[int]) -> List[int]: """ Sorts an array of integers in one iteration using a counting sort-like approach. Args: arr (List[int]): The array of integers to be sorted...