source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_evol_110k
78,782
Write a Python function to create a 2D array of specified dimensions filled with a specified numerical value using the NumPy module. The function should allow the user to specify the number of rows, columns, and the value to fill the array with. The code should start with: ```python import numpy as np from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import Union def create_2d_array(rows: int, cols: int, fill_value: Union[int, float] = 0) -> np.ndarray: """ Create a 2D array of specified dimensions filled with a specified numerical value. ...
magic_evol_110k
78,786
Write a Python function to remove duplicates from a given list without using built-in functions such as `set`. The function should maintain the order of the elements as they appear in the original list. The code should start with: ```python from typing import List def remove_duplicates(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 remove_duplicates(lst: List[int]) -> List[int]: """ Removes duplicates from a list while maintaining the order of elements. Args: lst (List[int]): The list from which duplicates are to b...
magic_evol_110k
78,791
Write a Python function to compute the product of elements in a given list that satisfy a specified condition. The condition is provided as a lambda function. The function should start with: ```python from typing import List, Callable def compute_product_with_condition(lst: List[int], condition: Callable[[int], bool])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable def compute_product_with_condition(lst: List[int], condition: Callable[[int], bool]) -> int: """ Compute the product of elements in the given list that satisfy the specified condition. Arg...
magic_evol_110k
78,793
Write a Python function to count the number of vowel characters in a given string. The function should be case-insensitive and should consider both uppercase and lowercase vowels. The code should start with: ```python def count_vowels(text: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_vowels(text: str) -> int: """ Count the number of vowel characters in a given string. Args: text (str): The input string to count vowels from. Returns: int: The number of vowel characters in t...
magic_evol_110k
78,821
Write a Python function to format a list of items by adding a comma after each item except the last one. The function should take a list of strings as input and return a single formatted string. The code should start with: ```python from typing import List def format_list_with_commas(items: List[str]) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def format_list_with_commas(items: List[str]) -> str: """ Formats a list of strings by adding a comma after each item except the last one. Args: items (List[str]): A list of strings to be fo...
magic_evol_110k
78,840
Write a Python function to generate an SVG animation that creates a trail or motion effect behind a given SVG shape. The function should take the SVG path data, the number of trail elements, and the animation duration as inputs. The function should return a string containing the SVG markup with the trail effect. The c...
Here is the Python code to solve the given problem in the markdown block: ```python def create_trail_effect(svg_path: str, num_trails: int, duration: float) -> str: """ Generates an SVG animation with a trail effect behind a given SVG shape. Args: svg_path (str): The SVG path data describing the sh...
magic_evol_110k
78,841
Write a Python function to remove recurring elements from a given numerical array while preserving the order of first occurrences. The function should not use sets or built-in functions like `set()` or `dict.fromkeys()`. The function should start with: ```python from typing import List def remove_duplicates_preserve_o...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_preserve_order(input_list: List[int]) -> List[int]: """ Removes recurring elements from a given numerical array while preserving the order of first occurrences. Args: i...
magic_evol_110k
78,857
Write a Python function to categorize a given integer value into one of three categories: "low", "medium", or "high". The categorization should follow the following rules: - Values from 1 to 3 should be categorized as "low". - Values from 4 to 6 should be categorized as "medium". - Values from 7 to 9 should be categori...
Here is the Python code to solve the given problem in the markdown block: ```python def categorize_value(value: int) -> str: """ Categorizes an integer value into one of three categories: "low", "medium", or "high". Args: value (int): The integer value to be categorized. Returns: str: ...
magic_evol_110k
78,871
Write a Python function that increments the value of a given parameter by 1 and returns the incremented value. The function should be designed to work with multiple variables, ensuring that the original variables are updated with the incremented values. The code should start with: ```python def increment_value(value: i...
Here is the Python code to solve the given problem in the markdown block: ```python def increment_value(value: int) -> int: """ Increments the given integer value by 1 and returns the incremented value. Args: value (int): The integer value to be incremented. Returns: int: The increment...
magic_evol_110k
78,894
Write a Python function to filter and sort a list of records based on the name field and date field. The function should perform the following steps: 1. Filter records that have an exact match with the given name. 2. Sort the filtered records by the date field in descending order. 3. If no exact match is found, sort th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_and_sort_records(records: List[Dict[str, str]], name: str) -> List[Dict[str, str]]: """ Filters and sorts a list of records based on the name and date fields. Args: records ...
magic_evol_110k
78,903
Write a Python function to merge two sorted arrays into a single sorted array. The function should efficiently combine the elements from both arrays while maintaining the sorted order. The code should start with: ```python from typing import List def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]: """ Merge two sorted arrays into a single sorted array. Args: arr1 (List[int]): The first sorted array. arr2 (...
magic_evol_110k
78,905
Write a Python function to multiply each element in a given list of integers by a specified factor. The function should handle both positive and negative integers, as well as zero. The code should start with: ```python from typing import List def multiply_elements(arr: List[int], factor: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def multiply_elements(arr: List[int], factor: int) -> List[int]: """ Multiplies each element in the given list of integers by the specified factor. Args: arr (List[int]): The list of integer...
magic_evol_110k
78,912
Write a Python function to add multiple elements to the beginning of a given tuple while ensuring that the new elements are consistent with the type and format of the original tuple. Additionally, write a validation function to check if the new elements match the type of the original tuple. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Any def validate_types(old_tuple: Tuple[Any, ...], new_elements: Tuple[Any, ...]) -> bool: """ Validate the types of new_elements against the types in old_tuple. Args: old_tuple (Tuple[Any...
magic_evol_110k
78,942
Write a Python function to generate the musical scale starting from a given key using a set of intervals. The function should take a string representing the starting key and a list of integers representing the intervals as input. The function should return a list of musical notes in the scale. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_scale(key: str, intervals: List[int]) -> List[str]: """ Generate a musical scale starting from a given key using a set of intervals. Args: key (str): The starting key of the sca...
magic_evol_110k
78,954
Write a Python function to filter and print all odd numbers from a given list while handling invalid or empty list items. The function should skip any even numbers and print an error message for any non-integer items in the list. The code should start with: ```python from typing import List def print_odd_numbers(numb...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_odd_numbers(numbers: List[int]) -> None: """ Prints all odd numbers from the given list while handling invalid or empty list items. Args: numbers (List[int]): The list of integers ...
magic_evol_110k
78,969
Write a Python function to remove duplicate elements from a given list of integers while preserving the order of the first occurrence of each element. The function should return a new list with all duplicate elements removed. The code should start with: ```python from typing import List def remove_duplicates(nums: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates(nums: List[int]) -> List[int]: """ Removes duplicate elements from a list of integers while preserving the order of the first occurrence of each element. Args: nums (Li...
magic_evol_110k
78,993
Write a Python function to determine the number of distinct ways to climb a staircase with `n` steps, where each step can be either 1 or 2 steps at a time. The function should start with: ```python def climb_stairs(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def climb_stairs(n: int) -> int: """ Calculate the number of distinct ways to climb a staircase with n steps, where each step can be either 1 or 2 steps at a time. Args: n (int): The number of steps in the sta...
magic_evol_110k
78,995
Write a Python function to segregate the even integers from a given list, square each of these even integers, and then compute their sum. The function should start with: ```python from typing import List def sum_of_even_squares(data: 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_even_squares(data: List[int]) -> int: """ Segregates the even integers from the given list, squares each of these even integers, and then computes their sum. Args: data (List[...
magic_evol_110k
79,001
Write a Python function to extract and return the rightmost digit before the decimal point from a given floating-point number. The function should handle both positive and negative floating-point numbers. The code should start with: ```python def rightmost_digit(num: float) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def rightmost_digit(num: float) -> int: """ Extracts and returns the rightmost digit before the decimal point from a given floating-point number. Args: num (float): The floating-point number from which to extract th...
magic_evol_110k
79,005
Write a Python function to sort a given list of integers in descending order. The function should return the sorted list. The code should start with: ```python from typing import List def sort_descending(list_items: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_descending(list_items: List[int]) -> List[int]: """ Sorts the given list of integers in descending order. Args: list_items (List[int]): The list of integers to be sorted. Retur...
magic_evol_110k
79,034
Write a Python function to sort a given sequence of real numbers in descending order. The function should be efficient and handle various edge cases, such as an empty sequence or a sequence with duplicate values. The code should start with: ```python from typing import List def sort_descending(sequence: List[float]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_descending(sequence: List[float]) -> List[float]: """ Sorts a given sequence of real numbers in descending order. Args: sequence (List[float]): The sequence of real numbers to be so...
magic_evol_110k
79,052
Write a Python function to remove a specified key from a given dictionary. If the key does not exist in the dictionary, the function should return the dictionary unchanged. The function should handle any dictionary and any valid key (including non-existent keys). 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 Dict, Any def remove_key(dictionary: Dict[Any, Any], key_to_remove: Any) -> Dict[Any, Any]: """ Removes a specified key from the given dictionary. If the key does not exist, the dictionary remains unchanged. ...
magic_evol_110k
79,063
Write a Python function to compute the absolute difference between two given 3D vectors. Each vector represents a point in a 3D space with x, y, and z coordinates. The function should return a new vector where each component is the absolute difference between the corresponding components of the input vectors. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_absolute_difference(vector1: List[int], vector2: List[int]) -> List[int]: """ Compute the absolute difference between two 3D vectors. Args: vector1 (List[int]): The first 3D vect...
magic_evol_110k
79,064
Write a Python function to sort the values at even indices of a given list in ascending order while keeping the values at odd indices unchanged. The function should handle negative numbers and floating-point precision up to 2 decimal places. The code should start with: ```python from typing import List def sort_even_i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_even_indices(l: List[float]) -> List[float]: """ Sorts the values at even indices of the given list in ascending order while keeping the values at odd indices unchanged. Args: l (Li...
magic_evol_110k
79,076
Write a Python function to perform element-wise multiplication between two lists of integers or floats and return a new list containing the results. The function should handle lists of different lengths by truncating the longer list to the length of the shorter list before performing the multiplication. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def element_wise_multiplication(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> List[Union[int, float]]: """ Perform element-wise multiplication between two lists of integers or...
magic_evol_110k
79,085
Write a Python function to group the entries of a given dictionary by their value types. Each entry should be placed into a separate dictionary according to its type. The function should return a new dictionary where the keys are the type names (as strings) and the values are dictionaries containing the entries of that...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def group_dictionary_by_type(dictionary: Dict[str, Any]) -> Dict[str, Dict[str, Any]]: """ Groups the entries of a given dictionary by their value types. Args: dictionary (Dict[str, Any...
magic_evol_110k
79,087
Write a Python function to find the index of the maximum value in a given array of numerical values. The function should iterate over each element and compare it to the remaining ones to identify the maximum value and its respective position. The code should start with: ```python from typing import List def find_max_i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_index(arr: List[int]) -> int: """ Find the index of the maximum value in a given array of numerical values. Args: arr (List[int]): The array of numerical values. Returns: ...
magic_evol_110k
79,090
Write a Python function to compute the nth Catalan number efficiently. The Catalan numbers are a sequence of natural numbers that appear in various combinatorial problems. The nth Catalan number can be computed using the formula: \[ C_n = \frac{(2n)!}{(n+1)!n!} \] The code should start with: ```python def catalan_num...
Here is the Python code to solve the given problem in the markdown block: ```python import math def catalan_number(n: int) -> int: """ Compute the nth Catalan number. The nth Catalan number is defined as: C_n = (2n)! / ((n+1)! * n!) Args: n (int): The position in the Catalan sequence to c...
magic_evol_110k
79,095
Write a Python function to sort a list of integers using a multistep sorting algorithm. The algorithm should first sort the list using the bubble sort algorithm, and then refine the sorted list using the insertion sort algorithm. The final sorted list should be in ascending order. 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 multistep_sort(lst: List[int]) -> List[int]: """ Sorts a list of integers using a multistep sorting algorithm. The algorithm first applies bubble sort and then refines the sorted list using inser...
magic_evol_110k
79,106
Write a Python function to manage a directory and log its existence and creation. The function should check if a specified directory exists, create it if it does not, and log the operations with timestamps. Additionally, the function should provide an option to delete the directory and handle errors during the creation...
Here is the Python code to solve the given problem in the markdown block: ```python import os import time import argparse def manage_directory(directory: str, action: str) -> None: """ Manages a directory and logs its existence and creation. Args: directory (str): The path to the directory to mana...
magic_evol_110k
79,117
Write a Python function that receives a list of integers and a target value as input. The function should return a dictionary where each key is a number from the list, and its value is a tuple. The first element of the tuple is the count of that number in the list, and the second element is a boolean indicating whether...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def count_and_compare(num_list: List[int], target: int) -> Dict[int, Tuple[int, bool]]: """ Counts the occurrences of each number in the list and compares each number to the target value. ...
magic_evol_110k
79,121
Write a Python function to calculate the sum of all numbers in a list that may contain integers, strings, floats, and nested lists up to 3 levels deep. The function should ignore non-numeric values and handle nested lists recursively. The code should start with: ```python from typing import List, Union def sum_number...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def sum_numbers_in_list(lst: List[Union[int, float, str, List]], depth: int = 0) -> float: """ Calculate the sum of all numbers in a list that may contain integers, floats, strings, and nested lis...
magic_evol_110k
79,137
Write a Python function to generate a lyrical composition consisting of four distinct lines based on a given theme. The function should handle different themes and ensure that the lines are unique and coherent with the theme. The function should also be optimized for performance and scalability. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import random def generate_poem(theme: str) -> str: """ Generates a lyrical composition consisting of four distinct lines based on the given theme. Args: theme (str): The theme for the...
magic_evol_110k
79,140
Write a Python function to sum two floating-point numbers supplied as input. The function should take two arguments, both of which are floating-point numbers, and return their sum. The function should also handle cases where the inputs are not valid floating-point numbers by returning `None`. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_two_floats(a: float, b: float) -> float: """ Sums two floating-point numbers. Args: a (float): The first floating-point number. b (float): The second floating-point number. Returns: floa...
magic_evol_110k
79,158
Write a Python function to generate a PostgreSQL SELECT query that extracts all entries with a specified ID and additionally returns the sum of a specific column for those rows grouped by another column. The function should handle the case where there are no results or the result set is empty. The function should start...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_query(property_id: int, sum_column: str, group_column: str) -> str: """ Generates a PostgreSQL SELECT query to extract all entries with a specified ID and additionally return the sum of a specific column for th...
magic_evol_110k
79,159
Write a Python function to compute the nth Fibonacci number efficiently using an iterative approach. The function should avoid the inefficiencies of the naive recursive approach by using dynamic programming or memoization techniques. The code should start with: ```python def fibonacci(n: int) -> int: ```
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 with dynamic programming. Args: n (int): The position in the Fibonacci sequence to compute. Returns: int: T...
magic_evol_110k
79,161
Write a Python function to create a dictionary where the keys are tuples and the values are the products of the elements in each tuple. The function should ensure that the keys are unique and the values are computed correctly. The code should start with: ```python from typing import List, Tuple, Dict def create_produc...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_product_dict(tuples_list: List[Tuple[int, int]]) -> Dict[Tuple[int, int], int]: """ Creates a dictionary where each key is a tuple from the input list and the value is the product...
magic_evol_110k
79,178
Write a Python function to find the smallest numerical value in a given list, ensuring robust error handling for non-iterable or non-numeric inputs. The function should raise appropriate exceptions if the input is not iterable or if no valid numeric values are found in the input. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List, Tuple, Set, Iterable def find_smallest_num(lst: Union[List, Tuple, Set, Iterable]) -> Union[int, float]: """ Find the smallest numerical value in a given list. Args: lst (Union[List,...
magic_evol_110k
79,197
Write a Python function to find the position of the last occurrence of a target integer in a given list of integers. If the target integer is not found, return -1. Implement this without using in-built Python functions or libraries. The code should start with: ```python def find_last_occurrence(my_list: list, target: i...
Here is the Python code to solve the given problem in the markdown block: ```python def find_last_occurrence(my_list: list, target: int) -> int: """ Find the position of the last occurrence of a target integer in a given list. Args: my_list (list): The list of integers to search through. ta...
magic_evol_110k
79,221
Write a Python function to perform arithmetic operations (addition, subtraction, multiplication, and division) on two given integers. The function should return a dictionary containing the results of these operations. The code should start with: ```python from typing import Dict def arithmetic_operations(x: int, y: in...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import Dict def arithmetic_operations(x: int, y: int) -> Dict[str, int]: """ Perform basic arithmetic operations (addition, subtraction, multiplication, and division) on two integers. Args: x (int): T...
magic_evol_110k
79,233
Write a Python function to convert a hexadecimal string to its decimal equivalent. The function should handle both uppercase and lowercase hexadecimal characters and should return the decimal value as an integer. The code should start with: ```python def hex_to_decimal(hex_string: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def hex_to_decimal(hex_string: str) -> int: """ Converts a hexadecimal string to its decimal equivalent. Args: hex_string (str): The hexadecimal string to be converted. It should start with '0x' or '0X' followed by ...
magic_evol_110k
79,247
Write a Python function to implement the selection sort algorithm. The function should sort a list of integers in ascending order. Additionally, the function should include a helper function to reverse the sorted list. Finally, write a separate function to calculate the time complexity of the selection sort algorithm i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def selection_sort(arr: List[int]) -> List[int]: """ Sorts the given list of integers using the selection sort algorithm. Args: arr (List[int]): The list of integers to be sorted. Retur...
magic_evol_110k
79,249
Write a Python function to remove all duplicate elements from a given list and also remove any elements that exceed a specified limit. The function should return the modified list. The code should start with: ```python from typing import List def remove_duplicates_and_limit(arr: List[int], limit: int) -> List[int]: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_and_limit(arr: List[int], limit: int) -> List[int]: """ Removes all duplicate elements from the given list and also removes any elements that exceed the specified limit. Args: ...
magic_evol_110k
79,258
Write a Python function to flatten a nested list using list comprehensions. The function should take a list of lists (a matrix) as input and return a single list containing all the elements from the nested lists in a flattened manner. The code should start with: ```python from typing import List def flatten_nested_lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def flatten_nested_list(matrix: List[List[int]]) -> List[int]: """ Flattens a nested list (matrix) into a single list containing all elements. Args: matrix (List[List[int]]): A list of lists...
magic_evol_110k
79,268
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...
magic_evol_110k
79,278
Write a Python function to generate a dictionary containing a quota of fifteen corresponding associations, wherein each distinct association comprises a hexadecimal color symbol acting as a key and an unpredictable decimal number, sufficiently chosen to yield values spanning the interval of 0.1 through to 1.0, function...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import random def generate_color_associations() -> Dict[str, float]: """ Generates a dictionary containing 15 unique hexadecimal color symbols as keys and random decimal numbers between 0.1 and 1.0, ...
magic_evol_110k
79,281
Write a Python function to find the one-dimensional index pair `(i, j)` in a given matrix where each cell contains a string of a single character, such that `matrix[i][j]` is equal to a given character `c`. Assume the given matrix is not empty and contains the character `c` at least once. The function should return the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_character_index(matrix: List[List[str]], c: str) -> Tuple[int, int]: """ Find the one-dimensional index pair (i, j) in a given matrix where each cell contains a string of a single charact...
magic_evol_110k
79,287
Write a Python function to extract and return every second element from a given list, starting from the first element (index 0). The function should handle lists of any length and return an empty list if the input list is empty. The code should start with: ```python from typing import List def get_every_second_elemen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_every_second_element(lst: List[int]) -> List[int]: """ Extracts and returns every second element from the given list, starting from the first element (index 0). Args: lst (List[int])...
magic_evol_110k
79,296
Write a Python function to extract and return a list of all discrete units (key-value pairs) from a given dictionary where each key is associated with a list of distinct numerical quantities. The function should return a list of tuples, where each tuple contains a key and a corresponding value from the dictionary. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def extract_discrete_units(dictionary: Dict[str, List[int]]) -> List[Tuple[str, int]]: """ Extracts and returns a list of all discrete units (key-value pairs) from a given dictionary. A...
magic_evol_110k
79,316
Write a Python function to calculate the maximum profit that can be obtained 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 `ith` day. You are allowed to make an unlimited number of transactions...
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 obtained by buying and selling a stock multiple times. Args: prices (List[int]): A list of stock prices...
magic_evol_110k
79,324
Write a Python function to reverse a given string efficiently. The function should return the reversed string while preserving all characters, including spaces and punctuation. The code should start with: ```python def reverse_string(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(s: str) -> str: """ Reverses the given string while preserving all characters. Args: s (str): The input string to be reversed. Returns: str: The reversed string. """ # Use sli...
magic_evol_110k
79,331
Write a Python function to determine if any of the tuples in a given list of tuples contains the character 'k'. The function should return `True` if at least one tuple contains 'k', otherwise it should return `False`. The code should start with: ```python from typing import List, Tuple def contains_k(tuples: List[Tup...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def contains_k(tuples: List[Tuple[str]]) -> bool: """ Determines if any of the tuples in the provided list contains the character 'k'. Args: tuples (List[Tuple[str]]): A list of tuple...
magic_evol_110k
79,337
Write a Python function to determine if a bank account's balance goes negative after processing a series of deposit and withdrawal transactions, considering transaction fees. The function should handle case-insensitive transaction types and optionally include fees in the balance calculations. It should also handle inva...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def below_zero(operations: List[Tuple[str, int, float]], case_insensitive: bool = False, fee_included: bool = False) -> Union[bool, str]: """ Determine if a bank account's balance goes nega...
magic_evol_110k
79,340
Write a Python function to decode a string of colors in a specialized hex format into a list of RGB triplet tuples. Each color in the string is represented by a 4-character string starting with a `#` followed by three hexadecimal digits. The function should handle both uppercase and lowercase letters and raise an excep...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def decode_complex_colors(color_string: str) -> List[Tuple[int, int, int]]: """ Decodes a string of colors in a specialized hex format into a list of RGB triplet tuples. Args: color_s...
magic_evol_110k
79,354
Write a Python function to remove duplicate elements from a given list while maintaining the original order of the elements. The function should not use any built-in functions or data structures that directly solve the problem, such as `set()`, `dict()`, or `collections.OrderedDict()`. The function should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_in_order(lst: List[int]) -> List[int]: """ Removes duplicate elements from the given list while maintaining the original order of elements. Args: lst (List[int]): The l...
magic_evol_110k
79,360
Write a Python function to calculate the Euclidean distance between two points on a two-dimensional plane. The function should accept two tuples representing the coordinates of the points and return the distance as a floating-point number. The code should start with: ```python from typing import Tuple import math def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import math def euclidean_distance(point1: Tuple[float, float], point2: Tuple[float, float]) -> float: """ Calculate the Euclidean distance between two points on a two-dimensional plane. Args: ...
magic_evol_110k
79,362
Write a Python function to calculate the area of a triangle given its side length and corresponding height. The function should be robust and handle potential edge cases such as zero or negative inputs. The code should start with: ```python def calculate_triangle_area(side_length: float, height: float) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_triangle_area(side_length: float, height: float) -> float: """ Calculate the area of a triangle given its side length and corresponding height. Args: side_length (float): The length of the side of the ...
magic_evol_110k
79,369
Write a Python function to calculate the n-th Tribonacci number without using any form of loop (for, while, do-while) or recursion. The Tribonacci sequence is defined as follows: - \( T_0 = 0 \) - \( T_1 = 1 \) - \( T_2 = 1 \) - \( T_{n+3} = T_n + T_{n+1} + T_{n+2} \) for \( n \geq 0 \) The function should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python def tribonacci(n: int) -> int: """ Calculate the n-th Tribonacci number without using loops or recursion. The Tribonacci sequence is defined as: - T_0 = 0 - T_1 = 1 - T_2 = 1 - T_{n+3} = T_n + T_{n+1} + T_{n...
magic_evol_110k
79,381
Write a Python function to generate a list of prime numbers within a given range `[low, high]`. The function should efficiently determine whether a number is prime and return all prime numbers in the specified range. The code should start with: ```python from typing import List def generate_primes_in_range(low: int, h...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def generate_primes_in_range(low: int, high: int) -> List[int]: """ Generate a list of prime numbers within the given range [low, high]. Args: low (int): The lower bound of the r...
magic_evol_110k
79,384
Write a Python function to determine if a given number `n` is a prime number. If `n` is not a prime number, the function should return `False` along with the smallest divisor of `n`. If `n` is a prime number, the function should return `True` and `None` for the divisor. The function should be optimized for performance,...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime_number(n: int) -> tuple: """ Determine if a given number `n` is a prime number. If `n` is not a prime number, return `False` and the smallest divisor. If `n` is a prime number, return `True` and `No...
magic_evol_110k
79,386
Write a Python function to count the frequency of each unique element in a given list. Additionally, convert the corrected Python code into an equivalent SQL statement that selects distinct records and provides a count of how many times each distinct record appears in the table. The Python function should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_unique_elements(table: List[str]) -> Dict[str, int]: """ Counts the frequency of each unique element in the given list. Args: table (List[str]): The list of elements to count...
magic_evol_110k
79,393
Write a Python function to filter out all elements from a given list that exceed a specified boundary limit. The function should return a new list containing only the elements that are less than or equal to the boundary limit. The code should start with: ```python from typing import List def filter_elements_by_limit(e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_elements_by_limit(elements: List[int], limit: int) -> List[int]: """ Filters out all elements from the given list that exceed the specified boundary limit. Args: elements (List[in...
magic_evol_110k
79,405
Write a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS. The code should start with: ```python def longest_common_subsequence(str1: str, str2: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def longest_common_subsequence(str1: str, str2: str) -> int: """ Calculate the length of the longest common subsequence (LCS) between two strings. Args: str1 (str): The first string. str2 (str): The second s...
magic_evol_110k
79,428
Write a Python function to find the least numerical value in a given list of integers. The function should iterate through the list and update the least value found so far. The code should start with: ```python from typing import List def find_least_value(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_least_value(numbers: List[int]) -> int: """ Find the least numerical value in a given list of integers. Args: numbers (List[int]): A list of integers from which to find the least va...
magic_evol_110k
79,442
Write a Python function that accepts a list of strings, ignores punctuation, and returns `True` if more than one unique item in the provided list starts with a less frequently used consonant in the English language ("k" or "z"). The function should ensure that the strings in the list start with these consonants only an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import string def less_used_consonants(lst: List[str]) -> bool: """ Determines if more than one unique item in the provided list starts with the consonants "k" or "z". Args: lst (List[str]):...
magic_evol_110k
79,450
Write a Python function to find all occurrences of a specified element `x` in a 2D list `lst` and return their positions sorted by row index in ascending order and by column index in descending order within the same row. The function should start with: ```python from typing import List, Tuple def get_positions(lst: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def get_positions(lst: List[List[int]], x: int) -> List[Tuple[int, int]]: """ Find all occurrences of a specified element `x` in a 2D list `lst` and return their positions sorted by row index ...
magic_evol_110k
79,470
Write a Python function to find the largest prime factor of a given integer `n`. The function should handle both positive and negative integers, efficiently compute the prime factors, and include error handling for invalid inputs. The function should raise appropriate exceptions for non-integer inputs and for integers ...
Here is the Python code to solve the given problem in the markdown block: ```python def largest_prime_factor(n: int) -> int: """ Return the largest prime factor of a positive or negative integer n. Handle invalid inputs and raise relevant error messages. Efficiently find the prime factors. Assume |n| > ...
magic_evol_110k
79,489
Write a Python function to change the text color in the console output. The function should accept a string and a color code, and return the string wrapped in the appropriate ANSI escape codes to change the text color. The color codes should be predefined as constants in the function. The function should also include a...
Here is the Python code to solve the given problem in the markdown block: ```python def color_text(text: str, color: str) -> str: """ Changes the text color in the console output using ANSI escape codes. Args: text (str): The text to be colored. color (str): The color code to apply to the t...
magic_evol_110k
79,511
Write a Python function to reduce a five-dimensional array to a two-dimensional matrix representation. The five-dimensional array is represented by its h blocks, t blocks, p layers, m horizontal lines, and n vertical lines. The function should flatten the five-dimensional array into a two-dimensional matrix where each ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reduce_5D_to_2D(fiveD_mat: List[List[List[List[List[int]]]]]) -> List[List[int]]: """ Reduces a five-dimensional array to a two-dimensional matrix representation. Args: fiveD_mat (List[L...
magic_evol_110k
79,512
Write a Python function to find the maximum element in a given matrix. The matrix is represented as a list of lists, where each inner list represents a row in the matrix. The function should return the maximum value found in the matrix. The code should start with: ```python from typing import List def find_max_elemen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_element(matrix: List[List[int]]) -> int: """ Find the maximum element in a given matrix. Args: matrix (List[List[int]]): A 2D list representing the matrix. Returns: ...
magic_evol_110k
79,541
Write a Python function to round off a collection of complex numbers (real and imaginary parts separately) to the nearest integer using a custom rounding function. The rounding function should meet the following criteria: - If the number's decimal part is 0.5 or above, the number should be rounded up. - If the number's...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_round(number: float) -> int: """ Custom rounding function that rounds up if the decimal part is 0.5 or above, and rounds down otherwise. Args: number (float): The number to be...
magic_evol_110k
79,543
Write a Python function to combine two lists into a single list containing all unique elements from both lists while preserving their relative order. The function should take two lists as input and return a new list with the combined unique elements. The code should start with: ```python from typing import List def c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def combine_unique_lists(list_one: List[int], list_two: List[int]) -> List[int]: """ Combines two lists into a single list containing all unique elements from both lists, while preserving their relat...
magic_evol_110k
79,546
Write a Python function to remove duplicate elements from a given list of fruit nomenclature strings while preserving the order of their first occurrence. The function should be efficient and handle various edge cases, such as an empty list or a list with all unique elements. 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 def remove_duplicates(fruits: List[str]) -> List[str]: """ Removes duplicate elements from a list of fruit nomenclature strings while preserving the order of their first occurrence. Args: fr...
magic_evol_110k
79,549
Write a Python function to remove duplicate elements from a given list while maintaining the order of the first occurrence of each element. The function should be efficient and handle various edge cases, such as an empty list or a list with all elements being the same. The code should start with: ```python from typing...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_maintain_order(arr: List[int]) -> List[int]: """ Removes duplicate elements from the given list while maintaining the order of the first occurrence of each element. Args: ...
magic_evol_110k
79,554
Write a Python function to generate a 3x3 matrix filled with non-repeating prime numbers based on a randomized selection process. The function should ensure that the matrix contains exactly 9 unique prime numbers. The code should start with: ```python from typing import List def generate_prime_matrix() -> List[List[in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def is_prime(num: int) -> bool: """ Check if a given number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prim...
magic_evol_110k
79,571
Write a Python function to generate a stochastic sequence of a specified length, consisting exclusively of a given subset of characters. The function should ensure that each character in the subset has an equal probability of being chosen for each position in the sequence. The code should start with: ```python from typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_stochastic_sequence(length: int, subset: List[str]) -> str: """ Generates a stochastic sequence of the specified length using characters from the given subset. Args: ...
magic_evol_110k
79,573
Write a Python function that takes two lists and a value as parameters. The function should append the given value to the first list only if it isn't found in either list and return the modified first list. The function should also handle edge cases such as empty lists and non-list inputs. Additionally, the function sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def append_unique_value(first: List[int], second: List[int], value: int) -> List[int]: """ Appends the given value to the first list only if it isn't found in either list and returns the modified first l...
magic_evol_110k
79,576
Write a Python function to find the longest increasing subsequence (LIS) in a given list of integers. The LIS is defined as the longest subsequence where each element is strictly greater than the previous element. The function should return the length of the LIS. 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 longest_increasing_subsequence(nums: List[int]) -> int: """ Calculate the length of the longest increasing subsequence in a given list of integers. Args: nums (List[int]): The list of ...
magic_evol_110k
79,595
Write a Python function to simulate a simplified version of the data processing pipeline for Reddit posts. The function should take a list of Reddit posts as input, where each post is represented as a dictionary with keys 'text' and 'user_info'. The function should perform the following steps: 1. **Data Normalization**...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple import re from collections import Counter def process_reddit_posts(posts: List[Dict[str, str]]) -> Tuple[List[str], List[Counter]]: """ Simulate a simplified data processing pipeline for Red...
magic_evol_110k
79,597
Write a Python function to calculate the value of `x` after performing a series of arithmetic operations on an initial value of `x`. The operations include doubling the value of `x` and then adding the result to itself. The function should take an integer `x` as input and return the final value of `x` after the operati...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_final_value(x: int) -> int: """ Calculate the final value of x after performing a series of arithmetic operations. The operations include doubling the value of x and then adding the result to itself. Args...
magic_evol_110k
79,599
Write a Python function to count the number of terminal nodes (leaves) in a binomial hierarchical structure represented as a nested dictionary. Each node in the tree is represented by a dictionary with keys `"data"`, `"left"`, and `"right"`. The `"left"` and `"right"` keys may contain nested dictionaries representing t...
Here is the Python code to solve the given problem in the markdown block: ```python def count_terminal_nodes(tree: dict) -> int: """ Count the number of terminal nodes (leaves) in a binomial hierarchical structure. Args: tree (dict): A nested dictionary representing the binomial hierarchical struct...
magic_evol_110k
79,610
Write a Python function to truncate a given string to display only the first `n` characters. If the length of the string is less than `n`, return the string as is. The function should handle cases where `n` is less than or equal to zero by returning an empty string. The code should start with: ```python def truncate_s...
Here is the Python code to solve the given problem in the markdown block: ```python def truncate_string(input_string: str, n: int) -> str: """ Truncates the given string to display only the first n characters. Args: input_string (str): The string to be truncated. n (int): The number of char...
magic_evol_110k
79,615
Write a Python function to check if a given string contains any numerical representation using regular expressions. The function should return `True` if the string contains any digit, and `False` otherwise. The code should start with: ```python import re def contains_number(input_string: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def contains_number(input_string: str) -> bool: """ Check if the given string contains any numerical representation. Args: input_string (str): The string to be checked for the presence of any digit. ...
magic_evol_110k
79,616
Write a Python function to sort a list of integers using the merge sort algorithm. Merge sort is a divide-and-conquer algorithm that recursively divides the list into halves until each sublist contains a single element, then merges these sublists back together in sorted order. The function should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sort(int_list: List[int]) -> List[int]: """ Sorts a list of integers using the merge sort algorithm. Args: int_list (List[int]): The list of integers to be sorted. Returns: ...
magic_evol_110k
79,618
Write a Python function to calculate the sum and product of the digits of a given integer. The function should handle both positive and negative integers. The code should start with: ```python def additive_multiplicative(num: int) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def additive_multiplicative(num: int) -> tuple: """ Calculate the sum and product of the digits of a given integer. Args: num (int): The integer whose digits' sum and product are to be calculated. Returns: ...
magic_evol_110k
79,629
Write a Python function to find the longest word in a list of words and return both the word and its length. If there are multiple words with the same maximum length, return the first one encountered. The function should handle lists of strings and return a tuple containing the longest word and its length. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Optional def find_longest_word(words: List[str]) -> Optional[Tuple[str, int]]: """ Finds the longest word in a list of words and returns both the word and its length. Args: words (Li...
magic_evol_110k
79,632
Write a Python function to calculate the greatest common divisor (GCD) of two numbers using the Euclidean algorithm. The function should be optimized for efficiency and correctness. The code should start with: ```python def gcd(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def gcd(a: int, b: int) -> int: """ Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm. Args: a (int): The first integer. b (int): The second integer. Returns: ...
magic_evol_110k
79,645
Write a Python function to convert a given temperature from Fahrenheit to Celsius. The function should take a single argument representing the temperature in Fahrenheit and return the equivalent temperature in Celsius. 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: """ Convert a given temperature from Fahrenheit to Celsius. Args: fahrenheit (float): The temperature in Fahrenheit to be converted. Returns: float...
magic_evol_110k
79,648
Write a Python function to transform a given list into a NumPy array and then sort the elements of the array in ascending order. The function should return the sorted NumPy array. The code should start with: ```python import numpy as np from typing import List def sort_list_to_numpy_array(lst: List[int]) -> np.ndarra...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def sort_list_to_numpy_array(lst: List[int]) -> np.ndarray: """ Transforms a given list of integers into a NumPy array and sorts its elements in ascending order. Args: lst...
magic_evol_110k
79,655
Write a Python function to validate whether a given string meets two conditions: 1. All alphabetic characters within the string are unique and non-repetitive. 2. The string has balanced parentheses, considering only '()', '[]', and '{}' as valid pairs. The string will only contain valid alphanumeric characters and the...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_string(s: str) -> bool: """ Validates whether a given string meets the following conditions: 1. All alphabetic characters within the string are unique and non-repetitive. 2. The string has balanced parenthes...
magic_evol_110k
79,660
Write a Python function to encrypt a given string using a custom Caesar cipher with a provided key. The encryption should consider case sensitivity and non-alphabetic characters, which should remain unchanged. The function should start with: ```python def custom_caesar_cipher(text: str, key: int) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def custom_caesar_cipher(text: str, key: int) -> str: """ Encrypts a given string using a custom Caesar cipher with a provided key. The encryption considers case sensitivity and leaves non-alphabetic characters unchanged. ...
magic_evol_110k
79,662
Write a Python function to analyze a given code snippet and count the number of lines, code lines, comment lines, and empty lines. The function should return a dictionary with these counts. A comment line is defined as a line that starts with a `#` symbol, and an empty line is a line that contains no characters or only...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def analyze_code_snippet(code: List[str]) -> Dict[str, int]: """ Analyzes a given code snippet and counts the number of lines, code lines, comment lines, and empty lines. Args: code (L...
magic_evol_110k
79,664
Write a Python function to simulate multiple sequences of coin tosses and calculate the probability distribution of getting heads or tails. The function should return a list of sequences, where each sequence is a list of 'heads' or 'tails' results, and a list representing the probability distribution of heads and tails...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import random def simulate_coin_tosses(sequences: int, tosses: int) -> Tuple[List[List[str]], List[float]]: """ Simulate multiple sequences of coin tosses and calculate the probability distributio...
magic_evol_110k
79,669
Write a Python function to create a dictionary from a given tuple of key-value pairs and compute the sum of the values in the dictionary. The function should return both the dictionary and the sum of its values. The code should start with: ```python from typing import Tuple, Dict, Any def create_dict_and_sum_values(m...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Dict, Any def create_dict_and_sum_values(my_tuple: Tuple[Tuple[Any, int], ...]) -> Tuple[Dict[Any, int], int]: """ Create a dictionary from a given tuple of key-value pairs and compute the sum of the v...
magic_evol_110k
79,676
Write a Python function to generate a deck of cards and return it in a specific format. The deck should be represented as a list of tuples, where each tuple contains a rank and a suit. The function should also include a parameter to specify the number of decks to be combined into one. 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, Tuple def generate_deck(num_decks: int = 1) -> List[Tuple[str, str]]: """ Generates a deck of cards and returns it as a list of tuples. Args: num_decks (int): The number of decks to combine...
magic_evol_110k
79,679
Write a Python function to generate a palindromic sequence from a given queue of elements. The function should take a queue (implemented using `collections.deque`) as input and return a list that represents the palindromic sequence. The palindromic sequence should be formed by appending the reverse of the original sequ...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import deque from typing import List def generate_palindromic_sequence(queue: deque) -> List[str]: """ Generates a palindromic sequence from a given queue of elements. Args: queue (deque): A deque ...
magic_evol_110k
79,692
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...
magic_evol_110k
79,696
Write a Python function to determine if the cumulative sum of integers at even indices in a given list falls within specified lower and upper bounds. The list must have an even number of elements and must not be empty. The function should start with: ```python from typing import List def within_boundary_sum(l: List[i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def within_boundary_sum(l: List[int], lower_barrier: int, upper_barrier: int) -> bool: """ Determines if the cumulative sum of integers at even indices in the list falls within the specified lower and up...
magic_evol_110k
79,705
Write a Python function to find all occurrences of a specified integer in a given two-dimensional numerical array and return their index positions as tuples. If the integer is not found, the function should return an empty list. The function should handle arrays of varying sizes and return all positions where the integ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_all_positions(num: int, array: List[List[int]]) -> List[Tuple[int, int]]: """ Find all occurrences of a specified integer in a two-dimensional numerical array and return their index posit...
magic_evol_110k
79,708
Write a Python function to determine which pairs of ratios from a given list are unable to form a proportion using the principle of cross-multiplication. The function should return a list of tuples representing the pairs of ratios that do not form a proportion. The code should start with: ```python from typing import ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_non_proportional_pairs(ratios: List[Tuple[int, int, int, int]]) -> List[Tuple[int, int, int, int]]: """ Determines which pairs of ratios from a given list are unable to form a proportion ...