source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
15,645
Write a Python function to find and return the unique alphabetical elements from a given text string, sorted in ascending order. The function should ignore case sensitivity and only consider alphabetic characters. The code should start with: ```python from typing import List def unique_alphabetical_elements(text_strin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def unique_alphabetical_elements(text_string: str) -> List[str]: """ Returns a list of unique alphabetical elements from the given text string, sorted in ascending order. Args: text_string (...
evol_instruct_66k
15,654
Write a Python function to find the identical elements present in two different ordered integer arrays without using any inherent Python function calls. The function should use a two-pointer technique to efficiently compare elements from both arrays. The code should start with: ```python from typing import List def f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_identical_elements(array1: List[int], array2: List[int]) -> List[int]: """ Finds and returns the identical elements present in two ordered integer arrays. Args: array1 (List[int]): ...
evol_instruct_66k
15,657
Write a Python function to compute the cumulative sum of elements in a given list of integers. The cumulative sum at each position should be the sum of all elements up to and including that position in the list. The function should return a new list containing these cumulative sums. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_sum(array: List[int]) -> List[int]: """ Compute the cumulative sum of elements in a given list of integers. Args: array (List[int]): The list of integers for which to compute ...
evol_instruct_66k
15,664
Write a Python function to determine if the capitalization of a given word is used correctly according to the following rules: 1. All characters in the word are capitalized (e.g., "USA"). 2. No characters in the word are capitalized (e.g., "leetcode"). 3. Only the first character in the word is capitalized (e.g., "Goog...
Here is the Python code to solve the given problem in the markdown block: ```python def detect_capital_use(word: str) -> bool: """ Determines if the capitalization of the given word is used correctly. The correct usage of capitalization is defined by the following conditions: 1. All characters in the w...
evol_instruct_66k
15,670
Write a Python function to interleave two sorted arrays in a zigzag manner. The largest number from the first array must be paired with the smallest number from the second array, and vice versa. The remaining numbers should follow the same rule alternately. The function should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def zigzag_interleave(arr1: List[int], arr2: List[int]) -> List[int]: """ Interleaves two sorted arrays in a zigzag manner. The largest number from the first array is paired with the smallest number ...
evol_instruct_66k
15,671
Write a Python function to transform a given string into its uppercase equivalent. The function should take a string as input and return a new string where all the characters are in uppercase. The function should handle any string, including those with special characters and numbers. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python def to_uppercase(input_string: str) -> str: """ Transforms the given string into its uppercase equivalent. Args: input_string (str): The string to be converted to uppercase. Returns: str: The uppercase ...
evol_instruct_66k
15,680
Write a Python function to find the second-to-last smallest numerical integer in a given array of unique, scattered discrete integers. The array is guaranteed to have at least two unique integers. The function should handle arrays with duplicates by removing them before finding the second-to-last smallest integer. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_second_smallest(array: List[int]) -> int: """ Find the second-to-last smallest numerical integer in a given array of unique, scattered discrete integers. Args: array (List[int]): Th...
evol_instruct_66k
15,683
Write a Python function to print each element of a given list of strings on a new line. The function should accept a list of strings as input and print each string without returning any value. The code should start with: ```python from typing import List def print_each_element(elements: List[str]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def print_each_element(elements: List[str]) -> None: """ Prints each element of the given list of strings on a new line. Args: elements (List[str]): A list of strings to be printed. R...
evol_instruct_66k
15,686
Write a Python function to find the indexes of all occurrences of a specified number in a given list. The function should return a list of indices where the specified number appears. The code should start with: ```python from typing import List def find_all_occurrences(lst: List[int], number: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_all_occurrences(lst: List[int], number: int) -> List[int]: """ Find the indexes of all occurrences of a specified number in a given list. Args: lst (List[int]): The list in which ...
evol_instruct_66k
15,699
Write a Python function to split a given sentence into individual words and return them as a list. The function should handle sentences with varying numbers of spaces between words and should not include empty strings in the result. The code should start with: ```python from typing import List def split_sentence_into_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_sentence_into_words(sentence: str) -> List[str]: """ Splits a given sentence into individual words and returns them as a list. Args: sentence (str): The sentence to be split into w...
evol_instruct_66k
15,707
Write a Python function to insert a new element at a specified index in a list without using built-in functions like `insert`. The list elements are floats, and the index is an integer. The function should handle edge cases such as inserting at the beginning or end of the list, and should not modify the original list. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insert_element(mylist: List[float], new_elem: float, i: int) -> List[float]: """ Inserts a new element at a specified index in a list without using built-in functions. Args: mylist (List...
evol_instruct_66k
15,710
Write a Python function to filter the prime numbers from a given list of integers and count the frequency of each prime number. The function should return a list of unique prime numbers and a corresponding list of their frequencies. The input list does not have to be ordered. The code should start with: ```python from...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number i...
evol_instruct_66k
15,730
Write a Python function to create and populate a dictionary with student IDs as keys and tuples containing the student's full legal name and age as values. The function should accept a list of tuples, where each tuple contains a student ID, full legal name, and age. The function should return the populated dictionary. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_student_dictionary(students: List[Tuple[int, str, int]]) -> Dict[int, Tuple[str, int]]: """ Creates a dictionary with student IDs as keys and tuples containing the student's full ...
evol_instruct_66k
15,731
Write a Python function to compute the sum of all elements in a nested list. The nested list can contain integers and other nested lists. The function should recursively traverse through all levels of the nested list to compute the sum. The code should start with: ```python from typing import List, Union def sum_nest...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def sum_nested_list(nested_list: List[Union[int, List]]) -> int: """ Compute the sum of all elements in a nested list. Args: nested_list (List[Union[int, List]]): A nested list contai...
evol_instruct_66k
15,735
Write a Python function to validate if a given string matches a specific pattern using regular expressions. The pattern should be defined as follows: - The first character (w) should be between 'a' and 'c'. - The second character (x) should be a digit between 0 and 9. - The third character (y) should be any lowercase l...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_string_pattern(string: str) -> bool: """ Validates if the given string matches the specified pattern using regular expressions. The pattern is defined as follows: - The first character (w) should...
evol_instruct_66k
15,743
Write a Python function to perform a binary search on a sorted list and return the index of the target element if it exists in the list. If the target element is not found, return -1. The function should be efficient and use the binary search algorithm. 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 binary_search(sorted_list: List[int], target: int) -> int: """ Perform a binary search on a sorted list to find the index of the target element. Args: sorted_list (List[int]): A sorted l...
evol_instruct_66k
15,752
Write a Python function to multiply all elements in a given two-dimensional matrix. The matrix is represented as a list of lists, where each inner list represents a row of the matrix. The function should return the product of all elements in the matrix. 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 multiply_matrix_elements(matrix: List[List[int]]) -> int: """ Multiplies all elements in a given two-dimensional matrix. Args: matrix (List[List[int]]): A list of lists representing th...
evol_instruct_66k
15,757
Write a Python function to count the number of strings in a given list that start with the letter 'a' (case-insensitive). The function should return the count as an integer. The code should start with: ```python from typing import List def count_strings_starting_with_a(string_list: List[str]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_strings_starting_with_a(string_list: List[str]) -> int: """ Counts the number of strings in a given list that start with the letter 'a' (case-insensitive). Args: string_list (List[...
evol_instruct_66k
15,759
Write a Python function to calculate the sum of the squares of all integers less than a given positive integer `n`. The function should return the aggregate total of these squared values. The code should start with: ```python def sum_of_squares(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_squares(n: int) -> int: """ Calculate the sum of the squares of all integers less than a given positive integer `n`. Args: n (int): A positive integer. Returns: int: The sum of the squares of...
evol_instruct_66k
15,765
Write a Python function to generate a list of even integers within a specified range, starting from a given lower bound (inclusive) and ending at a given upper bound (exclusive). The function should handle cases where the lower bound is greater than or equal to the upper bound by returning an empty list. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_even_numbers(lower_bound: int, upper_bound: int) -> List[int]: """ Generate a list of even integers within the specified range [lower_bound, upper_bound). Args: lower_bound (int...
evol_instruct_66k
15,810
Write a Python function to identify all the prime numbers within a given range [start, end]. The function should return a list of prime numbers found within the specified range. The code should start with: ```python from typing import List def find_prime_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 import math def find_prime_numbers(start: int, end: int) -> List[int]: """ Identify all prime numbers within a given range [start, end]. Args: start (int): The starting value of the range ...
evol_instruct_66k
15,850
Write a Python function to calculate the cumulative total of all numerical elements in a given array. The function should handle both positive and negative integers, as well as floating-point numbers. The function should also be able to handle an empty array by returning 0. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def cumulative_sum(array: List[float]) -> float: """ Calculate the cumulative total of all numerical elements in the given array. Args: array (List[float]): The array of numerical elements...
evol_instruct_66k
15,851
Write a Python function to compute the nth term of the Lucas series using an iterative approach. The Lucas series is defined as follows: - The 0th term is 2. - The 1st term is 1. - For n >= 2, the nth term is the sum of the (n-1)th and (n-2)th terms. The code should start with: ```python def lucas_iterative(n: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python def lucas_iterative(n: int) -> int: """ Compute the nth term of the Lucas series using an iterative approach. The Lucas series is defined as: - The 0th term is 2. - The 1st term is 1. - For n >= 2, the nth term ...
evol_instruct_66k
15,854
Write a Python function to perform an interpolative search in a sorted list, ensuring the procedure handles duplicates and missing numbers efficiently. The function should return the index of the first occurrence of the target element if it exists in the list, otherwise return -1. 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 interpolation_search(arr: List[int], x: int) -> int: """ Perform an interpolative search in a sorted list to find the index of the first occurrence of the target element. Args: arr (List...
evol_instruct_66k
15,860
Write a Python function to implement an adaptive quicksort algorithm that selects the pivot at runtime based on the input data for optimal performance. The algorithm should handle duplicate elements efficiently and allow for the modification of the pivot selection strategy. The function should also include a mechanism ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random import sys sys.setrecursionlimit(10000) def insertion_sort(A: List[int]) -> List[int]: """ Sorts the list A using the insertion sort algorithm. Args: A (List[int]): The list t...
evol_instruct_66k
15,883
Write a Python function to generate a random birthday from any given year. The function should return the date in the format 'YYYY-MM-DD'. The function should handle leap years correctly by generating a date from 1 to 366 days for leap years and 1 to 365 days for non-leap years. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime import random def generate_random_birthday(year: int) -> str: """ Generates a random birthday from the given year and returns it in the format 'YYYY-MM-DD'. Args: year (int): The year ...
evol_instruct_66k
15,897
Write a Python function to convert a list of hexadecimal string values into their corresponding binary representations. Each binary representation should be padded with leading zeros to ensure that the binary string length is a multiple of 4. The function should start with: ```python from typing import List def hex_to...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def hex_to_binary(hex_values: List[str]) -> List[str]: """ Converts a list of hexadecimal string values into their corresponding binary representations. Each binary string is padded with leading ze...
evol_instruct_66k
15,899
Write a Python function to generate an array of unique palindromic strings of length between 5 to 10 characters. Each string must be a valid palindrome and should not contain any special characters. The array must not contain any duplicate strings. The function should return the array of palindromic strings. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random import string def generate_unique_palindromes(num_palindromes: int) -> List[str]: """ Generates an array of unique palindromic strings of length between 5 to 10 characters. Args: ...
evol_instruct_66k
15,900
Write a Python function to merge two JSON-like dictionaries into a single dictionary. The function should handle nested dictionaries and lists. If there are conflicting keys, the value from the second dictionary should overwrite the value from the first dictionary. The function 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, Any def merge_json_dicts(dict1: Dict[str, Any], dict2: Dict[str, Any]) -> Dict[str, Any]: """ Merge two JSON-like dictionaries into a single dictionary. Args: dict1 (Dict[str, Any]): The fi...
evol_instruct_66k
15,913
Write a Python function that prints "Greetings, Universe!" if a specified boolean variable is `True`, otherwise prints "Best Wishes!". The function should not use any conditional statements and should minimize the number of extra variables used. The function should start with: ```python def print_greetings(is_display_g...
Here is the Python code to solve the given problem in the markdown block: ```python def print_greetings(is_display_greetings: bool) -> None: """ Prints "Greetings, Universe!" if the boolean variable is True, otherwise prints "Best Wishes!". Args: is_display_greetings (bool): A boolean variable that...
evol_instruct_66k
15,917
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 def shuffle_list(input_list: List[float]) -> None: ```...
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_...
evol_instruct_66k
15,923
Write a Python function to transpose a given matrix. The function should take a 2D list (matrix) as input and return its transpose. The transpose of a matrix is obtained by swapping its rows with its columns. The code should start with: ```python from typing import List def transpose_matrix(matrix: List[List[int]]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def transpose_matrix(matrix: List[List[int]]) -> List[List[int]]: """ Transposes the given matrix. Args: matrix (List[List[int]]): The input matrix to be transposed. Returns: Li...
evol_instruct_66k
15,925
Write a Python function to flatten a nested list of arbitrary depth into a single, flat list. The function should handle lists with varying levels of nesting efficiently and scalably. The code should start with: ```python from typing import List, Any def flatten_nested_list(nested_list: List[Any]) -> List[Any]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def flatten_nested_list(nested_list: List[Any]) -> List[Any]: """ Flattens a nested list of arbitrary depth into a single, flat list. Args: nested_list (List[Any]): The nested list to b...
evol_instruct_66k
15,935
Write a Python function to identify and return the frequency of a specific word in a list of strings. The function should be case-insensitive and also count the frequency of anagrams of the specific word. The function should start with: ```python from typing import List def word_anagram_frequency(word_list: List[str],...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import Counter def word_anagram_frequency(word_list: List[str], target_word: str) -> int: """ Identifies and returns the frequency of a specific word in a list of strings. The functi...
evol_instruct_66k
15,944
Write a Python function to find all the numbers between 0 and a given upper limit (inclusive) that are divisible by both 3 and 5, and then calculate and return the average of these numbers. The function should be efficient, considering the large range of numbers. The code should start with: ```python def find_divisibl...
Here is the Python code to solve the given problem in the markdown block: ```python def find_divisible_and_average(upper_limit: int) -> float: """ Finds all numbers between 0 and the given upper limit (inclusive) that are divisible by both 3 and 5, and calculates the average of these numbers. Args: ...
evol_instruct_66k
15,983
Write a Python function to find the length of the longest common subsequence (LCS) between two given strings `s` and `t`. The LCS is defined as the longest sequence of characters that appear in the same order in both strings, but not necessarily consecutively. The code should start with: ```python def longest_common_s...
Here is the Python code to solve the given problem in the markdown block: ```python def longest_common_subsequence_length(s: str, t: str) -> int: """ Calculate the length of the longest common subsequence between two strings s and t. Args: s (str): The first string. t (str): The second stri...
evol_instruct_66k
15,986
Write a Python function to convert a temperature from Fahrenheit to Celsius with precision. The function should handle non-numeric input gracefully by returning a specific error message. The code should start with: ```python def fahrenheit_to_celsius(fahrenheit: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def fahrenheit_to_celsius(fahrenheit: float) -> float: """ Converts a temperature from Fahrenheit to Celsius with precision. Args: fahrenheit (float): The temperature in Fahrenheit to be converted. Returns: ...
evol_instruct_66k
16,000
Write a Python function to count the frequency of a specific word in a list of strings. The function should handle case-insensitive comparisons and should not count partial matches (e.g., "hello" should not match "hello123"). The code should start with: ```python from typing import List def count_word_frequency(word: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_word_frequency(word: str, string_list: List[str]) -> int: """ Counts the frequency of a specific word in a list of strings. This function performs a case-insensitive comparison and ensures...
evol_instruct_66k
16,002
Write a Python function to calculate the sum of the squares of all elements 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 sum_of_squares(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_squares(numbers: List[int]) -> int: """ Calculate the sum of the squares of all elements in a given list of integers. Args: numbers (List[int]): A list of integers for which the s...
evol_instruct_66k
16,004
Write a Python function to compute the nth Fibonacci number using an iterative approach. The function should efficiently calculate the Fibonacci number by storing intermediate results in a list to avoid redundant calculations, which is a common technique in dynamic programming. The code should start with: ```python de...
Here is the Python code to solve the given problem in the markdown block: ```python def fibonacci(n: int) -> int: """ Compute the nth Fibonacci number using an iterative approach. Args: n (int): The position in the Fibonacci sequence to compute. Returns: int: The nth Fibonacci number. ...
evol_instruct_66k
16,019
Write a Python function to find the positions of all occurrences of a specified character in a given string. The function should return a list of indices where the character is found. The code should start with: ```python from typing import List def find_character_positions(string: str, character: str) -> List[int]: `...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_character_positions(string: str, character: str) -> List[int]: """ Find the positions of all occurrences of a specified character in a given string. Args: string (str): The input ...
evol_instruct_66k
16,028
Write a Python function to compute the Euclidean distance between two specified 3-dimensional Cartesian coordinate tuples. Additionally, create a function that can process an array of such coordinate tuples and return the cumulative distance traversed when transitioning from the initial to the terminal coordinate, navi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple from math import sqrt, pow def calculate_euclidean_distance(p1: Tuple[float, float, float], p2: Tuple[float, float, float]) -> float: """ Calculate the Euclidean ...
evol_instruct_66k
16,035
Write a Python function to identify the penultimate item from a given tuple. The function should take a tuple as input and return the second-to-last element. If the tuple has fewer than two elements, the function should return `None`. The code should start with: ```python from typing import Tuple, Any def get_penulti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Any def get_penultimate_item(items: Tuple[Any, ...]) -> Any: """ Returns the penultimate item from a given tuple. Args: items (Tuple[Any, ...]): The tuple from which to extract the penulti...
evol_instruct_66k
16,036
Write a Python function to calculate either the median or the mode of a given list of integers based on a specified calculation type. The function should handle edge cases such as an empty list or an invalid calculation type. The input list is not guaranteed to be sorted, so sorting should be considered within the func...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union from collections import Counter def calculate_statistic(nums: List[int], calc_type: str) -> Union[float, int, None]: """ Calculate the median or mode of a list of integers based on the specified c...
evol_instruct_66k
16,041
Write a Python function to merge two ascending-ordered lists of integers, `A` and `B`, of lengths `p` and `q`, respectively, into a single list in ascending order. The function should efficiently merge the two lists without using any additional sorting algorithms. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_lists(A: List[int], B: List[int]) -> List[int]: """ Merges two ascending-ordered lists of integers into a single ascending-ordered list. Args: A (List[int]): The first ascen...
evol_instruct_66k
16,045
Write a Python function to calculate the sum of the squares of all even numbers in a given list of integers. The function should iterate through the list, identify even numbers, square them, and then sum these squared values. The code should start with: ```python from typing import List def sum_of_squares_of_evens(num...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sum_of_squares_of_evens(nums: List[int]) -> int: """ Calculate the sum of the squares of all even numbers in the given list. Args: nums (List[int]): A list of integers. Returns: ...
evol_instruct_66k
16,060
Write a Python function to split a given list of numerical inputs into two halves such that the difference in the sum of the elements in each half is minimized. The function should return the two halves as two separate lists. The code should start with: ```python from typing import List, Tuple def split_list_minimize...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def split_list_minimized_difference(input_list: List[int]) -> Tuple[List[int], List[int]]: """ Splits a given list of numerical inputs into two halves such that the difference in the sum of the el...
evol_instruct_66k
16,061
Write a Python function to rotate a given square matrix in a clockwise direction by a specified number of positions. The function should handle errors and manage various types of entries. The function should start with: ```python from typing import List def rotate_matrix(matrix: List[List[int]], positions: int) -> Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def rotate_matrix(matrix: List[List[int]], positions: int) -> List[List[int]]: """ Rotate a given square matrix in a clockwise direction by a specified number of positions. Args: matrix (Lis...
evol_instruct_66k
16,068
Write a Python function to calculate the sum of corresponding elements in two lists and return the result as a list. Ensure that modifying one list does not affect the other. The function should start with: ```python from typing import List def sum_of_corresponding_elements(list1: List[int], list2: List[int]) -> List[...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_corresponding_elements(list1: List[int], list2: List[int]) -> List[int]: """ Calculate the sum of corresponding elements in two lists and return the result as a list. Args: list1 ...
evol_instruct_66k
16,084
Write a Python function to create a matrix of gastronomic entities from two given lists, ensuring that each row in the matrix contains distinct gastronomic entities. The function should also ensure that the matrix is printed in a specific format where each row is printed on a new line. The code should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_gastronomic_matrix(table1: List[str], table2: List[str]) -> List[List[str]]: """ Creates a matrix of gastronomic entities from two given lists and prints each row on a new line. Args: ...
evol_instruct_66k
16,095
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(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def factorial(n: int) -> int: """ Calculate the factorial of a given non-negative integer. Args: n (int): The non-negative integer for which to calculate the factorial. Returns: int: The factorial of th...
evol_instruct_66k
16,098
Write a Python function to filter out odd numbers and numbers divisible by 5 from a given list of integers. The function should not use any built-in filter functions. The code should start with: ```python from typing import List def filter_numbers(num_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_numbers(num_list: List[int]) -> List[int]: """ Filters out odd numbers and numbers divisible by 5 from the given list of integers. Args: num_list (List[int]): The list of integers...
evol_instruct_66k
16,099
Write a Python function to calculate the area and circumference of a circle given its radius and central coordinates. The function should also allow updating the radius and central coordinates. The code should start with: ```python from typing import Tuple def circle_metrics(radius: float, center: Tuple[float, float])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import math def circle_metrics(radius: float, center: Tuple[float, float]) -> Tuple[float, float]: """ Calculate the area and circumference of a circle given its radius and central coordinates. Arg...
evol_instruct_66k
16,105
Write a Python function to convert a binary search tree (BST) into a sorted array without using any built-in sort functions, while preserving the original structure of the tree. The function should perform an in-order traversal of the BST to collect the node values in a sorted order. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def bst_to_sorted_array(root: TreeNode) -> List[int]: "...
evol_instruct_66k
16,113
Write a Python function to construct an array composed of Unicode objects by extracting them from the provided string input. The function should return a list of Unicode values corresponding to each character in the input string. The code should start with: ```python from typing import List def extract_unicode_values(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def extract_unicode_values(input_string: str) -> List[int]: """ Constructs an array composed of Unicode objects by extracting them from the provided string input. Args: input_string (str): T...
evol_instruct_66k
16,121
Write a Python function to filter out non-prime numbers from a given list and return a new list containing only the prime numbers. The function should efficiently determine if a number is prime by checking divisibility up to the square root of the number. The code should start with: ```python from typing import List ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_primes(nums: List[int]) -> List[int]: """ Filters out non-prime numbers from the given list and returns a new list containing only the prime numbers. Args: nums (List[int]): The l...
evol_instruct_66k
16,125
Write a Python function to find the pair of distinct elements in a given list of integers that yields the highest arithmetic sum. The function should return both the pair of elements and their sum. The code should start with: ```python from typing import List, Tuple def find_highest_sum_pair(arr: List[int]) -> Tuple[T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_highest_sum_pair(arr: List[int]) -> Tuple[Tuple[int, int], int]: """ Finds the pair of distinct elements in the given list that yields the highest arithmetic sum. Args: arr (...
evol_instruct_66k
16,145
Write a Python function to swap the values of two variables. The function should take two parameters and return a tuple with the swapped values. The code should start with: ```python def swap_values(a: int, b: int) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def swap_values(a: int, b: int) -> tuple: """ Swaps the values of two variables and returns them as a tuple. Args: a (int): The first variable. b (int): The second variable. Returns: tuple: A tu...
evol_instruct_66k
16,150
Write a Python function to print an array of tuples in reverse order. The function should take a list of tuples as input and print each tuple in reverse order. The code should start with: ```python from typing import List, Tuple def print_tuples_in_reverse(tuples: List[Tuple[str, int]]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Tuple def print_tuples_in_reverse(tuples: List[Tuple[str, int]]) -> None: """ Prints each tuple in the given list of tuples in reverse order. Args: tuples (List[Tuple[str, int]]): A list ...
evol_instruct_66k
16,163
Write a Python function to merge two numerical sequences into a single sorted list without any duplicate elements. The function should accept two lists as input and return a new list that contains all unique elements from both lists, sorted in ascending order. The code should start with: ```python from typing import Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_and_sort_lists(list_1: List[int], list_2: List[int]) -> List[int]: """ Merges two numerical sequences into a single sorted list without any duplicate elements. Args: list_1 (List[i...
evol_instruct_66k
16,166
Write a Python function to calculate the maximum profit that can be achieved by buying and selling a stock multiple times over a given period. The function should take a list of stock prices where `prices[i]` represents the price of the stock on the `i-th` day. You are allowed to make an unlimited number of transaction...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be achieved by buying and selling a stock multiple times. Args: prices (List[int]): A list of stock prices...
evol_instruct_66k
16,177
Write a Python function to generate a list containing exactly three elements: "red", "blue", and "green", in that specific order. The function should ensure that the elements are added to the list in the correct sequence and return the list. The code should start with: ```python from typing import List def generate_c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_color_list() -> List[str]: """ Generates a list containing exactly three elements: "red", "blue", and "green", in that specific order. Returns: List[str]: A list containing the ...
evol_instruct_66k
16,179
Write a Python function to calculate the result of raising a given base `n` to a specified exponent `m` using a recursive approach. The function should handle both positive and negative exponents. The code should start with: ```python def recursive_exponentiation(n: int, m: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def recursive_exponentiation(n: int, m: int) -> int: """ Calculate the result of raising a base `n` to an exponent `m` using a recursive approach. Args: n (int): The base number. m (int): The exponent. ...
evol_instruct_66k
16,187
Write a Python function to find the first non-repeating character in a given string and return its position. The function should not use any built-in functions or methods except for determining the length of the string. The string will only contain alphabetic characters and will not include any special notations. The f...
Here is the Python code to solve the given problem in the markdown block: ```python def find_first_non_repeating_char(input_str: str) -> tuple: """ Finds the first non-repeating character in the given string and returns its position. Args: input_str (str): The input string to search for the first n...
evol_instruct_66k
16,194
Write a Python function to calculate the total 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 either down or right at any point in time. The code should start with: ```python def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def unique_paths(m: int, n: int) -> int: """ Calculate the total 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 in the grid. ...
evol_instruct_66k
16,196
Write a Python function that takes three parameters: a list `arr`, a value `value`, and a boolean flag `flag`. If the flag is `True`, the function should return the index of the first occurrence of `value` in `arr`. If the flag is `False`, the function should return `True` if `value` is in `arr`, otherwise `False`. If ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def find_value(arr: List[int], value: int, flag: bool) -> Union[int, bool]: """ Finds the index of the first occurrence of a value in an array if the flag is True, otherwise returns True if th...
evol_instruct_66k
16,199
Write a Python function to create a dictionary representing a person with three key-value pairs: 'name', 'age', and 'occupation'. The function should take three parameters corresponding to these keys and return the dictionary. The code should start with: ```python from typing import Dict def create_person_dict(name: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def create_person_dict(name: str, age: int, occupation: str) -> Dict[str, object]: """ Creates a dictionary representing a person with 'name', 'age', and 'occupation' attributes. Args: name ...
evol_instruct_66k
16,216
Write a Python function to swap the values of two unique integer variables without using a temporary variable. The function should take two integers as input and return a tuple containing the swapped values. The code should start with: ```python def swap_integers(a: int, b: int) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def swap_integers(a: int, b: int) -> tuple: """ Swaps the values of two unique integer variables without using a temporary variable. Args: a (int): The first integer. b (int): The second integer. Return...
evol_instruct_66k
16,217
Write a Python function to replace all non-alphanumeric characters in a given string with a specified substitute character. The function should handle any string input and return the modified string. The code should start with: ```python def replace_non_alphanumeric(text: str, substitute: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def replace_non_alphanumeric(text: str, substitute: str) -> str: """ Replaces all non-alphanumeric characters in the given text with the specified substitute character. Args: text (str): The input string to be proce...
evol_instruct_66k
16,218
Write a Python function to calculate the atomic composition of a given DNA sequence and its corresponding RNA strand. The function should also provide the atomic composition of the RNA strand. The DNA sequence is represented as a string of nucleotides (A, T, C, G), and the corresponding RNA strand is derived by replaci...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def dna_rna_composition(DNA: str) -> Tuple[List[List[str]], str, List[List[str]]]: """ Calculate the atomic composition of a given DNA sequence and its corresponding RNA strand. Args: ...
evol_instruct_66k
16,226
Write a Python function to calculate the Euclidean distance between two points in a higher-dimensional space. The function should handle potential mismatches in the dimensions of the input points by raising a `ValueError`. The code should start with: ```python from typing import List import math def euclidean_distance...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def euclidean_distance(point1: List[float], point2: List[float]) -> float: """ Calculate the Euclidean distance between two points in a higher-dimensional space. Args: point1 (Li...
evol_instruct_66k
16,228
Write a Python function to perform basic operations on a four-dimensional array with consistent dimensions of 4 x 4 x 4 x 4. The operations include creating the array, reading a value from a specific position, updating a value at a specific position, and zeroing out a 3-dimensional block within the 4-dimensional array....
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def manipulate_4d_array() -> np.ndarray: """ Perform basic operations on a 4-dimensional array with dimensions 4 x 4 x 4 x 4. Operations include: 1. Creating the array filled with zeros. 2. Readi...
evol_instruct_66k
16,229
Write a Python function to replace all instances of the character '0' with the character 'x' in a given bi-dimensional array (matrix) of alphabetic elements. The function should modify the matrix in place and return the modified matrix. The code should start with: ```python from typing import List def replace_zeros_wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def replace_zeros_with_x(matrix: List[List[str]]) -> List[List[str]]: """ Replace all instances of the character '0' with the character 'x' in a given bi-dimensional array (matrix) of alphabetic elements...
evol_instruct_66k
16,250
Write a Python function to determine if a given sequence of hexadecimal characters exhibits cyclic symmetry, similar to an ambigram. A sequence is considered to have cyclic symmetry if it reads the same forwards and backwards. The function should be case-insensitive and should only consider valid hexadecimal characters...
Here is the Python code to solve the given problem in the markdown block: ```python def is_cyclic_symmetry(hex_seq: str) -> bool: """ Determines if a given sequence of hexadecimal characters exhibits cyclic symmetry. Args: hex_seq (str): The sequence of hexadecimal characters to check. Returns...
evol_instruct_66k
16,265
Write a Python function to construct an array from a given set of numbers without using any built-in array functions. Additionally, implement two functions: one to add a new element to the array and another to remove an element by its index. Ensure that the functions handle edge cases such as adding an element to an em...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def construct_array(numbers: List[int]) -> List[int]: """ Construct an array from the given set of numbers without using any built-in array functions. Args: numbers (List[int]): The s...
evol_instruct_66k
16,272
Write a Python function to generate the first `n` elements of the Catalan sequence efficiently using dynamic programming. The Catalan sequence is defined by the recurrence relation: \[ C(n) = \sum_{i=0}^{n-1} C(i) \times C(n-i-1) \] with base cases \( C(0) = 1 \) and \( C(1) = 1 \). The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_catalan_sequence(n: int) -> List[int]: """ Generate the first n elements of the Catalan sequence using dynamic programming. Args: n (int): The number of Catalan numbers to gener...
evol_instruct_66k
16,273
Write a Python function to calculate the frequency of a specific word in a given sentence, considering case insensitivity. The function should handle punctuation and multiple spaces correctly. The code should start with: ```python from typing import List def word_frequency(sentence: str, word: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def word_frequency(sentence: str, word: str) -> int: """ Calculate the frequency of a specific word in a given sentence, considering case insensitivity. Args: sentence (str): The s...
evol_instruct_66k
16,284
Write a Python function to calculate the simple interest given the principal amount, the annual interest rate, and the time duration in years. The function should return the calculated simple interest. The code should start with: ```python def calculate_simple_interest(principal: float, rate: float, time: float) -> flo...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_simple_interest(principal: float, rate: float, time: float) -> float: """ Calculate the simple interest given the principal amount, the annual interest rate, and the time duration in years. Args: princ...
evol_instruct_66k
16,287
Write a Python function to perform the subtraction of two numbers and return the result. The function should handle both positive and negative integers, as well as zero. The code should start with: ```python def subtract_numbers(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def subtract_numbers(a: int, b: int) -> int: """ Subtracts the second integer from the first integer and returns the result. Args: a (int): The first integer. b (int): The second integer. Returns: ...
evol_instruct_66k
16,290
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
16,308
Write a Python function to build a dictionary from a list of string pairs, where each pair is represented as a string in the format "key->value". The function should take a list of such string pairs as input and return a dictionary where each key is a string and each value is also a string. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def build_dictionary_from_pairs(pairs: List[str]) -> Dict[str, str]: """ Builds a dictionary from a list of string pairs, where each pair is in the format "key->value". Args: pairs (Li...
evol_instruct_66k
16,310
Write a Python function to generate prime numbers within a given range `[low, high]`, ensuring that the lower limit `low` is positive and less than the upper limit `high`. The function should also return the total number of primes found within the range. The code should start with: ```python from typing import List, Tu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def generate_primes_in_range(low: int, high: int) -> Tuple[List[int], int]: """ Generates prime numbers within the given range [low, high] and returns the list of primes along with the...
evol_instruct_66k
16,321
Write a Python function to determine if a given word has alternating vowels and consonants. A word is considered to have alternating vowels and consonants if no two adjacent characters are both vowels or both consonants. The function should be case-insensitive. The code should start with: ```python def is_alternating_...
Here is the Python code to solve the given problem in the markdown block: ```python def is_alternating_word(word: str) -> bool: """ Determines if a given word has alternating vowels and consonants. Args: word (str): The word to be checked. Returns: bool: True if the word has alternatin...
evol_instruct_66k
16,329
Write a Python function to validate if a given string is a valid US phone number. The phone number may optionally include an international dialing code, area code, and/or separators such as spaces, parentheses, or hyphens. The function should return `True` if the phone number is valid and `False` otherwise. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_us_phone_number(phone_number: str) -> bool: """ Validate if the given string is a valid US phone number. The phone number may optionally include an international dialing code, area code, and/or s...
evol_instruct_66k
16,332
Write a Python function to concatenate a list of strings into a single string, using the most efficient method available in Python. The function should avoid using the `+` operator for concatenation and should handle different types of string formatting. The function should also be able to handle an empty list by retur...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def concatenate_strings(str_list: List[str]) -> str: """ Concatenates a list of strings into a single string using the most efficient method. Args: str_list (List[str]): A list of strings to...
evol_instruct_66k
16,364
Write a Python function that takes an input and produces an output that is precisely identical to the provided input. The function should handle various data types, including but not limited to strings, integers, floats, lists, and dictionaries. The function should also handle nested structures within these data types....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any import copy def precise_identity(input_value: Any) -> Any: """ Returns an output that is precisely identical to the provided input, including nested structures. Args: input_value (Any): The i...
evol_instruct_66k
16,365
Write a Python function to filter out and return all the odd numbers from a given list of integers. The function should handle lists of any size, including empty lists. The code should start with: ```python from typing import List def filter_odd_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 filter_odd_numbers(numbers: List[int]) -> List[int]: """ Filters out and returns all the odd numbers from the given list of integers. Args: numbers (List[int]): The list of integers from...
evol_instruct_66k
16,369
Write a Python function to calculate the number of ways to reach the bottom-right corner of a grid from the top-left corner, moving only right or down, given the dimensions of the grid. The code should start with: ```python def count_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def count_paths(m: int, n: int) -> int: """ Calculate the number of ways to reach the bottom-right corner of an m x n grid from the top-left corner, moving only right or down. Args: m (int): The number of rows...
evol_instruct_66k
16,373
Write a Python function to generate a new list by processing each item in two given lists, `list_one` and `list_two`, sequentially. The new list should contain elements that are the result of a mathematical operation applied on their corresponding items. Specifically, each item from `list_one` should be multiplied by t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_lists(list_one: List[int], list_two: List[int]) -> List[int]: """ Generates a new list by processing each item in list_one and list_two sequentially. Each item from list_one is multiplied...
evol_instruct_66k
16,379
Write a Python function to generate a numerical sequence based on the provided integer `n`. The sequence should consist of the squares of the first `n` natural numbers. The function should return a list of these squared values. The code should start with: ```python from typing import List def generate_sequence(n: int...
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]: """ Generates a sequence of squares of the first n natural numbers. Args: n (int): The number of natural numbers to square. Returns: ...
evol_instruct_66k
16,388
Write a Python function to divide a given text string using a specified delimiter symbol while maintaining the order of the substrings. The function should return a list of substrings. The code should start with: ```python from typing import List def split_string_by_delimiter(text: str, delimiter: str) -> List[str]: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string_by_delimiter(text: str, delimiter: str) -> List[str]: """ Splits the given text string using the specified delimiter and returns a list of substrings. Args: text (str): The ...
evol_instruct_66k
16,395
Write a Python function to generate the first `n` rows of Pascal's Triangle. Pascal's Triangle is a triangular array of the binomial coefficients. Each number in the triangle is the sum of the two numbers directly above it. The function should return a list of lists, where each inner list represents a row in the triang...
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...
evol_instruct_66k
16,396
Write a Python function to find the largest number in a given list of integers. The function should handle both positive and negative integers. The code should start with: ```python from typing import List def find_largest_number(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_largest_number(numbers: List[int]) -> int: """ Find the largest number in a given list of integers. Args: numbers (List[int]): A list of integers from which to find the largest numb...
evol_instruct_66k
16,416
Write a Python function to calculate the sum of all elements in a nested list, where the list can contain integers and other nested lists. The function should recursively traverse through all levels of nested lists to compute the total sum. The code should start with: ```python from typing import Union, List def sum_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List def sum_nested_list(nested_list: Union[List, int]) -> int: """ Calculate the sum of all elements in a nested list. Args: nested_list (Union[List, int]): A nested list containing integ...
evol_instruct_66k
16,421
Write a Python function to move all zeros in a given list of integers to the end of the list while maintaining the relative order of the non-zero elements. The function should not use any additional data structures; it should modify the list in place. 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 move_zeros_to_end(nums: List[int]) -> None: """ Moves all zeros in the given list of integers to the end while maintaining the relative order of non-zero elements. Args: nums (List[int])...
evol_instruct_66k
16,442
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 t...
evol_instruct_66k
16,453
Write a Python function to validate phone numbers in a given list of customer records. The function should use regular expressions to check if each phone number follows the standard US format (e.g., "123-456-7890"). The function should return a list of invalid phone numbers. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def find_invalid_phone_numbers(records: List[str]) -> List[str]: """ Validate phone numbers in a list of customer records and return a list of invalid phone numbers. Args: records ...
evol_instruct_66k
16,460
Write a Python function to swap the values of two distinct variables using bitwise XOR operations. The function should take two integers as input and return a tuple containing the swapped values. The code should start with: ```python def swap_using_xor(a: int, b: int) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def swap_using_xor(a: int, b: int) -> tuple: """ Swaps the values of two distinct integers using bitwise XOR operations. Args: a (int): The first integer. b (int): The second integer. Returns: t...
evol_instruct_66k
16,461
Write a Python function to determine if a given number is a perfect square. A perfect square is a number that can be expressed as the square of an integer. The function should return `True` if the number is a perfect square and `False` otherwise. The code should start with: ```python def is_perfect_square(n: int) -> bo...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_perfect_square(n: int) -> bool: """ Determines if a given number is a perfect square. Args: n (int): The number to check. Returns: bool: True if the number is a perfect square, False...
evol_instruct_66k
16,462
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...