source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
30,339
Write a Python function to remove all occurrences of a specified alphabet from an input text. The function should handle both uppercase and lowercase letters, ensuring that all instances of the specified alphabet, regardless of their case, are removed from the input text. The code should start with: ```python def remo...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_alphabet(text: str, alphabet: str) -> str: """ Removes all occurrences of a specified alphabet (case-insensitive) from the input text. Args: text (str): The input text from which the alphabet is to be rem...
evol_instruct_66k
30,356
Write a Python function to calculate the Euclidean distance between corresponding elements of two numerical arrays and store the results in a new array. Additionally, implement boundary tests to handle any possible faults in the data points of the arrays, such as non-numerical values or missing data points. The functio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def euclidean_distance_array(a: List[float], b: List[float]) -> List[float]: """ Calculate the Euclidean distance between corresponding elements of two numerical arrays. Args: a ...
evol_instruct_66k
30,386
Write a Python function to generate the first `n` numbers in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. The function should return a list containing the first `n` Fibonacci numbers. The code should start w...
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 first n numbers in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two precedi...
evol_instruct_66k
30,392
Write a Python function to convert any given string of text into its uppercase form. The function should handle various edge cases, such as empty strings, strings with special characters, and strings with numbers. The function should return the uppercase version of the input string. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_uppercase(text: str) -> str: """ Converts the given string of text into its uppercase form. Args: text (str): The input string to be converted to uppercase. Returns: str: The uppercase ve...
evol_instruct_66k
30,396
Write a Python function to determine whether two phrases have the exact same words, their order, and each word's frequency, all while ignoring the repetition and case of the words. The function should be robust and handle edge cases such as empty strings, phrases with different lengths, and phrases with repeated words....
Here is the Python code to solve the given problem in the markdown block: ```python def compare_word_sets_and_order(phrase1: str, phrase2: str) -> bool: """ Determine whether two phrases have the exact same set of words, their order, and the frequency of each word, while ignoring word repetition and case. ...
evol_instruct_66k
30,403
Write a Python function to implement the FizzBuzz game for numbers from 1 to n. The function should replace numbers divisible by 3 with the word "Fizz", numbers divisible by 5 with the word "Buzz", and numbers divisible by both 3 and 5 with the word "FizzBuzz". The function should only print one result for each number ...
Here is the Python code to solve the given problem in the markdown block: ```python def fizz_buzz(n: int) -> None: """ Implements the FizzBuzz game for numbers from 1 to n. For each number in the range: - If the number is divisible by both 3 and 5, print "FizzBuzz". - If the number is divisible by ...
evol_instruct_66k
30,410
Write a Python function to generate the Fibonacci sequence up to the nth term. The function should return a list containing the first n Fibonacci numbers. The code should start with: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the nth term. Args: n (int): The number of terms in the Fibonacci sequence to generate. Returns: ...
evol_instruct_66k
30,422
Write a Python function to compute the net price of a product after applying a discount. The function should take the base cost of the product and the discount percentage as inputs and return the net price after the discount is applied. The function should handle cases where the discount percentage is zero or negative....
Here is the Python code to solve the given problem in the markdown block: ```python def compute_net_price(base_cost: float, discount_percent: float) -> float: """ Compute the net price of a product after applying a discount. Args: base_cost (float): The base cost of the product. discount_pe...
evol_instruct_66k
30,423
Write a Python function to recursively sum all the individual elements within a multi-level nested list structure. The function should handle lists of arbitrary depth and should sum all the integers found at any level of nesting. The code should start with: ```python from typing import List def recursive_sum(arr: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def recursive_sum(arr: List) -> int: """ Recursively sums all the individual elements within a multi-level nested list structure. Args: arr (List): A list containing integers and/or nested l...
evol_instruct_66k
30,431
Write a Python function to generate the first `n` elements of a geometric progression where each element is double the previous one. Additionally, write a function to find the element at a specified index in the generated array. Both functions should include proper input validation and error handling. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def geometric_progression(n: int) -> List[int]: """ Generate a geometric progression where each element is double the previous one. Args: n (int): The number of elements to generate. Re...
evol_instruct_66k
30,432
Write a Python function to determine if there exists a pair of indices (i, j) such that the elements at these indices in two given arrays `A` and `B` are equal. If such a pair exists, return `True` and the indices; otherwise, return `False` and an empty tuple. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_matching_indices(A: List[int], B: List[int]) -> Tuple[bool, Tuple[int, int]]: """ Determine if there exists a pair of indices (i, j) such that A[i] == B[j]. Args: A (List[int...
evol_instruct_66k
30,437
Write a Python function to sort a given list of whole numbers in ascending order. The function should take a list of integers as input and return the sorted list. The code should start with: ```python from typing import List def sort_list_of_numbers(numbers: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_list_of_numbers(numbers: List[int]) -> List[int]: """ Sorts a given list of whole numbers in ascending order. Args: numbers (List[int]): The list of whole numbers to be sorted. ...
evol_instruct_66k
30,442
Write a Python function to find the maximum value in a given list of integers in one pass. The function should handle an empty list by returning `None`. The code should start with: ```python from typing import List, Optional def find_max_in_one_pass(nums: List[int]) -> Optional[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Optional def find_max_in_one_pass(nums: List[int]) -> Optional[int]: """ Find the maximum value in a given list of integers in one pass. Args: nums (List[int]): The list of integers from ...
evol_instruct_66k
30,459
Write a Python function to transpose a given matrix, where the rows of the original matrix become the columns of the transposed matrix and vice versa. The function should handle matrices of any dimensions. The code should start with: ```python from typing import List def transpose_matrix(matrix: List[List[int]]) -> L...
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, converting its rows to columns and columns to rows. Args: matrix (List[List[int]]): The ori...
evol_instruct_66k
30,473
Write a Python function to categorize temperature readings into unique labels based on predefined temperature ranges. The function should return a string representing the category label for the given temperature. The temperature ranges and corresponding labels are as follows: - "Cold" for temperatures between 32 and 50...
Here is the Python code to solve the given problem in the markdown block: ```python def categorize_temperature(temperature: float) -> str: """ Categorizes a temperature reading into one of three unique labels based on predefined ranges. Args: temperature (float): The temperature reading to be categ...
evol_instruct_66k
30,474
Write a Python function to convert a JSON representation of an HTML document back to its original HTML format. The JSON structure represents the tree-like structure of an HTML document, including tags, attributes, and text content. The function should handle self-closing tags and maintain the order of attributes. The ...
Here is the Python code to solve the given problem in the markdown block: ```python import json from typing import Dict, List, Union def json_to_html(json_data: Union[Dict, List]) -> str: """ Converts a JSON representation of an HTML document back to its original HTML format. Args: json_data (Unio...
evol_instruct_66k
30,476
Write a Python function to reverse the order of elements in a given list. The function should take a list as input and return a new list with the elements in reverse order. The original list should not be modified. The code should start with: ```python from typing import List def reverse_list(input_list: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(input_list: List[int]) -> List[int]: """ Reverses the order of elements in the given list and returns a new list with the reversed elements. Args: input_list (List[int]): Th...
evol_instruct_66k
30,490
Write a Python function to generate a list of words from a given sentence, excluding specified prepositions and conjunctions while preserving the order of the remaining words. The function should start with: ```python from typing import List def generate_filtered_word_list(sentence: str, ignore_words: List[str]) -> Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_filtered_word_list(sentence: str, ignore_words: List[str]) -> List[str]: """ Generates a list of words from the given sentence, excluding specified prepositions and conjunctions. Args: ...
evol_instruct_66k
30,492
Write a Python function to count the occurrences of each alphabetic character in a given string and return the result as a dictionary. The function should ignore non-alphabetic characters and be case-insensitive, treating 'A' and 'a' as the same character. The code should start with: ```python from typing import Dict ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_alphabetic_chars(text: str) -> Dict[str, int]: """ Counts the occurrences of each alphabetic character in the given string, ignoring case and non-alphabetic characters. Args: text ...
evol_instruct_66k
30,499
Write a Python function to generate a dictionary named `vehicles` and populate it with five key-value pairs. The keys should be vehicle types (e.g., 'Car', 'Motorcycle') and the values should be the corresponding vehicle brands (e.g., 'Toyota', 'Harley Davidson'). The function should return the populated dictionary. T...
Here is the Python code to solve the given problem in the markdown block: ```python def create_vehicles_dictionary() -> dict: """ Generates a dictionary named 'vehicles' and populates it with five key-value pairs. The keys are vehicle types and the values are the corresponding vehicle brands. Returns: ...
evol_instruct_66k
30,501
Write a Python function to recursively traverse a nested dictionary and compute the sum of all numerical values contained within it. The dictionary can have an arbitrary number of nested layers. The function should start with: ```python from typing import Dict def sum_nested_numbers(dictionary: Dict) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sum_nested_numbers(dictionary: Dict) -> int: """ Recursively traverse a nested dictionary and compute the sum of all numerical values. Args: dictionary (Dict): The nested dictionary to t...
evol_instruct_66k
30,510
Write a Python function to transform a given alphanumeric string into a list of its individual characters. The function should handle any string input, including empty strings and strings with special characters. The function should be efficient and use Python's built-in capabilities to achieve the transformation. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def string_to_char_list(text_string: str) -> List[str]: """ Transforms a given alphanumeric string into a list of its individual characters. Args: text_string (str): The input string to be t...
evol_instruct_66k
30,514
Write a Python function to generate a SQL command that deletes all records with the "Inactive" status from a 'users' table in MySQL, ensuring relational integrity is maintained. Additionally, write a script that logs this action with a timestamp, the number of records deleted, and the user who performed the action. The...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def generate_delete_sql(table_name: str, status_column: str, status_value: str) -> str: """ Generates a SQL DELETE command to remove records with a specific status from a table, ensuring relational...
evol_instruct_66k
30,515
Write a Python function to determine if one string is a subsequence of another string. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. The code should start with: ```python def is_subsequence(str1: str, str2: st...
Here is the Python code to solve the given problem in the markdown block: ```python def is_subsequence(str1: str, str2: str) -> bool: """ Determines if one string is a subsequence of another string. Args: str1 (str): The subsequence candidate. str2 (str): The string in which to check for th...
evol_instruct_66k
30,522
Write a Python function to integrate two novel constituents at the initial position of an existing array without altering the sequential order of the remaining elements. The function should take two parameters: the original list and a list of new elements to be added at the beginning. The function should return the mod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def integrate_new_elements(original_list: List[str], new_elements: List[str]) -> List[str]: """ Integrates the new elements at the beginning of the original list without altering the sequential order of ...
evol_instruct_66k
30,524
Write a Python function to generate the first n perfect cubes and return them in a list. A perfect cube is a number that is the cube of an integer. The function should start with: ```python from typing import List def generate_perfect_cubes(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_perfect_cubes(n: int) -> List[int]: """ Generate the first n perfect cubes and return them in a list. Args: n (int): The number of perfect cubes to generate. Returns: ...
evol_instruct_66k
30,539
Write a Python function to find the pair of numbers with the largest difference in a given list of numbers. The function should return the pair as a tuple, where the first element is the smallest number and the second element is the largest number in the list. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_largest_difference_pair(numbers: List[int]) -> Tuple[int, int]: """ Finds the pair of numbers with the largest difference in a given list of numbers. Args: numbers (List[int]...
evol_instruct_66k
30,542
Write a Python function to concatenate two given strings in the order they are provided without altering their original form. The function should return the concatenated string. The code should start with: ```python def concatenate_strings(string1: str, string2: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_strings(string1: str, string2: str) -> str: """ Concatenates two given strings in the order they are provided without altering their original form. Args: string1 (str): The first string to concatenat...
evol_instruct_66k
30,545
Write a Python function to create a new list where each element is derived from the initial and terminal integer values of each subarray found within a given two-dimensional array. The function should take a 2D list as input and return a new 2D list with the specified elements. 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 def extract_first_last_elements(two_d_array: List[List[int]]) -> List[List[int]]: """ Extracts the first and last elements from each subarray in a given 2D array. Args: two_d_array (List[Lis...
evol_instruct_66k
30,547
Write a Python function to remove all occurrences of a specified item from a given list. The function should return a new list with all instances of the specified item removed. The code should start with: ```python from typing import List def remove_all_occurrences(lst: List[int], item_to_remove: int) -> List[int]: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_all_occurrences(lst: List[int], item_to_remove: int) -> List[int]: """ Removes all occurrences of a specified item from a given list. Args: lst (List[int]): The list from which to...
evol_instruct_66k
30,566
Write a Python function to compute the Lowest Common Multiple (LCM) of three integers. The function should be able to handle any positive integers and should return the LCM. The code should start with: ```python def compute_lcm_of_three(x: int, y: int, z: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def compute_lcm_of_three(x: int, y: int, z: int) -> int: """ Compute the Lowest Common Multiple (LCM) of three integers. Args: x (int): The first integer. y (int): The second integer. z (int): The th...
evol_instruct_66k
30,584
Write a Python function to remove all key-value pairs from a dictionary where the keys start with the string sequence "item". The function should return the modified dictionary. The code should start with: ```python from typing import Dict def remove_items_with_prefix(data: Dict[str, str]) -> Dict[str, str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def remove_items_with_prefix(data: Dict[str, str]) -> Dict[str, str]: """ Removes all key-value pairs from the dictionary where the keys start with the string sequence "item". Args: data (Di...
evol_instruct_66k
30,586
Write a Python function to validate whether a given two-dimensional array of integers represents a palindromic sequence both row-wise and column-wise. The array must also have an odd length when combined row-wise or column-wise. The function should handle arrays of varying lengths (up to N dimensions where N > 2) and p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_palindromic_matrix(arr: List[List[int]]) -> bool: """ Validates whether a given two-dimensional array of integers represents a palindromic sequence both row-wise and column-wise. The array mus...
evol_instruct_66k
30,596
Write a Python function to extract the domain component from an email address. The email address is in the format `username@domain.com`. The function should handle various valid email formats and return the domain part of the email address. The code should start with: ```python def extract_domain(email: str) -> str: `...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_domain(email: str) -> str: """ Extracts the domain component from a given email address. Args: email (str): The email address from which to extract the domain. Returns: str: The domain part ...
evol_instruct_66k
30,602
Write a Python function to construct a File Transfer Protocol (FTP) address by combining a given username, server name, and directory path. The function should ensure that these elements are concatenated in a valid and standardized format. The code should start with: ```python def construct_ftp_address(username: str, s...
Here is the Python code to solve the given problem in the markdown block: ```python def construct_ftp_address(username: str, server: str, directory: str) -> str: """ Constructs a File Transfer Protocol (FTP) address by combining the given username, server name, and directory path. Args: username (s...
evol_instruct_66k
30,610
Write a Python function to compute the cumulative sum of a given tuple of integers. The function should return a new tuple where each element is the cumulative sum of the elements up to that index in the original tuple. The code should start with: ```python from typing import Tuple def cumulative_sum(arr: Tuple[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def cumulative_sum(arr: Tuple[int]) -> Tuple[int]: """ Compute the cumulative sum of a given tuple of integers. Args: arr (Tuple[int]): A tuple of integers for which the cumulative sum is t...
evol_instruct_66k
30,651
Write a Python function to check whether an input string is a palindrome using a regular expression. The function should be case and whitespace insensitive, meaning it should recognize strings like "Race car" as palindromes. The function should start with: ```python import re def is_palindrome(input_string: str) -> bo...
Here is the Python code to solve the given problem in the markdown block: ```python import re def is_palindrome(input_string: str) -> bool: """ Check whether the input string is a palindrome using a regular expression. The function is case and whitespace insensitive. Args: input_string (str): ...
evol_instruct_66k
30,653
Write a Python function to determine if one character string (`subseq`) is a subsequence of another character string (`seq`). A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. The function should return `True` if `...
Here is the Python code to solve the given problem in the markdown block: ```python def is_subsequence(subseq: str, seq: str) -> bool: """ Determines if the string `subseq` is a subsequence of the string `seq`. Args: subseq (str): The subsequence string to check. seq (str): The main sequenc...
evol_instruct_66k
30,664
Write a Python function to perform a linear search on a given array to find the index of a specified target element. If the target element is not found, the function should return -1. The function should be efficient and handle various edge cases, such as an empty array or a target not present in the array. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def linear_search(arr: List[int], target: int) -> int: """ Perform a linear search to find the index of a specified target element in the array. Args: arr (List[int]): The array in which to ...
evol_instruct_66k
30,666
Write a Python function to calculate the sum of the first `n` natural numbers efficiently, considering the limitations of integer overflow. Implement a custom function to perform the addition operation to maintain precision with large numbers. The code should start with: ```python def sum_of_first_n_numbers(n: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_first_n_numbers(n: int) -> int: """ Calculate the sum of the first n natural numbers efficiently, considering the limitations of integer overflow. Args: n (int): The number of natural numbers to sum. ...
evol_instruct_66k
30,674
Write a Python function to calculate the time at which each ball reaches its maximum height given an array of initial velocities. Each ball's height is described by the quadratic equation \( h = -16t^2 + vt + 10 \), where \( v \) is the initial upward velocity. The function should also determine which ball reaches the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_max_height_times(velocities: List[int]) -> Tuple[List[float], int, float]: """ Calculate the time at which each ball reaches its maximum height given an array of initial velocities. ...
evol_instruct_66k
30,686
Write a Python function to find the name with the minimum frequency in a given dictionary of names and their respective frequencies. If multiple names have the same minimum frequency, return the name that is alphabetically first. The code should start with: ```python from typing import Dict def find_min_frequency_nam...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def find_min_frequency_name(name_frequency: Dict[str, int]) -> str: """ Find the name with the minimum frequency in a given dictionary of names and their respective frequencies. If multiple names hav...
evol_instruct_66k
30,695
Write a Python function to determine if a given integer can be expressed as an integer power of another integer. The function should return `True` if the input number can be represented as \( a^b \) where both \( a \) and \( b \) are integers greater than 1, and `False` otherwise. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_exponential_power(n: int) -> bool: """ Determines if a given integer can be expressed as an integer power of another integer. Args: n (int): The integer to check. Returns: bool: True...
evol_instruct_66k
30,704
Write a Python function to calculate the cumulative total of the numerical components embedded within a specified list of singular values. The list may contain both integers and strings. The function should sum only the integers and ignore any non-integer values. The code should start with: ```python from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_total(values: List[int]) -> int: """ Calculate the cumulative total of the numerical components (integers) embedded within a specified list of singular values. Args: values (L...
evol_instruct_66k
30,705
Write a Python function to demonstrate De Morgan's Laws using bitwise operations on four distinct integer variables: `alpha`, `beta`, `gamma`, and `delta`. The function should perform two bitwise operations: the first operation should be between `alpha` and `beta` to assign the result to `gamma`, and the second operati...
Here is the Python code to solve the given problem in the markdown block: ```python def demonstrate_de_morgans_laws(alpha: int, beta: int, delta: int) -> bool: """ Demonstrates De Morgan's Laws using bitwise operations on the given integers. Args: alpha (int): The first integer. beta (int):...
evol_instruct_66k
30,712
Write a Python function to determine if a given year is a leap year in both the Gregorian and Julian calendar systems. The function should return a dictionary with two keys: `"Gregorian"` and `"Julian"`, each containing a boolean value indicating whether the year is a leap year in the respective calendar system. The c...
Here is the Python code to solve the given problem in the markdown block: ```python def is_leap_year(year: int) -> dict: """ Determines if a given year is a leap year in both the Gregorian and Julian calendar systems. Args: year (int): The year to check. Returns: dict: A dictionary wit...
evol_instruct_66k
30,715
Write a Python function to create a two-dimensional matrix of given dimensions `m` and `n`, and populate it with a specified uniform value. The function should return the constructed matrix. The code should start with: ```python from typing import List def create_uniform_matrix(m: int, n: int, value: float) -> List[L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def create_uniform_matrix(m: int, n: int, value: float) -> List[List[float]]: """ Creates a two-dimensional matrix of dimensions m x n, populated with a specified uniform value. Args: m (int...
evol_instruct_66k
30,719
Write a Python function to validate the Fundamental Theorem of Arithmetic for a given composite number using a predefined tuple of prime numbers. The function should decompose the composite number into its prime factors and return a list of these factors. The code should start with: ```python from typing import List, T...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def decompose_into_prime_factors(composite_number: int, prime_tuple: Tuple[int, ...]) -> List[int]: """ Decomposes a composite number into its prime factors using a predefined tuple of prime numbe...
evol_instruct_66k
30,728
Write a Python function to find all instances of multiples of a distinct integer `n` within a given range defined by `lower_limit` and `upper_limit`. The function should consider edge cases where the boundaries could either include or exclude the designated limits. The function should return a list of all such multiple...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def find_multiples_in_range(n: int, lower_limit: int, upper_limit: int) -> List[int]: """ Find all multiples of a distinct integer `n` within the given range [lower_limit, upper_limit]. ...
evol_instruct_66k
30,729
Write a Python function to identify all distinct alphabetical characters present in two given alphanumeric sequences. The function should be case-sensitive and ignore any non-alphabet characters. The function should return a set of unique alphabetical characters found in both sequences. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def unique_alphabetical_elements(string1: str, string2: str) -> set: """ Identify all distinct alphabetical characters present in two given alphanumeric sequences. The function is case-sensitive and ignores any non-alphabet ...
evol_instruct_66k
30,733
Write a Python function to transform a sequence of hexadecimal character strings into an equivalent representation as a binary numeral, and another function to revert the binary numeral back to the original hexadecimal representation. The solution should be optimized to handle large inputs efficiently. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hex_to_bin(hex_str_list: List[str]) -> List[str]: """ Transform a sequence of hexadecimal character strings into an equivalent representation as a binary numeral. Args: hex_str_list (Lis...
evol_instruct_66k
30,739
Write a Python function to replace all instances of the number zero with the number one in a given list of integers. The function should return a new list with the replacements made. The code should start with: ```python from typing import List def replace_zeros_with_ones(input_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def replace_zeros_with_ones(input_list: List[int]) -> List[int]: """ Replaces all instances of the number zero with the number one in a given list of integers. Args: input_list (List[int])...
evol_instruct_66k
30,763
Write a Python function to implement the selection sort algorithm to sort a given list of integers in ascending order. The function should modify the input list in place and return the sorted list. The code should start with: ```python from typing import List def selection_sort(lst: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def selection_sort(lst: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the selection sort algorithm. Args: lst (List[int]): The list of integers to be sorted....
evol_instruct_66k
30,768
Write a Python function to iterate over each item in a given dictionary and return a list of tuples where each tuple contains a key and its corresponding value from the dictionary. The function should handle dictionaries with any number of key-value pairs. The code should start with: ```python from typing import Dict,...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def iterate_dictionary(d: Dict[str, int]) -> List[Tuple[str, int]]: """ Iterates over each item in the given dictionary and returns a list of tuples. Each tuple contains a key and its co...
evol_instruct_66k
30,771
Write a Python function to generate the Fibonacci sequence up to a given limit `n` (inclusive) and another function to check if a given number is a Fibonacci number. The Fibonacci sequence should be generated efficiently in terms of both time and space complexity. The code should start with: ```python from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union import math def generate_fibonacci_sequence(n: int) -> List[int]: """ Generate the Fibonacci sequence up to a given limit n (inclusive). Args: n (int): The upper limit for the Fibonac...
evol_instruct_66k
30,787
Write a Python function to generate a dictionary that maps student names to their academic performance metrics. Each student's performance should be represented as a nested dictionary with keys for different subjects and values for the corresponding grades. The function should accept a list of tuples, where each tuple ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def generate_student_performance(students: List[Tuple[str, int, int, int]]) -> Dict[str, Dict[str, int]]: """ Generates a dictionary that maps student names to their academic performance met...
evol_instruct_66k
30,797
Write a Python function to calculate the number of unique combinations of various lengths for a given set without repetition, including empty subsets. The function should work with sets containing numbers, strings, and mixed data types. The code should start with: ```python from typing import Set, List, Any def count_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Set, List, Any from itertools import chain, combinations def count_unique_combinations(my_set: Set[Any]) -> int: """ Calculate the number of unique combinations of various lengths for a given set without repe...
evol_instruct_66k
30,802
Write a Python function to count the number of characters in a given string, excluding spaces and punctuation. The function should only count alphabetic characters (both uppercase and lowercase) and digits. The code should start with: ```python from typing import List def count_alphanumeric_chars(text: str) -> int: ``...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def count_alphanumeric_chars(text: str) -> int: """ Counts the number of alphanumeric characters in the given string. Args: text (str): The input string to count alphanumeric characters fr...
evol_instruct_66k
30,812
Write a Python function to detect and remove duplicates from a given list of integers. The function should return a new list with all duplicate elements removed, while maintaining the order of the first occurrence of each element. The code should start with: ```python from typing import List def remove_duplicates(arr...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def remove_duplicates(arr: List[int]) -> List[int]: """ Removes duplicates from a given list of integers while preserving the order of the first occurrence of each element. Args: arr (List...
evol_instruct_66k
30,822
Write a Python function to identify all numbers in a given list that are divisible by 3 and encapsulate the uniform attribute of divisibility by 3. The function should return a list of these numbers. The code should start with: ```python from typing import List def find_divisible_by_3(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 find_divisible_by_3(numbers: List[int]) -> List[int]: """ Identifies all numbers in the given list that are divisible by 3. Args: numbers (List[int]): The list of integers to be checked....
evol_instruct_66k
30,839
Write a Python function to convert a boolean value to its alphabetic equivalence, where `True` is represented as 'Yes' and `False` is represented as 'No'. The function should take a boolean value as input and return the corresponding string. The code should start with: ```python def boolean_to_string(value: bool) -> s...
Here is the Python code to solve the given problem in the markdown block: ```python def boolean_to_string(value: bool) -> str: """ Converts a boolean value to its alphabetic equivalence. Args: value (bool): The boolean value to convert. Returns: str: The string 'Yes' if the input is Tr...
evol_instruct_66k
30,847
Write a Python function to sort a given list in ascending order using a custom sorting algorithm. The sorting must be implemented from scratch and cannot use Python's built-in sorting functions. The function should be able to handle various edge cases, such as empty lists, lists with duplicate elements, and lists with ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_sort(my_list: List[int]) -> List[int]: """ Sorts a given list in ascending order using the Bubble Sort algorithm. Args: my_list (List[int]): The list of integers to be sorted. ...
evol_instruct_66k
30,850
Write a Python function to evaluate the aggregation sum of a numerical matrix incrementally. The matrix can contain real or complex numbers. The function should start with: ```python from typing import List, Union def incremental_sum(matrix: List[Union[int, float, complex]]) -> Union[int, float, complex]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Union def incremental_sum(matrix: List[Union[int, float, complex]]) -> Union[int, float, complex]: """ Evaluate the aggregation sum of a numerical matrix incrementally. Args: matrix (List...
evol_instruct_66k
30,855
Write a Python function to reverse the order of keys in a given dictionary. The function should return a new dictionary with the keys in reverse order, while maintaining the original key-value pairs. The code should start with: ```python from typing import Dict def reverse_dictionary_keys(dictionary: Dict[str, int]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def reverse_dictionary_keys(dictionary: Dict[str, int]) -> Dict[str, int]: """ Reverses the order of keys in a given dictionary while maintaining the original key-value pairs. Args: dictiona...
evol_instruct_66k
30,858
Write a Python function to determine if a given string contains both an exclamation mark "!" and a question mark "?" in any order. The function should use regular expressions to perform this check efficiently. The code should start with: ```python import re def has_exclamation_and_question(s: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def has_exclamation_and_question(s: str) -> bool: """ Determine if a given string contains both an exclamation mark "!" and a question mark "?" in any order. Args: s (str): The input string to be checked....
evol_instruct_66k
30,871
Write a Python function to create a dictionary from a list of tuples, where each tuple contains a key-value pair. The function should handle cases where the input list might be empty or contain duplicate keys. If there are duplicate keys, the function should retain the last occurrence of each key in the resulting dicti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def create_dict_from_tuples(components: List[Tuple[str, int]]) -> dict: """ Creates a dictionary from a list of tuples, where each tuple contains a key-value pair. If there are duplicate keys,...
evol_instruct_66k
30,874
Write a Python function to display the elements of a given list in reverse order, with each element repeated twice. Adjacent repetitions should be separated by an asterisk. Each element and its repetition should be on a new line. Additionally, if the element is even, append the string " - even" to the output line. If i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def format_reverse_elements(nums: List[int]) -> str: """ Formats the elements of a given list in reverse order, with each element repeated twice. Adjacent repetitions are separated by an asterisk. Ea...
evol_instruct_66k
30,875
Write a Python function to group and sort a list of books by multiple keys using the `itertools.groupby` function. The function should take a list of dictionaries, where each dictionary represents a book with keys `"author"`, `"title"`, and `"year_published"`. The function should return a list of tuples, where each tup...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple from itertools import groupby from operator import itemgetter def group_books_by_author_and_year(books: List[Dict[str, str]]) -> List[Tuple[Tuple[str, int], List[Dict[str, str]]]]: """ Group...
evol_instruct_66k
30,877
Write a Python function to check if one set is a subset of another without using Python set methods. The function should be efficient and correctly determine if every element in the first set is present in the second set. The function should return `True` if the first set is a subset of the second and `False` otherwise...
Here is the Python code to solve the given problem in the markdown block: ```python def is_subset(s1: set, s2: set) -> bool: """ Check if the first set is a subset of the second set without using Python set methods. Args: s1 (set): The first set to check. s2 (set): The second set to check a...
evol_instruct_66k
30,885
Write a Python function to sort a list of strings using the bubble sort algorithm. The function should ensure that the comparison and swapping of adjacent elements are done carefully to achieve the correct order. The code should start with: ```python from typing import List def bubble_sort_strings(lst: List[str]) -> L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort_strings(lst: List[str]) -> List[str]: """ Sorts a list of strings using the bubble sort algorithm. Args: lst (List[str]): The list of strings to be sorted. Returns: ...
evol_instruct_66k
30,886
Write a Python function to break a given string into words and return the list of words. The function should handle various edge cases, such as strings with multiple spaces, leading and trailing spaces, and empty strings. The code should start with: ```python from typing import List def split_string_into_words(s: str)...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string_into_words(s: str) -> List[str]: """ Splits a given string into a list of words. Args: s (str): The input string to be split into words. Returns: List[str]: A l...
evol_instruct_66k
30,900
Write a Python function to generate a multiplication table for numbers up to a given limit `n`. The function should return a list of strings, where each string represents a multiplication operation in the format "i x j = product". The function should start with: ```python from typing import List def generate_multiplic...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_multiplication_table(n: int) -> List[str]: """ Generates a multiplication table for numbers up to a given limit `n`. Args: n (int): The limit up to which the multiplication tabl...
evol_instruct_66k
30,901
Write a Python function to determine if a given list of integers is an arithmetic progression. An arithmetic progression is a sequence of numbers such that the difference between the consecutive terms is constant. The function should return `True` if the list is an arithmetic progression, and `False` otherwise. The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_arithmetic_progression(lst: List[int]) -> bool: """ Determines if a given list of integers is an arithmetic progression. An arithmetic progression is a sequence of numbers such that the diffe...
evol_instruct_66k
30,917
Write a Python function to find the total number of common characters present in both strings. The function should take two strings as input and return an integer representing the total number of common characters. The function should consider the frequency of each character in both strings. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python def count_common_characters(str1: str, str2: str) -> int: """ Calculate the total number of common characters present in both strings. Args: str1 (str): The first string. str2 (str): The second string. ...
evol_instruct_66k
30,923
Write a Python function to count the number of integers between 1 and a given upper limit `n` that are divisible by 3. The function should use a while loop to iterate through the numbers and increment a counter each time a number is divisible by 3. The code should start with: ```python def count_divisible_by_3(n: int) ...
Here is the Python code to solve the given problem in the markdown block: ```python def count_divisible_by_3(n: int) -> int: """ Counts the number of integers between 1 and n (inclusive) that are divisible by 3. Args: n (int): The upper limit of the range to check. Returns: int: The co...
evol_instruct_66k
30,932
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 code 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
30,933
Write a Python function to separate a list of integers into two lists: one containing all even numbers and the other containing all odd numbers. The function should return a tuple with the two lists. The code should start with: ```python from typing import List, Tuple def separate_parity(array: List[int]) -> Tuple[Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def separate_parity(array: List[int]) -> Tuple[List[int], List[int]]: """ Separates a list of integers into two lists: one containing all even numbers and the other containing all odd numbers. ...
evol_instruct_66k
30,935
Write a Python function to calculate the sum of two numbers. The function should take two parameters and return their sum. Additionally, write a function to calculate the product of two numbers. The function should also take two parameters and return their product. The code should start with: ```python def sum_two_numb...
Here is the Python code to solve the given problem in the markdown block: : ```python def sum_two_numbers(num1: float, num2: float) -> float: """ Calculate the sum of two numbers. Args: num1 (float): The first number. num2 (float): The second number. Returns: float: The sum of ...
evol_instruct_66k
30,939
Write a Python function to manipulate a 2D matrix consisting of integer elements. The function should perform the following operations: 1. Display the original matrix. 2. Transpose the matrix. 3. Output a new matrix whose elements are the squares of the corresponding elements in the original matrix. The initial matrix...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def manipulate_matrix(matrix: List[List[int]]) -> None: """ Manipulates a 2D matrix consisting of integer elements. The function performs the following operations: 1. Displays the original matri...
evol_instruct_66k
30,946
Write a Python function to sort a list of integers based on a given order ('asc' for ascending or 'desc' for descending). However, for numbers that are multiples of 3, group and sort them at the rightmost side of the arranged list. Preserve the original order for all multiples of 3. 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 sort_numbers_with_multiples_of_3(lst: List[int], order: str) -> List[int]: """ Sorts a list of integers based on the given order ('asc' for ascending or 'desc' for descending). Numbers that are m...
evol_instruct_66k
30,951
Write a Python function to generate a list of tuples where each tuple contains an element from list `a` and an element from list `b`. The function should use list comprehension to achieve this. The code should start with: ```python from typing import List, Tuple def generate_combinations(a: List[int], b: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_combinations(a: List[int], b: List[int]) -> List[Tuple[int, int]]: """ Generate a list of tuples where each tuple contains one element from list `a` and one element from list `b`. ...
evol_instruct_66k
30,954
Write a Python function to reverse the order of words in a given string. The function should take a string `text` as input and return a new string with the words in the reverse order. The words in the input string are separated by spaces. The function should handle multiple spaces between words and leading/trailing spa...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_words_in_string(text: str) -> str: """ Reverses the order of words in a given string. Args: text (str): The input string containing words separated by spaces. Returns: str: A new string with...
evol_instruct_66k
30,963
Write a Python function to merge overlapping intervals from a given list of intervals. Each interval is represented as a list of two integers, where the first integer is the start of the interval and the second integer is the end of the interval. The function should return a list of merged intervals. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_intervals(intervals: List[List[int]]) -> List[List[int]]: """ Merge overlapping intervals from a given list of intervals. Args: intervals (List[List[int]]): A list of intervals, wh...
evol_instruct_66k
30,969
Write a Python function to find the least significant number in a given list of five unique integers. The least significant number is defined as the number with the smallest value in the list. The function should return this number. The code should start with: ```python from typing import List def find_least_signific...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_least_significant_number(numbers: List[int]) -> int: """ Finds the least significant number in a list of five unique integers. Args: numbers (List[int]): A list of exactly five uniq...
evol_instruct_66k
30,971
Write a Python function to create a dictionary that amalgamates the respective countries along with their aggregate population count. The countries intended for integration within the dictionary are as follows: "USA", "Canada", "India", "China", and "Japan". The function should return the dictionary. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python def create_population_dictionary() -> dict: """ Creates a dictionary that amalgamates the respective countries along with their aggregate population count. Returns: dict: A dictionary where the keys are country name...
evol_instruct_66k
30,972
Write a Python function to convert a given temperature in Fahrenheit to Celsius. The function should take a single argument representing the temperature in Fahrenheit and return the corresponding temperature in Celsius. The formula to convert Fahrenheit to Celsius is: \[ \text{Celsius} = \left( \text{Fahrenheit} - 32 ...
Here is the Python code to solve the given problem in the markdown block: ```python def fahrenheit_to_celsius(fahrenheit: float) -> float: """ Convert a temperature from Fahrenheit to Celsius. Args: fahrenheit (float): The temperature in Fahrenheit. Returns: float: The temperature in C...
evol_instruct_66k
30,973
Write a Python function to extend a given list of numbers by adding all odd numbers from 0 to 100, ensuring the result list is in ascending sorted order and contains no duplicate entries. The function should start with: ```python from typing import List def extend_list_with_odds(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 extend_list_with_odds(num_list: List[int]) -> List[int]: """ Extends the given list of numbers by adding all odd numbers from 0 to 100, ensuring the result list is in ascending sorted order and c...
evol_instruct_66k
30,974
Write a Python function to convert a dictionary with distinct key-value pairs into a list of string elements, preserving the original pairing structure. Each string element in the list should be formatted as `key: value`. The function should handle dictionaries with various types of values, including strings, integers,...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def convert_dict_to_list(dictionary: Dict[str, any]) -> List[str]: """ Convert a dictionary with distinct key-value pairs into a list of string elements. Each string element in the list is form...
evol_instruct_66k
30,981
Write a Python function to remove all punctuation marks from a given ASCII-encoded English statement. The function should efficiently handle any string input and return the cleaned string without any punctuation. The code should start with: ```python import string def remove_punctuation(sentence: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python import string def remove_punctuation(sentence: str) -> str: """ Removes all punctuation marks from the given ASCII-encoded English statement. Args: sentence (str): The input string from which punctuation marks need...
evol_instruct_66k
31,012
Write a Python function to find the largest number among four given integers. The function should compare the numbers directly without using Python's built-in `max` function or any other library functions that directly solve the problem. The function should start with: ```python def find_largest_number(a: int, b: int, ...
Here is the Python code to solve the given problem in the markdown block: ```python def find_largest_number(a: int, b: int, c: int, d: int) -> int: """ Find the largest number among four given integers. Args: a (int): The first integer. b (int): The second integer. c (int): The thir...
evol_instruct_66k
31,019
Write a Python function to sort a list of integers in ascending order using the `sorted()` function and return the sorted list. Additionally, write another function to sort a list of integers in ascending order using the `sort()` method and return the original list after sorting. 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 sort_with_sorted(numbers: List[int]) -> List[int]: """ Sort the list of integers using the sorted() function and return the sorted list. Args: numbers (List[int]): The list of integers t...
evol_instruct_66k
31,030
Write a Python function to reverse the order of characters in a given string using an iterative approach. The function should start with: ```python def reverse_string(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def reverse_string(s: str) -> str: """ Reverses the order of characters in a given string using an iterative approach. Args: s (str): The input string to be reversed. Returns: str: The reversed string...
evol_instruct_66k
31,037
Write a Python function to generate a loop that iterates a specified number of times, printing a given phrase within each iteration. The function should accept two parameters: the number of iterations and the phrase to be printed. The code should start with: ```python def print_phrase_iterations(iterations: int, phrase...
Here is the Python code to solve the given problem in the markdown block: ```python def print_phrase_iterations(iterations: int, phrase: str) -> None: """ Prints a given phrase a specified number of times. Args: iterations (int): The number of times the phrase should be printed. phrase (str...
evol_instruct_66k
31,047
Write a Python function to flatten a nested list of integers into a single list. The nested list can have an arbitrary depth of nesting. The function should handle lists that contain integers or further nested lists. The code should start with: ```python from typing import List, Union def flatten_nested_list(nested_li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def flatten_nested_list(nested_list: List[Union[int, List]]) -> List[int]: """ Flattens a nested list of integers into a single list. Args: nested_list (List[Union[int, List]]): The n...
evol_instruct_66k
31,050
Write a Python function to count the number of distinct integers in a given list, considering repetitive occurrences. The function should return the count of unique integers in the list. The code should start with: ```python from typing import List def count_distinct_integers(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_distinct_integers(arr: List[int]) -> int: """ Count the number of distinct integers in a given list. Args: arr (List[int]): The list of integers from which to count distinct elemen...
evol_instruct_66k
31,057
Write a Python function to manipulate a list by extending it with another list and appending a sublist to it. The function should return the modified list. Additionally, explain the differences between the `extend` and `append` methods in Python lists. The code should start with: ```python from typing import List, Uni...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def manipulate_list(lst: List[Union[str, List[str]]]) -> List[Union[str, List[str]]]: """ Manipulate the given list by extending it with another list and appending a sublist. Args: ls...
evol_instruct_66k
31,064
Write a Python function to implement the Caesar Cipher encryption and decryption technique. The function should handle both uppercase and lowercase alphabetic characters, transposing them by a given number of positions in the alphabetical order. Special characters and non-alphabetic characters should remain unchanged. ...
Here is the Python code to solve the given problem in the markdown block: ```python def caesar_cipher(text: str, shift: int, decrypt: bool = False) -> str: """ Encrypts or decrypts the given text using the Caesar Cipher technique. Args: text (str): The text to be encrypted or decrypted. shi...
evol_instruct_66k
31,066
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):...
evol_instruct_66k
31,068
Write a Python function to extract all numerical figures from a given text string. The function should return a list of integers found in the text. The code should start with: ```python from typing import List import re def extract_numbers(text: str) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_numbers(text: str) -> List[int]: """ Extracts all numerical figures from the given text string and returns them as a list of integers. Args: text (str): The input text ...
evol_instruct_66k
31,083
Write a Python function to transform a given two-dimensional matrix into a one-dimensional list. The function should handle matrices of varying sizes and ensure that all elements are included in the resulting list in a row-major order. The code should start with: ```python from typing import List def flatten_matrix(ma...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def flatten_matrix(matrix: List[List[int]]) -> List[int]: """ Transforms a given two-dimensional matrix into a one-dimensional list. Args: matrix (List[List[int]]): A two-dimensional list (m...