source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_evol_110k
79,713
Write a Python function to calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm. The function should be efficient and handle both positive and negative integers. The code should start with: ```python def gcd(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def gcd(a: int, b: int) -> int: """ Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm. Args: a (int): The first integer. b (int): The second integer. Returns: ...
magic_evol_110k
79,762
Write a Python function to generate and yield the first N numbers in the Fibonacci sequence using a generator. The Fibonacci sequence is defined such that each number is the sum of the two preceding ones, starting from 0 and 1. The function should start with: ```python def generate_fibonacci_sequence(n: int): ```
Here is the Python code to solve the given problem in the markdown block: ```python def generate_fibonacci_sequence(n: int): """ Generates the first N numbers in the Fibonacci sequence using a generator. Args: n (int): The number of Fibonacci numbers to generate. Yields: int: The next ...
magic_evol_110k
79,777
Write a Python function to calculate the sum of all integer elements in a given list, while ignoring any non-integer elements. The function should handle lists containing various data types, including integers, strings, floats, and other non-integer types. 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, Union def sum_of_integers(my_list: List[Union[int, float, str]]) -> int: """ Calculate the sum of all integer elements in a given list, ignoring any non-integer elements. Args: my_list (Lis...
magic_evol_110k
79,831
Write a Python function to separate even and odd numbers from a given list and return them in two separate lists. The function should be efficient and able to handle large lists of up to 10,000 numbers, including negative, zero, and duplicate values. The code should start with: ```python from typing import List, Tuple ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def separate_even_odd(numbers: List[int]) -> Tuple[List[int], List[int]]: """ Separates even and odd numbers from a given list and returns them in two separate lists. Args: numbers (L...
magic_evol_110k
79,833
Write a Python function to calculate the critical maximal speed \( V_{Hexagon} \) of the runner in a game of chase within a regular hexagon-shaped pool. The swimmer starts at the center of the hexagon, and the runner starts at the midpoint of one of the hexagon's edges. The critical speed is the threshold below which t...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def calculate_v_hexagon(radius: float) -> float: """ Calculate the critical maximal speed V_Hexagon of the runner in a hexagon-shaped pool. Args: radius (float): The radius of the circumscribed c...
magic_evol_110k
79,846
Write a Python function to extract and magnify words from a given list of strings that contain dual vowel clusters. A dual vowel cluster is defined as two consecutive vowels (a, e, i, o, u) in a word. The function should return a list of these magnified words in uppercase. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def magnify_dual_vowel_words(words: List[str]) -> List[str]: """ Extracts and magnifies words from a given list of strings that contain dual vowel clusters. Args: words (List[str])...
magic_evol_110k
79,853
Write a Python function to replace each element of a given array with its square and return the result. The function should not use built-in functions like `map()`, `**`, or `pow()` to perform the squaring operation. The function should start with: ```python from typing import List def square_elements(arr: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def square_elements(arr: List[int]) -> List[int]: """ Replace each element of the given array with its square and return the result. Args: arr (List[int]): The array of integers to be square...
magic_evol_110k
79,854
Write a Python function to determine if a specific substring exists within a larger text string. The function should return a binary outcome (True or False). The function should handle edge cases such as empty strings and substrings, and should be efficient in its operation. The code should start with: ```python def s...
Here is the Python code to solve the given problem in the markdown block: ```python def substring_exists(string: str, substring: str) -> bool: """ Determines if a specific substring exists within a larger text string. Args: string (str): The larger text string in which to search for the substring. ...
magic_evol_110k
79,865
Write a Python function to shuffle a given list of floating-point numbers in place. The function should use the Fisher-Yates (Knuth) shuffle algorithm to ensure a uniform random permutation of the list. The code should start with: ```python from typing import List import random def shuffle_list(input_list: List[float]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def shuffle_list(input_list: List[float]) -> None: """ Shuffles the given list of floating-point numbers in place using the Fisher-Yates (Knuth) shuffle algorithm. Args: input_...
magic_evol_110k
79,870
Write a Python function to print out a list of numbers from a given list along with their corresponding squares. The output should be presented as a list of tuples where the first element of each tuple corresponds to a number from the input list and the second element corresponds to the square of that number. The funct...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def print_numbers_with_squares(numbers: List[int]) -> List[Tuple[int, int]]: """ Prints out a list of numbers from a given list along with their corresponding squares. Args: numbers (...
magic_evol_110k
79,878
Write a Python function to format a provided list of numbers with periods as decimal markers and commas as thousands separators. The function should handle both integers and floating-point numbers. For floating-point numbers, the function should format them to two decimal places. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def format_numbers(numbers: List[float]) -> List[str]: """ Formats a list of numbers with periods as decimal markers and commas as thousands separators. Args: numbers (List[float]): A list o...
magic_evol_110k
79,879
Write a Python function to create an NxN matrix filled with sequential numbers starting from 0 to N^2 - 1, rotate the matrix 90 degrees clockwise, and then check if the rotated matrix is symmetrical. The function should return `True` if the rotated matrix is symmetrical, otherwise `False`. 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 create_and_check_matrix(n: int) -> bool: """ Creates an NxN matrix filled with sequential numbers starting from 0 to N^2 - 1, rotates the matrix 90 degrees clockwise, and checks if the rotated ma...
magic_evol_110k
79,888
Write a Python function to print each unique letter from a given string, one by one on a new line, in alphabetical order, and disregarding case sensitivity. The function should not return any value but should print the letters directly. The code should start with: ```python def print_unique_letters(input_string: str) ...
Here is the Python code to solve the given problem in the markdown block: ```python def print_unique_letters(input_string: str) -> None: """ Prints each unique letter from the given string, one by one on a new line, in alphabetical order, and disregarding case sensitivity. Args: input_string (str):...
magic_evol_110k
79,894
Write a Python function to find the sorted unique common elements between two lists without using built-in Python list functions like `set`, `sorted`, or `intersection`. The function should use a custom sorting algorithm (e.g., insertion sort) to sort the resulting list and a custom method to remove duplicates. The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_sort(lst: List[int]) -> List[int]: """ Perform a custom sort (insertion sort) on the given list. Args: lst (List[int]): The list to be sorted. Returns: List[int]: The...
magic_evol_110k
79,899
Write a Python function to find the smallest disparity between any pair of elements within a provided array. The function should efficiently traverse the array and compare elements to determine the minimum difference. The code should start with: ```python from typing import List def find_min_difference(arr: List[int])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_min_difference(arr: List[int]) -> int: """ Find the smallest disparity between any pair of elements within a provided array. Args: arr (List[int]): The array of integers to analyze....
magic_evol_110k
79,905
Write a Python function to create two new arrays of integers which contain the sums of corresponding elements of two existing arrays and the differences, respectively. The function should handle arrays of different lengths by taking the minimum length of the two arrays for the calculations. 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 calculate_sums_and_differences(arr1: List[int], arr2: List[int]) -> (List[int], List[int]): """ Calculate the sums and differences of corresponding elements of two arrays. Args: arr1 (Li...
magic_evol_110k
79,911
Write a Python function to randomly select a word from a given list of words. The function should ensure that each word has an equal probability of being selected. The code should start with: ```python from typing import List import random def select_random_word(words: List[str]) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def select_random_word(words: List[str]) -> str: """ Randomly selects a word from a given list of words. Args: words (List[str]): A list of words from which to select a random ...
magic_evol_110k
79,935
Write a Python function to find the median of a list of numbers. The function should be able to handle both sorted and unsorted lists, duplicate entries, and lists of both odd and even lengths. The function should be efficient, sorting the list and determining the median in the best possible time complexity. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_median(num_list: List[int]) -> float: """ Find the median of a list of numbers. Args: num_list (List[int]): The list of numbers from which to find the median. Returns: ...
magic_evol_110k
79,952
Write a Python function to list all available AWS services and randomly select one service from the list. The function should return the selected service as a string. Additionally, provide a sample code showcase for the selected service if it matches a specific service (e.g., 'S3'). The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional import random def select_aws_service(aws_services: List[str]) -> Optional[str]: """ Selects a random AWS service from the provided list and optionally prints a sample code showcase for a specif...
magic_evol_110k
79,962
Write a Python function that takes a string as input and returns the total number of characters in the string along with a dictionary containing the count of each unique character (ignoring case sensitivity). The function should handle special characters and white spaces. The code should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple def analyze_string(s: str) -> Tuple[int, Dict[str, int]]: """ Analyzes the given string to return the total number of characters and a dictionary containing the count of each unique character ...
magic_evol_110k
79,971
Write a Python function to remove all duplicate elements from a given list while preserving the original order of the elements. The function should take a list of integers as input and return a new list with all duplicates removed. The code should start with: ```python from typing import List def remove_duplicates_pre...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_preserve_order(input_list: List[int]) -> List[int]: """ Removes all duplicate elements from the given list while preserving the original order. Args: input_list (List[i...
magic_evol_110k
79,974
Write a Python function to transform the key-value pairs of a dictionary into a new list of strings. Each string in the list should be formatted as `key:value`. The function should handle dictionaries with various types of values, including strings, integers, floats, and lists. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Any def transform_dict_to_list(dictionary: Dict[str, Any]) -> List[str]: """ Transforms the key-value pairs of a dictionary into a new list of strings. Each string in the list is formatted as ...
magic_evol_110k
79,984
Write a Python function to determine the letter grade of a pupil based on their numerical score using a ternary operator. The grading scale is as follows: - 'A' for scores 90 and above - 'B' for scores 80-89 - 'C' for scores 70-79 - 'D' for scores 60-69 - 'F' for scores below 60 The function should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python def get_letter_grade(num_grade: int) -> str: """ Determine the letter grade of a pupil based on their numerical score using a ternary operator. Args: num_grade (int): The numerical score of the pupil. Returns: ...
magic_evol_110k
80,018
Write a Python function to determine if each string in a list of lexical entries is a palindrome. The function should handle potential discontinuities such as spaces, punctuation, and case sensitivity. The solution should optimize for space complexity by using no additional data structures to store intermediate values....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def clean_string(s: str) -> str: """ Normalizes the input string by converting it to lowercase and removing all non-alphanumeric characters. Args: s (str): The input string to be normalized....
magic_evol_110k
80,026
Write a Python function to remove duplicate elements from a given list while preserving the order of the first occurrence of each element. The function should be efficient and handle various types of input lists, including empty lists and lists with all unique elements. 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 def remove_duplicates_preserve_order(arr: List[int]) -> List[int]: """ Removes duplicate elements from the given list while preserving the order of the first occurrence of each element. Args: ...
magic_evol_110k
80,051
Write a Python function that takes two lists as input: one list of base numbers and another list of corresponding exponents. The function should return a new list where each element is the result of raising the corresponding base number to the power of its corresponding exponent. If the two lists are not of the same le...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def list_powers(base_list: List[int], exponent_list: List[int]) -> List[int] or str: """ Raises each base number in the base_list to the power of its corresponding exponent in the exponent_list. Arg...
magic_evol_110k
80,053
Write a Python function to convert a given number of megabytes into its equivalent byte representation using both the decimal and binary conventions. The function should include two sub-functions: - `decimal_megabytes_to_bytes(megabytes: float) -> int`: Converts a given number of megabytes (using the decimal convention...
Here is the Python code to solve the given problem in the markdown block: ```python def decimal_megabytes_to_bytes(megabytes: float) -> int: """ Convert a given number of megabytes (decimal convention) to bytes. Args: megabytes (float): The number of megabytes to convert. Returns: int:...
magic_evol_110k
80,059
Write a Python function to calculate the product of all integers in a nested list, regardless of the depth of nesting. The function should raise a `TypeError` if the input is not a list or if any element within the nested list is not an integer. The function should be implemented using recursion and should not use any ...
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_nested_numbers(lst): """ Calculate the product of all integers in a nested list, regardless of the depth of nesting. Args: lst (list): A nested list of integers. Returns: int: The product o...
magic_evol_110k
80,067
Write a Python function to calculate the sum of two integers, `number1` and `number2`, and return the result. The function should handle any integer inputs and ensure that the sum is correctly computed. The code should start with: ```python def sum_of_two_numbers(number1: int, number2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_two_numbers(number1: int, number2: int) -> int: """ Calculate the sum of two integers. Args: number1 (int): The first integer. number2 (int): The second integer. Returns: int: The sum...
magic_evol_110k
80,076
Write a Python function to remove any even digits from a given number and display the remaining odd digits in descending order. The function should handle edge cases such as negative integers and zero. The solution should not use the built-in sort function and should be efficient. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_even_and_sort_desc(n: int) -> int: """ Removes any even digits from a given number and displays the remaining odd digits in descending order. Args: n (int): The input number from which to remove even digi...
magic_evol_110k
80,084
Write a Python function to append an element to an existing list and return the modified list. The function should handle the case where the element to be appended is not a list itself. Additionally, ensure that the function does not modify the original list but returns a new list with the appended element. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def append_element_to_list(original_list: List[Any], element: Any) -> List[Any]: """ Appends an element to an existing list and returns the modified list without modifying the original list. Ar...
magic_evol_110k
80,094
Write a Python function to find all numerical values starting specifically with the integer 8 from a given text string using a corrected regex pattern. The pattern should only detect numbers starting with the integer 8 and should exclude any numbers starting with 8 but having any non-numerical values immediately follow...
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def find_numbers_starting_with_8(text: str) -> List[str]: """ Find all numerical values starting specifically with the integer 8 from a given text string. The pattern should only detect num...
magic_evol_110k
80,112
Write a Python function to calculate the sum of two integers and print the result. The function should take two integer arguments and return the sum. Additionally, the function should print the sum to the console. The code should start with: ```python def sum_and_print(num1: int, num2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_and_print(num1: int, num2: int) -> int: """ Calculate the sum of two integers and print the result. Args: num1 (int): The first integer. num2 (int): The second integer. Returns: int: The...
magic_evol_110k
80,116
Write a Python function `checkNumber` that takes two arguments: `number` and `factor`. The function should check if the given `number` is divisible by the `factor` and return a boolean value indicating the result. The function should also handle cases where `factor` is zero by returning `False`. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def checkNumber(number: int, factor: int) -> bool: """ Check if the given number is divisible by the specified factor. Args: number (int): The number to be checked for divisibility. factor (int): The factor ...
magic_evol_110k
80,120
Write a Python function to compare two entities based on a given quantitative measure and return a numerical result according to the following rules: - Return `0` if the quantitative measures of both entities are equal. - Return a positive integer if the first entity's measure is greater than the second entity's measur...
Here is the Python code to solve the given problem in the markdown block: ```python def compare_entities(measure1: float, measure2: float) -> int: """ Compares two entities based on a given quantitative measure and returns a numerical result. Args: measure1 (float): The quantitative measure of the ...
magic_evol_110k
80,142
Write a Python function to determine the occupation of the second character in a given list of dictionaries. Each dictionary contains information about a character, including their name and occupation. The function should return the occupation of the second character in the list. 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, Dict def find_second_character_occupation(characters: List[Dict[str, str]]) -> str: """ Determines the occupation of the second character in a given list of dictionaries. Args: characters (...
magic_evol_110k
80,172
Write a Python function to verify if all the elements in a given 2D array are in ascending order row-wise, column-wise, and diagonally. The function should also check for both the primary and secondary diagonal order in case of a square matrix. Include handling for an empty input and edge cases of single-element 2D arr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def verify_ascending_order(arr: List[List[int]]) -> bool: """ Verify if all elements in a given 2D array are in ascending order row-wise, column-wise, and diagonally. Also, check for both the primary...
magic_evol_110k
80,173
Write a Python function to sort a list of fruit names in ascending lexicographic order and return the sorted list. The function should handle an empty list gracefully and return an empty list in such cases. The code should start with: ```python from typing import List def sort_fruits(fruits: List[str]) -> List[str]: `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_fruits(fruits: List[str]) -> List[str]: """ Sorts a list of fruit names in ascending lexicographic order. Args: fruits (List[str]): A list of fruit names to be sorted. Returns:...
magic_evol_110k
80,179
Write a Python function to determine if a given integer is a prime number. The function should rigorously check for the absence of divisors other than 1 and the number itself, ensuring that the function is efficient by only checking up to the square root of the number. The code should start with: ```python def is_prim...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime_number(n: int) -> bool: """ Determines if a given integer is a prime number. Args: n (int): The integer to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
magic_evol_110k
80,187
Write a Python function to calculate the maximum number of apple pies that can be baked given a certain number of boxes of apples, the number of apples in each box, and the number of apples required to bake one apple pie. The function should return the total number of apple pies that can be baked. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_max_apple_pies(boxes: int, apples_per_box: int, apples_per_pie: int) -> int: """ Calculate the maximum number of apple pies that can be baked given the number of boxes of apples, the number of apples in each bo...
magic_evol_110k
80,195
Write a Python function to determine if a given character is present in a specified string. The function should return a boolean value indicating whether the character is found in the string. The code should start with: ```python def is_character_in_string(character: str, word: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_character_in_string(character: str, word: str) -> bool: """ Determines if a given character is present in a specified string. Args: character (str): The character to search for in the string. word (st...
magic_evol_110k
80,209
Write a Python function to determine if at least one element from the second vector is present in the first vector. The function should return `True` if there is at least one common element, otherwise it should return `False`. The function should be efficient and handle edge cases such as empty vectors. The code shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def has_common_element(vector1: List[int], vector2: List[int]) -> bool: """ Determines if there is at least one common element between two vectors. Args: vector1 (List[int]): The first vecto...
magic_evol_110k
80,210
Write a Python function to find the least negative value in a given array of negative integers. The function should return the least negative value, which is the maximum value among the negative integers. The code should start with: ```python from typing import List def least_negative_value(numbers: List[int]) -> int:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def least_negative_value(numbers: List[int]) -> int: """ Finds the least negative value in a given array of negative integers. Args: numbers (List[int]): A list of negative integers. Re...
magic_evol_110k
80,214
Write a Python function to generate an updated list by multiplying each element in a given list by a specified factor. The function should handle lists of integers and return a new list with the updated values. The code should start with: ```python from typing import List def multiply_list_elements(original_list: List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def multiply_list_elements(original_list: List[int], factor: int) -> List[int]: """ Generate an updated list by multiplying each element in the given list by the specified factor. Args: orig...
magic_evol_110k
80,220
Write a Python function to process two lists based on a sequence of operations specified in a third list. The operations can include merging the lists, finding common elements, unique elements, sorting in descending order, calculating element differences, length of lists, sum of elements, average of elements, maximum a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union import statistics import math def process_lists(list1: List[Union[int, float, str, List]], list2: List[Union[int, float, str, List]], operations: List[str]) -> List[Union[List, str]]: """ Process ...
magic_evol_110k
80,229
Write a Python function to merge two dictionaries together by updating the value of common keys. If a key exists in both dictionaries, the value from the second dictionary should overwrite the value in the first dictionary. If a key exists only in one dictionary, it should be added to the merged dictionary with its cor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def merge_dictionaries(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]: """ Merges two dictionaries together by updating the value of common keys. Args: dict1 (Dict[str, int]...
magic_evol_110k
80,232
Write a Python function that processes a list of elements, squares each numeric element, and stores the results in a new list. The function should use a `while` loop instead of a `for` loop and include error handling to manage potential exceptions, such as encountering a non-numeric value in the list. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def square_numeric_elements(arr: List[int]) -> List[int]: """ Squares each numeric element in the input list and returns a new list containing the squared values. Non-numeric elements are skipped, an...
magic_evol_110k
80,238
Write a Python function to determine if the elements of a given multidimensional array form a palindrome. The function should handle both single-dimensional and multidimensional arrays. A multidimensional array is considered a palindrome if, when flattened, the sequence of elements reads the same forward and backward. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def is_palindrome_multidimensional(arr: Union[List[Union[int, float]], List[List[Union[int, float]]]]) -> bool: """ Determine if the elements of a given multidimensional array form a palindrome. ...
magic_evol_110k
80,271
Write a Python function to create a dictionary where the keys are integers from 1 to `n` (inclusive) and the values are their corresponding square roots. The function should use dictionary comprehension for efficiency. The code should start with: ```python import math def create_square_root_dict(n: int) -> dict: ```
Here is the Python code to solve the given problem in the markdown block: ```python import math def create_square_root_dict(n: int) -> dict: """ Creates a dictionary where the keys are integers from 1 to n (inclusive) and the values are their corresponding square roots. Args: n (int): The upper li...
magic_evol_110k
80,272
Write a Python function to sort a given list of integers in ascending order without using built-in sorting functions or libraries. Additionally, write a function to check if the sorted list forms an Arithmetic Progression (AP). If it does, return the common difference of the AP. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sort_and_check_arithmetic(lst: List[int]) -> Tuple[List[int], bool, int]: """ Sorts the given list of integers in ascending order and checks if the sorted list forms an Arithmetic Progression....
magic_evol_110k
80,274
Write a Python function to count the occurrences of each element in a given sequence and return the result as a dictionary. The function should handle any iterable sequence (e.g., list, tuple, string) and should be efficient in terms of both time and space complexity. The code should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Iterable def count_occurrences(seq: Iterable) -> Dict[any, int]: """ Counts the occurrences of each element in a given sequence and returns the result as a dictionary. Args: seq (Iterable):...
magic_evol_110k
80,289
Write a Python function to print numbers from 0 to n (inclusive) using a for loop with list comprehension, and also find the sum of all even numbers in that range. The function should return the sum of the even numbers. The code should start with: ```python def print_numbers_and_sum_evens(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def print_numbers_and_sum_evens(n: int) -> int: """ Prints numbers from 0 to n (inclusive) and returns the sum of all even numbers in that range. Args: n (int): The upper limit of the range (inclusive). Returns...
magic_evol_110k
80,303
Write a Python function to replace all empty strings in a given list with default values based on the length of the preceding element. The function should also count the number of times each default value is used. The default values are: 1. "not_specified" - Use this default value if the preceding element of the list c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def replace_empty_strings(my_list: List[str]) -> Tuple[List[str], int, int]: """ Replace all empty strings in the given list with default values based on the length of the preceding element. A...
magic_evol_110k
80,309
Write a Python function to calculate the sum of all integers within a given list that fall within the range 1 to 100 (inclusive). The function should filter out any numbers outside this range and any non-integer values before computing the sum. The function should handle edge cases such as an empty list and non-integer...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_in_valid_range(numbers: List[int]) -> int: """ Calculate the sum of all integers within the range 1 to 100 (inclusive) from a given list. Args: numbers (List[int]): A list of integer...
magic_evol_110k
80,312
Write a Python function to compute the average of the numbers in a given list. The function should handle lists of integers and floating-point numbers. If the list is empty, the function should return `None`. The code should start with: ```python from typing import List, Optional def compute_average(numbers: List[floa...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def compute_average(numbers: List[float]) -> Optional[float]: """ Computes the average of the numbers in the given list. Args: numbers (List[float]): The list of numbers (integers ...
magic_evol_110k
80,323
Write a Python function to find the maximum element in a rotated sorted array that may contain duplicates. The array is sorted in descending order and rotated between 1 and `n` times, where `n` is the length of the array. The function should not use any in-built functions or libraries, and it should only use loops and ...
Here is the Python code to solve the given problem in the markdown block: ```python def find_max_in_rotated_sorted_array(nums: list) -> int: """ Find the maximum element in a rotated sorted array that may contain duplicates. Args: nums (list): A list of integers representing the rotated sorted arra...
magic_evol_110k
80,336
Write a Python function to generate and return the first `n` rows of Pascal's Triangle as a list of lists. Each inner list represents a row in the triangle. The function should start with: ```python from typing import List def generate_pascals_triangle(n: int) -> List[List[int]]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_pascals_triangle(n: int) -> List[List[int]]: """ Generate the first n rows of Pascal's Triangle. Args: n (int): The number of rows to generate. Returns: List[List[i...
magic_evol_110k
80,359
Write a Python function to remove all vowels (both uppercase and lowercase) from a given string. The function should return the modified string without any vowels. The code should start with: ```python def remove_vowels(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def remove_vowels(s: str) -> str: """ Removes all vowels (both uppercase and lowercase) from the given string. Args: s (str): The input string from which vowels are to be removed. Returns: str: The mo...
magic_evol_110k
80,363
Write a Python function to validate email addresses that end with specific top-level domains (TLDs) such as `.edu`, `.gov`, and international TLDs (non `.com` TLDs). The function should ensure that it does not match subdomains or parent domains attached to the specified TLDs. The function should be efficient and use re...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_email(email: str) -> bool: """ Validates email addresses that end with specific top-level domains (TLDs) such as .edu, .gov, and international TLDs (non .com TLDs). Ensures that the email does not mat...
magic_evol_110k
80,370
Write a Python function to filter out prime positive numbers from a given array. The function should return a list of prime positive numbers found in the input array. The code should start with: ```python from typing import List def filter_prime_positive_numbers(numbers: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def 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. """ if n <...
magic_evol_110k
80,374
Write a Python function to generate a unique nine-symbol code using exclusively the characters from the 16-unit hexadecimal system, ensuring that the code strictly adheres to alphanumeric criteria. The function should allow for customization of the code length and should ensure that the generated code is unique by chec...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_unique_code(length: int = 9, existing_codes: List[str] = []) -> str: """ Generates a unique nine-symbol code using exclusively the characters from the 16-unit hexadecimal syste...
magic_evol_110k
80,402
Write a Python function to construct a NumPy array that consists of a specified number of instances of a negative integer followed by a specified number of instances of a positive integer. The function should take three parameters: the negative integer, the number of times it should be repeated, the positive integer, a...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def construct_array(negative_int: int, num_negative: int, positive_int: int, num_positive: int) -> np.ndarray: """ Constructs a NumPy array consisting of a specified number of instances of a negative integer ...
magic_evol_110k
80,414
Write a Python function to remove trailing spaces and newline characters from a given string while preserving any special characters or digits that may appear in the string. The function should handle various edge cases, such as strings with no trailing spaces or newlines, strings with only trailing spaces or newlines,...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_trailing_spaces_newlines(string: str) -> str: """ Removes trailing spaces and newline characters from the given string. Args: string (str): The input string from which to remove trailing spaces and newlin...
magic_evol_110k
80,421
Write a Python function to sort a list of numerical values based on their divisibility characteristics with a specific number. The function should return a list of numbers from the input list that are divisible by the specified number, sorted in ascending order. 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_by_divisibility(numbers: List[int], divisible_number: int) -> List[int]: """ Sorts a list of numerical values based on their divisibility characteristics with a specific number. Args: ...
magic_evol_110k
80,434
Write a Python function to simulate a simple button's appearance settings using a dictionary. The function should take a dictionary representing the button's initial appearance settings and modify it according to predefined rules. The predefined rules are: 1. If the button's style is set to "Flat", change the border st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def modify_button_appearance(button_settings: Dict[str, str]) -> Dict[str, str]: """ Modifies the appearance settings of a button based on predefined rules. Args: button_settings (Dict[str, ...
magic_evol_110k
80,442
Write a Python function to remove a specified item from a given tuple and return a new tuple without that item. If the item is not found in the tuple, the function should return the original tuple. The function should handle the immutability of tuples by converting the tuple to a list, removing the item, and then conve...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_from_tuple(tup: tuple, item: any) -> tuple: """ Removes a specified item from a given tuple and returns a new tuple without that item. If the item is not found in the tuple, the original tuple is returned. Ar...
magic_evol_110k
80,445
Write a Python function to calculate the minimum and maximum values in a given array without using built-in functions `min()` and `max()`. The function should iterate through the array to find the minimum and maximum values. The code should start with: ```python from typing import List, Tuple def find_min_max(arr: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_min_max(arr: List[int]) -> Tuple[int, int]: """ Calculate the minimum and maximum values in a given array without using built-in functions min() and max(). Args: arr (List[in...
magic_evol_110k
80,448
Write a Python function to calculate the maximum amount of water that can be trapped between the bars of a given list of non-negative integers representing the heights of the bars. Each bar has a width of 1 unit. The function should return the total amount of water trapped. 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 trap_water(heights: List[int]) -> int: """ Calculate the maximum amount of water that can be trapped between the bars of a given list of non-negative integers. Args: heights (List[int]):...
magic_evol_110k
80,456
Write a Python function to calculate the nth term of a geometric progression given the initial term, the common ratio, and the position of the term. The function should handle both positive and negative common ratios and positions. The code should start with: ```python def nth_term_of_geometric_progression(initial_term...
Here is the Python code to solve the given problem in the markdown block: ```python def nth_term_of_geometric_progression(initial_term: float, common_ratio: float, n: int) -> float: """ Calculate the nth term of a geometric progression. Args: initial_term (float): The initial term of the geometric ...
magic_evol_110k
80,457
Write a Python function that takes a list of integers as input and returns a list of their absolute values sorted in ascending order. The function should handle both positive and negative integers, ensuring that the absolute values are sorted correctly. The code should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sorted_absolute_values(numbers: List[int]) -> List[int]: """ Returns a list of absolute values of the given integers, sorted in ascending order. Args: numbers (List[int]): A list of inte...
magic_evol_110k
80,470
Write a Python function to find the first non-duplicate character in a given string along with its index. The function should be case-sensitive and consider special characters. If no non-duplicate character is found, the function should return `None` for both the character and the index. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python def find_first_non_duplicate(s: str) -> tuple: """ Finds the first non-duplicate character in the given string along with its index. Args: s (str): The input string to search for the first non-duplicate character. ...
magic_evol_110k
80,493
Write a Python function that takes an iterable and a type constructor (e.g., `list`, `set`, `tuple`) and returns a new iterable of the specified type, containing the elements of the original iterable. The function should be type-annotated to ensure type safety. 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 Iterable, Type, Any def cast_iterable(itr: Iterable[Any], cast_type: Type[Iterable]) -> Iterable: """ Casts an iterable to a different iterable type specified by the cast_type. Args: itr (Iterabl...
magic_evol_110k
80,508
Write a Python function to search for a given element in a list and return the indices of all its occurrences. If the element is not present in the list, the function should return an empty list. The function should be efficient and handle lists with repeated elements. The code should start with: ```python from typing...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_all_indices(numbers_list: List[int], element: int) -> List[int]: """ Find all indices of a given element in a list. Args: numbers_list (List[int]): The list of integers to search in...
magic_evol_110k
80,514
Write a Python function to generate and return the square transformation of every individual element in a given list of integers. The function should handle lists of any length, including empty lists. The code should start with: ```python from typing import List def square_elements(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 square_elements(arr: List[int]) -> List[int]: """ Generates the square transformation of every individual element in the given list of integers. Args: arr (List[int]): The list of intege...
magic_evol_110k
80,525
Write a Python function to return the mirror image of a given string. The function should handle empty strings and raise an error if the input is `None`. The function should achieve this in one pass without using any extra space. The input string will contain only lowercase and uppercase English alphabet letters and di...
Here is the Python code to solve the given problem in the markdown block: ```python def mirror_image(s: str) -> str: """ Returns the mirror image of the given string. Args: s (str): The input string containing only lowercase and uppercase English alphabet letters and digits. Returns: s...
magic_evol_110k
80,526
Write a Python function to invert a large sequence of numerical integers efficiently in terms of both time and space complexity. The sequence will have a minimum length of 1000 elements. The function should return the inverted sequence. The code should start with: ```python from typing import List def invert_large_se...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def invert_large_sequence(seq: List[int]) -> List[int]: """ Inverts a large sequence of numerical integers efficiently. Args: seq (List[int]): The sequence of integers to be inverted. Must h...
magic_evol_110k
80,543
Write a Python function to calculate the sum of absolute values of elements in a given list. The function should handle both positive and negative integers. The code should start with: ```python from typing import List def sum_of_absolute_values(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_absolute_values(numbers: List[int]) -> int: """ Calculate the sum of absolute values of elements in a given list. Args: numbers (List[int]): A list of integers. Returns: ...
magic_evol_110k
80,552
Write a Python function to sort a given array in descending order and calculate the sum of the top three elements. The function should handle arrays of any length, including cases where the array has fewer than three elements. The code should start with: ```python from typing import List def sum_of_top_three(array: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_top_three(array: List[int]) -> int: """ Sorts the given array in descending order and calculates the sum of the top three elements. Args: array (List[int]): The array of integers ...
magic_evol_110k
80,555
Write a Python function to generate the Fibonacci sequence up to the nth ordinal number position using an iterative approach. The function should return a list containing the Fibonacci sequence up to the nth position. The code should start with: ```python from typing import List def generate_fibonacci(n: int) -> List[...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the nth ordinal number position using an iterative approach. Args: n (int): The ordinal number position...
magic_evol_110k
80,565
Write a Python function to determine if a given numerical value resides within the bounds of 5 and 10 (inclusive). The function should return `True` if the number is within the bounds and `False` otherwise. The code should start with: ```python def is_within_bounds(number: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_within_bounds(number: int) -> bool: """ Determines if a given numerical value resides within the bounds of 5 and 10 (inclusive). Args: number (int): The numerical value to check. Returns: bool: T...
magic_evol_110k
80,566
Write a Python function to generate a random 2D array of size `m` by `n` with numbers between `min_val` and `max_val` (inclusive). The function should return the generated 2D array. The code should start with: ```python from typing import List import numpy as np def generate_random_2d_array(m: int, n: int, min_val: i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import numpy as np def generate_random_2d_array(m: int, n: int, min_val: int, max_val: int) -> List[List[int]]: """ Generate a random 2D array of size m by n with numbers between min_val and max_val (inc...
magic_evol_110k
80,574
Write a Python class to represent an `Animal` with the following properties and methods: 1. Properties: `type` (string: mammal, bird, fish, etc.), `name` (string), `age` (integer, in years), `is_endangered` (boolean). 2. Methods: - `speak()`: Returns a string: "{name} makes a noise." - `grow()`: Increases the age...
Here is the Python code to solve the given problem in the markdown block: ```python class Animal: def __init__(self, type: str, name: str, age: int, is_endangered: bool): """ Initialize an Animal object with the given properties. Args: type (str): The type of the animal (e.g., m...
magic_evol_110k
80,591
Write a Python function to generate a pseudorandom integer within a specified inclusive range [min_val, max_val]. The function should utilize Python's standard library to achieve this. The code should start with: ```python import random def generate_random_number(min_val: int, max_val: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(min_val: int, max_val: int) -> int: """ Generates a pseudorandom integer within the specified inclusive range [min_val, max_val]. Args: min_val (int): The lower bound of the...
magic_evol_110k
80,593
Write a Python function to calculate the amount of gasoline consumed by a car on a roundtrip journey between two cities given the distance between the cities and the car's fuel economy. The function should return the amount of gasoline consumed in gallons. The code should start with: ```python def calculate_gasoline_c...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_gasoline_consumption(distance: float, fuel_economy: float) -> float: """ Calculate the amount of gasoline consumed by a car on a roundtrip journey between two cities. Args: distance (float): The distan...
magic_evol_110k
80,601
Write a Python function to find all prime numbers up to a given limit `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 find_primes_up_to(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_primes_up_to(n: int) -> List[int]: """ Find all prime numbers up to a given limit `n` using the Sieve of Eratosthenes algorithm. Args: n (int): The upper limit up to which prime num...
magic_evol_110k
80,605
Write a Python function to find the penultimate highest numerical value from a given array of whole numbers. The function should handle duplicate values by considering only unique values. The code should start with: ```python from typing import List def penultimate_highest_value(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def penultimate_highest_value(numbers: List[int]) -> int: """ Find the penultimate highest numerical value from a given array of whole numbers. Args: numbers (List[int]): The array of whole ...
magic_evol_110k
80,643
Write a Python function to generate a stochastic sequence of length `n` using only lowercase letters from the English alphabet. The function should ensure that each character in the sequence is chosen randomly and independently from the set of lowercase letters. The code should start with: ```python import random impor...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_random_sequence(n: int) -> str: """ Generates a stochastic sequence of length `n` using only lowercase letters from the English alphabet. Args: n (int): The length of the se...
magic_evol_110k
80,651
Write a Python function to encrypt and decrypt a given string using a simple Caesar cipher with a shift of 2. The Caesar cipher shifts each letter in the string by a fixed number of positions down the alphabet. Non-alphabetic characters should remain unchanged. The function should handle both uppercase and lowercase le...
Here is the Python code to solve the given problem in the markdown block: ```python def encrypt(s: str) -> str: """ Encrypts the given string using a Caesar cipher with a shift of 2. Args: s (str): The string to be encrypted. Returns: str: The encrypted string. """ CHARSET_SIZE...
magic_evol_110k
80,658
Write a Python function to replace all occurrences of a specific word in a string along with their cases and pre-defined plural forms. The function should handle upper case, lower case, and title case versions of the words during replacement. Additionally, it should handle the plural form of the word by replacing it wi...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_words(sentence: str, word: str, replacement: str) -> str: """ Replaces all occurrences of a specific word in a string along with their cases and pre-defined plural forms. Args: sentence (str): The input ...
magic_evol_110k
80,666
Write a Python function to "pluck" the node with the smallest value that adheres to a particular condition defined by an auxiliary function `cond_fn`. The function should traverse an array of positive integers and return the node with the smallest value that satisfies the condition, along with its index. If multiple no...
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]) -> Union[List[int], List[Union[int, int]]]: """ Plucks the node with the smallest value that adheres to a condition defined by c...
magic_evol_110k
80,699
Write a Python function to generate a pseudo-random hexadecimal number stream of a specified length. The function should ensure that the generated stream contains only valid hexadecimal characters (0-9, a-f) and has the exact length specified by the user. The code should start with: ```python from typing import List d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_hex_stream(length: int) -> str: """ Generates a pseudo-random hexadecimal number stream of the specified length. Args: length (int): The length of the hexadecimal ...
magic_evol_110k
80,709
Write a Python function that takes a list of strings as input and returns a list of tuples. Each tuple should contain a unique string from the input list and its count in the original list. The returned list should be sorted in ascending order based on the string values. The function should be efficient and handle edge...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def distinct_ordered_strings_with_count(strings: List[str]) -> List[Tuple[str, int]]: """ Returns a list of tuples containing unique strings from the input list and their counts, sorted in ascendi...
magic_evol_110k
80,719
Write a Python function to merge multiple dictionaries into a single dictionary, ensuring that any duplicate keys are handled by keeping only the last value encountered for each key. The function should accept a variable number of dictionaries as input and return the merged dictionary. The code should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def merge_dictionaries(*dicts: Dict[Any, Any]) -> Dict[Any, Any]: """ Merge multiple dictionaries into a single dictionary, keeping only the last value for any duplicate keys. Args: *di...
magic_evol_110k
80,731
Write a Python function to count the number of null bits (zeros) in the binary representation of a given integer. The function should take an integer as input and return the count of zeros in its binary representation. The code should start with: ```python def count_zeros_in_binary(num: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_zeros_in_binary(num: int) -> int: """ Counts the number of null bits (zeros) in the binary representation of a given integer. Args: num (int): The integer whose binary representation's zeros are to be coun...
magic_evol_110k
80,738
Write a Python function to merge an array of strings into a single, unseparated string, considering that the strings in the array may be separated by either commas or semicolons. The function should handle both types of separators and return a single concatenated string without any separators. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_strings(input_array: List[str]) -> str: """ Merges an array of strings into a single, unseparated string. The strings in the array may be separated by either commas or semicolons. Args...
magic_evol_110k
80,740
Write a Python function to find the maximum element of a 3x3 matrix and its position (row and column indices). Additionally, ensure your function checks if the matrix is a valid 3x3 matrix. The function should return a tuple containing the maximum element and its position. If the matrix is not a valid 3x3 matrix, the f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_max_element_and_position(matrix: List[List[int]]) -> Tuple[int, Tuple[int, int]] or str: """ Find the maximum element of a 3x3 matrix and its position (row and column indices). Args:...
magic_evol_110k
80,752
Write a Python function to merge two dictionaries such that the resulting dictionary contains only the keys that are present in both input dictionaries. For each common key, the value should be a tuple consisting of the corresponding values from both dictionaries. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple def merge_dictionaries(given_dictionary: Dict[str, int], predefined_dictionary: Dict[str, int]) -> Dict[str, Tuple[int, int]]: """ Merges two dictionaries such that the resulting dictionary contai...
magic_evol_110k
80,754
Write a Python function to identify and replace all special characters present in the given string with their respective ASCII values while maintaining the order of occurrence of these characters. The function should only replace non-alphanumeric characters (i.e., characters that are neither letters nor digits). The co...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_special_characters(s: str) -> str: """ Replaces all special characters in the given string with their respective ASCII values. Args: s (str): The input string containing alphanumeric and special characte...
magic_evol_110k
80,767
Write a Python function to determine if a list of elements is monotonically increasing or decreasing, considering a strictness criterion. If the `strict` parameter is set to `True`, adjacent elements must not be identical; otherwise, they can be the same. The function should handle edge cases such as empty lists and si...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_monotonic(lst: List[int], strict: bool = False) -> bool: """ Determine if the list elements are monotonically increasing or decreasing, considering the strictness criterion. Args: ...
magic_evol_110k
80,787
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 rows ...