source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
32,828
Write a Python function to remove repetitive elements from a given list while maintaining the order of the first occurrence of each element. The function should efficiently handle the removal of duplicates without using additional data structures like dictionaries. The code should start with: ```python from typing imp...
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 repetitive elements from the given list while maintaining the order of the first occurrence of each element. Args: arr (List...
evol_instruct_66k
32,831
Write a Python function to check if a target element is present in a given dataset efficiently. The dataset is a list of integers. The function should use a more efficient data structure to improve the performance of the search operation. The code should start with: ```python from typing import List def is_target_in_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_target_in_dataset(dataset: List[int], target: int) -> bool: """ Checks if the target element is present in the given dataset efficiently. Args: dataset (List[int]): The dataset in whi...
evol_instruct_66k
32,849
Write a Python function that creates a reversed duplicate of a given list while ensuring that the original list remains unchanged. The function should return the reversed duplicate list. The code should start with: ```python from typing import List def reverse_duplicate(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 reverse_duplicate(input_list: List[int]) -> List[int]: """ Creates a reversed duplicate of the given list while preserving the original list's integrity. Args: input_list (List[int]): Th...
evol_instruct_66k
32,851
Write a Python function to count the number of key-value pairs in a given dictionary. The function should be able to handle any dictionary, regardless of its size or the types of its keys and values. The code should start with: ```python def count_dictionary_items(dictionary: dict) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_dictionary_items(dictionary: dict) -> int: """ Counts the number of key-value pairs in a given dictionary. Args: dictionary (dict): The dictionary whose items are to be counted. Returns: int: ...
evol_instruct_66k
32,852
Write a Python function to traverse a given matrix (2D list) of integers and return the sum of all elements in the matrix. The function should handle matrices of any size, including empty matrices. The code should start with: ```python from typing import List def sum_matrix_elements(matrix: List[List[int]]) -> int: ``...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sum_matrix_elements(matrix: List[List[int]]) -> int: """ Calculate the sum of all elements in a given matrix. Args: matrix (List[List[int]]): A 2D list of integers representing the mat...
evol_instruct_66k
32,865
Write a Python function to filter out words from a given list where each word contains more than three vowels. The function should use list comprehension for this purpose. The code should start with: ```python from typing import List def filter_words_by_vowels(words: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def filter_words_by_vowels(words: List[str]) -> List[str]: """ Filters out words from a given list where each word contains more than three vowels. Args: words (List[str]): A list of words...
evol_instruct_66k
32,879
Write a Python function to determine whether a provided input belongs to the boolean category. If the input is not a boolean, further investigate if it is a list. The function should return a string indicating the category of the input: "boolean", "list", or "other". The code should start with: ```python def verify_in...
Here is the Python code to solve the given problem in the markdown block: ```python def verify_input(input_data): """ Determine the category of the provided input data. Args: input_data: The input data to be categorized. Returns: str: A string indicating the category of the input data:...
evol_instruct_66k
32,894
Write a Python function to construct a NumPy array consisting of a specified number of instances of a negative integer juxtaposed with another specified number of instances of a positive integer. The function should take three parameters: the negative integer, the number of times it should be repeated, the positive int...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def construct_array(negative_int: int, num_negative: int, positive_int: int, num_positive: int) -> np.ndarray: """ Constructs a NumPy array consisting of a specified number of instances of a negative integer ...
evol_instruct_66k
32,909
Write a Python function to simulate a daily CRON task that sends an email notification to every user registered in a system. The function should take a list of user emails and a message as input and print a simulated email dispatch for each user. The code should start with: ```python from typing import List def send_d...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def send_daily_notification(user_emails: List[str], message: str) -> None: """ Simulates sending a daily notification email to each user in the provided list of emails. Args: user_emails (...
evol_instruct_66k
32,916
Write a Python function to filter and return a list of even integers from a given collection of numerical values. The function should handle any iterable collection (e.g., list, tuple, set) of integers. The code should start with: ```python from typing import Iterable, List def filter_even_numbers(numbers: Iterable[i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Iterable, List def filter_even_numbers(numbers: Iterable[int]) -> List[int]: """ Filters and returns a list of even integers from the given collection of numerical values. Args: numbers (Iterable...
evol_instruct_66k
32,923
Write a Python function to identify all odd integers within a given list and calculate the product of these odd integers. The function should start with: ```python from typing import List def product_of_odds(lst: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def product_of_odds(lst: List[int]) -> int: """ Calculate the product of all odd integers in the given list. Args: lst (List[int]): The list of integers from which to find the product of o...
evol_instruct_66k
32,924
Write a Python function to find the penultimate highest value (second largest) in a given list of numerical elements. The function should handle lists with fewer than two elements by returning `None`. The code should start with: ```python from typing import List, Optional def find_penultimate_highest(numbers: List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_penultimate_highest(numbers: List[int]) -> Optional[int]: """ Find the penultimate highest value (second largest) in a given list of numerical elements. Args: numbers (Lis...
evol_instruct_66k
32,927
Write a Python function to generate a list of squares of integers within a specified range. The function should accept two parameters: the starting integer (`start`) and the ending integer (`end`). The function should return a list containing the squares of all integers from `start` to `end` (inclusive). The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_squares(start: int, end: int) -> List[int]: """ Generate a list of squares of integers within the specified range [start, end]. Args: start (int): The starting integer of the ra...
evol_instruct_66k
32,933
Write a Python function to count the occurrences of each word in a given sentence, considering the following constraints: 1. Ignore the case of the words (i.e., treat "The" and "the" as the same word). 2. Remove all punctuation marks before counting the words. 3. Count the words while maintaining their original order o...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import OrderedDict import re from collections import OrderedDict def count_words_in_sentence(sentence: str) -> OrderedDict[str, int]: """ Count the occurrences of each word in a given sentence, ignoring case and pun...
evol_instruct_66k
32,944
Write a Python function to create a dictionary from a list of tuples, where each tuple consists of a color name and its value. If the input list contains duplicate color names, merge the values of duplicate color names as a list of values. The order of color names should be preserved from the input list. The code shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_color_dict(items: List[Tuple[str, str]]) -> Dict[str, List[str]]: """ Create a dictionary from a list of tuples, where each tuple consists of a color name and its value. If th...
evol_instruct_66k
32,976
Write a Python function to generate a random number between a given range `[min_value, max_value]`. The function should ensure that the generated number is within the specified range and should handle edge cases such as when `min_value` is greater than `max_value`. The code should start with: ```python import random ...
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(min_value: int, max_value: int) -> int: """ Generates a random integer within the specified range [min_value, max_value]. Args: min_value (int): The lower bound of the range...
evol_instruct_66k
32,987
Write a Python function to concatenate two strings with a specified delimiter. The function should take three parameters: the first string, the second string, and an optional delimiter. If the delimiter is not provided, it should default to an empty string. The function should return the concatenated string. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_with_delimiter(string_1: str, string_2: str, delimiter: str = '') -> str: """ Concatenates two strings with a specified delimiter. Args: string_1 (str): The first string to concatenate. strin...
evol_instruct_66k
32,994
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...
evol_instruct_66k
32,998
Write a Python function to find the closest value to a given number in a given array. The function should efficiently handle the search and return the closest element in the array to the given number. The code should start with: ```python from typing import List def find_closest_value(arr: List[int], target: int) -> i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_closest_value(arr: List[int], target: int) -> int: """ Find the closest value to a given number in a given array. Args: arr (List[int]): The array of integers to search within. ...
evol_instruct_66k
33,000
Write a Python function to combine three dictionaries into a single set, maintaining their unique entries, and sort the resulting set alphabetically. The function should also manage case sensitivity, meaning it should distinguish between upper and lower case letters. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def combine_and_sort_dict_keys(dict1: Dict[str, int], dict2: Dict[str, int], dict3: Dict[str, int]) -> List[str]: """ Combines the keys from three dictionaries into a single set, maintaining their ...
evol_instruct_66k
33,010
Write a Python function to generate a sorted array of 20 unique integers within the range from 0 to 50. The function should also maintain a history of all previously generated arrays for comparison purposes. The code should start with: ```python from typing import List import random def generate_unique_sorted_array(pr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_unique_sorted_array(previous_arrays: List[List[int]]) -> List[List[int]]: """ Generates a sorted array of 20 unique integers within the range from 0 to 50, and maintains a ...
evol_instruct_66k
33,030
Write a Python function to convert a given list of strings into a list of integers, handling non-integer values by converting them to 0. The function should start with: ```python from typing import List def convert_to_integers(strings: List[str]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def convert_to_integers(strings: List[str]) -> List[int]: """ Converts a list of strings into a list of integers. If a string cannot be converted to an integer, it is converted to 0. Args: ...
evol_instruct_66k
33,041
Write a Python function to calculate the product of all elements in a 2D matrix, handling zeros and negative numbers appropriately. The function should optimize for minimized time complexity. The code should start with: ```python from typing import List def product_of_matrix(matrix: List[List[int]]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_matrix(matrix: List[List[int]]) -> int: """ Calculate the product of all elements in a 2D matrix, handling zeros and negative numbers. Args: matrix (List[List[int]]): A 2D lis...
evol_instruct_66k
33,048
Write a Python function to remove sequential duplicates from a list, allowing up to 'n' duplicates in a sequence. The function should take a list of elements and an integer 'n' as parameters and return a new list with the specified number of sequential duplicates retained. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_sequential_duplicates(lst: List[str], n: int) -> List[str]: """ Removes sequential duplicates from a list, allowing up to 'n' duplicates in a sequence. Args: lst (List[str]): The ...
evol_instruct_66k
33,053
Write a Python function to sort a given numerical matrix (a list of integers) in decreasing order. The function should return the sorted list. The code should start with: ```python from typing import List def sort_matrix_descending(matrix: 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_matrix_descending(matrix: List[int]) -> List[int]: """ Sorts a given numerical matrix (a list of integers) in decreasing order. Args: matrix (List[int]): The numerical matrix to be ...
evol_instruct_66k
33,064
Write a Python function to filter and return a list of numbers that fall within a specified range from a given list of integers. The function should take three parameters: the list of integers, the lower bound (inclusive), and the upper bound (inclusive). The function should return a new list containing only the number...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_numbers_in_range(numbers: List[int], lower_bound: int, upper_bound: int) -> List[int]: """ Filters and returns a list of numbers that fall within the specified range [lower_bound, upper_bound]...
evol_instruct_66k
33,069
Write a Python function to generate a list of squares of numbers from 1 to a given positive integer `n`. The function should return a list containing the squares of all integers from 1 to `n`. The code should start with: ```python from typing import List def generate_squares(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_squares(n: int) -> List[int]: """ Generate a list of squares of numbers from 1 to n. Args: n (int): The upper limit of the range (inclusive) for which squares are to be generate...
evol_instruct_66k
33,100
Write a Python function to exclude specific keys from a given dictionary. The function should return a new dictionary that contains all the key-value pairs from the original dictionary except those specified in the exclusion list. The code should start with: ```python from typing import Dict, List, Any def exclude_ke...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Any def exclude_keys_from_dict(original_dict: Dict[Any, Any], exclude_keys: List[Any]) -> Dict[Any, Any]: """ Exclude specific keys from a given dictionary and return a new dictionary. Args: ...
evol_instruct_66k
33,110
Write a Python function to move all zeroes in a given list to the end of the list while maintaining the relative order of the non-zero elements. The function should not use any additional data structures; it should modify the list in place. The code should start with: ```python from typing import List def move_zeroes...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def move_zeroes_to_end(array: List[int]) -> None: """ Moves all zeroes in the given list to the end while maintaining the relative order of non-zero elements. Args: array (List[int]): The li...
evol_instruct_66k
33,111
Write a Python function to find the first occurrence of a specific substring within a given string, and return the index of its starting position. If the substring is not found, return -1. The function should use a loop to iterate through the string and should stop searching as soon as the substring is found. The funct...
Here is the Python code to solve the given problem in the markdown block: ```python def find_substring(main_string: str, sub_string: str) -> int: """ Find the first occurrence of a substring within a main string and return the index of its starting position. If the substring is not found, return -1. Ar...
evol_instruct_66k
33,113
Write a Python function to identify the length of the most extensive sublist within a nested list structure and the index of the most extensive sublist. If multiple sublists share the longest length, the function should return the index of the earliest one. The code should start with: ```python from typing import List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def longest_sublist(lst: List[List[int]]) -> Tuple[int, int]: """ Identify the length of the most extensive sublist within a nested list structure and the index of the most extensive sublist. ...
evol_instruct_66k
33,129
Write a Python function to count the frequency of each unique element in a given list and return the result as a dictionary where the keys are the unique elements and the values are their respective frequencies. The code should start with: ```python from typing import List, Dict def count_element_frequencies(lst: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_element_frequencies(lst: List[str]) -> Dict[str, int]: """ Counts the frequency of each unique element in the given list and returns a dictionary. Args: lst (List[str]): The ...
evol_instruct_66k
33,131
Write a Python function to add a period punctuation mark at the end of a given string only if it doesn't already have one or if it's not empty. Additionally, remove any extra whitespace before the period. The function should handle various edge cases, such as empty strings, strings with trailing spaces, and strings tha...
Here is the Python code to solve the given problem in the markdown block: ```python def add_period_to_string(phrase: str) -> str: """ Adds a period punctuation mark at the end of a given string only if it doesn't already have one or if it's not empty. Also, removes any extra whitespace before the period. ...
evol_instruct_66k
33,134
Write a Python function to perform a binary search on a sorted array to find the range of indices where a given element `x` occurs. If the element is not found, return `-1`. The function should handle duplicate entries by returning a tuple with the start and end indices of the range where `x` occurs. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def binary_search_range(arr: List[int], x: int) -> Tuple[int, int]: """ Perform a binary search on a sorted array to find the range of indices where a given element `x` occurs. If the element ...
evol_instruct_66k
33,138
Write a Python function to calculate the sum of elements in an array of any length. The function should handle both positive and negative integers, as well as an empty array. The code should start with: ```python from typing import List def sum_of_array(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sum_of_array(arr: List[int]) -> int: """ Calculate the sum of elements in an array of any length. Args: arr (List[int]): The array of integers whose sum needs to be calculated. Re...
evol_instruct_66k
33,140
Write a Python function to generate the Fibonacci sequence up to a specified iteration index `n`. The function should return a list of Fibonacci numbers up to the `n`-th iteration. The Fibonacci sequence is defined such that each number is the sum of the two preceding ones, starting from 0 and 1. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def fibonacci_sequence(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the n-th iteration. Args: n (int): The iteration index up to which the Fibonacci sequence should be gen...
evol_instruct_66k
33,141
Write a Python function to generate a random combination of two numbers between 1 and 10, and return the combination as a tuple. The function should not print anything to the console. The code should start with: ```python import random def generate_random_combination() -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_combination() -> tuple: """ Generates a random combination of two numbers between 1 and 10. Returns: tuple: A tuple containing two random integers between 1 and 10. """ # G...
evol_instruct_66k
33,145
Write a Python function to convert a hexadecimal input (string) to its binary representation (string). The function should handle both uppercase and lowercase hexadecimal characters and should return the binary representation without leading zeros. The code should start with: ```python def hex_to_binary(x: str) -> str...
Here is the Python code to solve the given problem in the markdown block: ```python def hex_to_binary(x: str) -> str: """ Convert a hexadecimal input (string) to its binary representation (string). Args: x (str): The hexadecimal input string to be converted. Returns: str: The binary re...
evol_instruct_66k
33,146
Write a Python function to determine if two given strings are mutual anagrams, considering case insensitivity and ignoring non-alphanumeric characters. The function should return `True` if the strings are anagrams and `False` otherwise. The code should start with: ```python import re def are_anagrams(word1: str, word2...
Here is the Python code to solve the given problem in the markdown block: ```python import re def are_anagrams(word1: str, word2: str) -> bool: """ Determine if two given strings are mutual anagrams, ignoring case and non-alphanumeric characters. Args: word1 (str): The first string to be checked. ...
evol_instruct_66k
33,148
Write a Python function to sort the keys of a dictionary based on their corresponding values. The values can be either numeric (integers or floats) or strings. Numeric values should be sorted in ascending order, and string values should be sorted in lexicographical order. The function should handle potential exceptions...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def sort_dictionary_by_values(d: Dict[Any, Any]) -> Dict[Any, Any]: """ Sorts the keys of a dictionary based on their corresponding values. Numeric values are sorted in ascending order, and stri...
evol_instruct_66k
33,159
Write a Python function to convert a given string into title case format. The function should handle various edge cases, such as empty strings, strings with only whitespace, and strings with mixed case. The function should also handle punctuation and numbers appropriately, ensuring that only the first letter of each wo...
Here is the Python code to solve the given problem in the markdown block: ```python def to_title_case(text: str) -> str: """ Converts the given string into title case format. Args: text (str): The input string to be converted. Returns: str: The title case formatted string. Raises:...
evol_instruct_66k
33,167
Write a Python function to simulate a simple caching mechanism for a RESTful API. The function should store the recent requests and their responses in a dictionary, and return the cached response if the same request is made again. The function should handle three types of HTTP requests: GET, POST, and DELETE. The cache...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any, Optional def handle_request(request_type: str, url: str, data: Optional[Dict[str, Any]] = None, cache: Dict[str, Any] = {}) -> Dict[str, Any]: """ Simulate a simple caching mechanism for a RESTful ...
evol_instruct_66k
33,169
Write a Python function to convert a list of integers into a Python array and then return the sum of the elements in the array. The function should handle the conversion efficiently and ensure that the input list is not modified. The code should start with: ```python from typing import List import array as arr def lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import array as arr def list_to_array_sum(input_list: List[int]) -> int: """ Converts a list of integers into a Python array and returns the sum of its elements. Args: input_list (List[int])...
evol_instruct_66k
33,178
Write a Python function to calculate the total sum of values contained within a dictionary. The function should iterate through the dictionary using a for loop and sum the values. The code should start with: ```python from typing import Dict def sum_dict_values(my_dict: Dict[str, int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sum_dict_values(my_dict: Dict[str, int]) -> int: """ Calculate the total sum of values contained within a dictionary. Args: my_dict (Dict[str, int]): A dictionary with string keys and in...
evol_instruct_66k
33,190
Write a Python function to sort an array in ascending order using the Bubble Sort technique. The function should handle negative integers and zeros, and should not use any built-in sort methods. The code should start with: ```python from typing import List def bubble_sort(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort(arr: List[int]) -> List[int]: """ Sorts an array in ascending order using the Bubble Sort technique. Args: arr (List[int]): The array to be sorted. Returns: List...
evol_instruct_66k
33,202
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The function should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid. Args: m (int): The number of row...
evol_instruct_66k
33,223
Write a Python function to simulate the behavior of the provided JavaScript code snippet using a different methodology. The JavaScript code iterates over a list of names and prints each name to the console. Your task is to achieve the same output using a Python function that does not use a `for` loop or the `print` fun...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_names(people: List[str]) -> None: """ Simulates the behavior of the provided JavaScript code snippet by printing each name from a list of names. Instead of using a for loop or the print fun...
evol_instruct_66k
33,229
Write a Python function to compute the Manhattan distance between two points in a Cartesian coordinate system. The function should accept two tuples, each representing the coordinates of a point, and return the Manhattan distance between these two points. The Manhattan distance is defined as the sum of the absolute dif...
Here is the Python code to solve the given problem in the markdown block: ```python def manhattan_distance(pointA: tuple, pointB: tuple) -> int: """ Compute the Manhattan distance between two points in a Cartesian coordinate system. Args: pointA (tuple): A tuple representing the coordinates (x1, y1...
evol_instruct_66k
33,240
Write a Python function to create a 5x5 matrix filled with zeros using NumPy, and then modify the matrix such that the first row and the first column are filled with ones. The function should return the modified matrix. The code should start with: ```python import numpy as np def create_and_modify_matrix() -> np.ndar...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_and_modify_matrix() -> np.ndarray: """ Create a 5x5 matrix filled with zeros and modify it such that the first row and the first column are filled with ones. Returns: np.ndarray: A 5x5...
evol_instruct_66k
33,255
Write a Python function to remove the last item from a given list without using any inbuilt functions such as `pop()`. The function should return the modified list. Additionally, provide a corrected version of the erroneous code provided and explain the improvements made. 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 def remove_last_item(input_list: List[int]) -> List[int]: """ Removes the last item from the given list without using inbuilt functions such as pop(). Args: input_list (List[int]): The list ...
evol_instruct_66k
33,260
Write a Python function to generate the first `n` terms of 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` terms of the sequence. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci_sequence(n: int) -> List[int]: """ Generate the first n terms of the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two ...
evol_instruct_66k
33,266
Write a Python function to filter and return a list of books published after a specified year from a given list of book dictionaries. Each book dictionary contains 'title' and 'year' keys. The function should start with: ```python from typing import List, Dict def filter_books_by_year(books: List[Dict[str, any]], year...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_books_by_year(books: List[Dict[str, any]], year: int) -> List[Dict[str, any]]: """ Filters and returns a list of books published after a specified year. Args: books (List[Di...
evol_instruct_66k
33,274
Write a Python function to create a dictionary where the keys are numbers from 1 to 10, and the values are lists containing the square and cube of each key. Additionally, create a function that accepts a key and returns the corresponding list of values from the dictionary. The function should handle invalid keys by ret...
Here is the Python code to solve the given problem in the markdown block: ```python def create_dictionary() -> dict: """ Create a dictionary where keys are numbers from 1 to 10 and values are lists containing the square and cube of each key. Returns: dict: A dictionary with keys from 1 to 10 and va...
evol_instruct_66k
33,276
Write a Python function to find all even numbers and their indices in a given list, and calculate the average of these even numbers. If no even numbers are found, return a message indicating that no even numbers were found. The function should return a tuple containing the list of even numbers, the list of their indice...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_even_numbers(list_of_numbers: List[int]) -> Tuple[List[int], List[int], float]: """ Finds all even numbers and their indices in a given list, and calculates the average of these even numb...
evol_instruct_66k
33,289
Write a Python function to invert the elements within a given 2D integer array such that the element in the top right corner swaps positions with the bottom left corner and do the same for all subsequent elements in the array. The solution must not use any language-specific built-in functions or libraries for the inver...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def invert_2d_array(matrix: List[List[int]]) -> List[List[int]]: """ Inverts the elements within a given 2D integer array such that the element in the top right corner swaps positions with the bottom lef...
evol_instruct_66k
33,303
Write a Python function to calculate the total sum of all elements in a given 2-D matrix and identify and store any prime numbers found within the matrix. The function should return a tuple containing the total sum and a list of prime numbers. The code should start with: ```python from typing import List, Tuple def s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def check_prime(n: int) -> bool: """ Check if a given number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False...
evol_instruct_66k
33,309
Write a Python function to calculate the quadratic value of each element in a given list of prime numbers and return a list of these quadratic values. The function should use a single `while` loop to traverse through the list. The code should start with: ```python from typing import List def calculate_quadratic_value...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_quadratic_values(prime_nums: List[int]) -> List[int]: """ Calculate the quadratic value of each element in a given list of prime numbers and return a list of these quadratic values. Ar...
evol_instruct_66k
33,310
Write a Python function to calculate the sum of squares of the first n natural numbers. The function should take an integer `n` as input and return the sum of squares of all numbers from 1 to `n`. The code should start with: ```python def sum_of_squares(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def sum_of_squares(n: int) -> int: """ Calculate the sum of squares of the first n natural numbers. Args: n (int): The number of natural numbers to consider. Returns: int: The sum of squares of the fi...
evol_instruct_66k
33,330
Write a Python function to determine if a given string contains only ASCII printable characters. An ASCII printable character is defined as a character with an ordinal value between 32 and 126 (inclusive). The function should return `True` if all characters in the string are ASCII printable characters, and `False` othe...
Here is the Python code to solve the given problem in the markdown block: ```python def is_ascii_printable(input_string: str) -> bool: """ Determines if the given string contains only ASCII printable characters. Args: input_string (str): The string to be checked. Returns: bool: True if...
evol_instruct_66k
33,333
Write a Python function to compute the Least Common Multiple (LCM) of three distinct non-negative and non-zero integers efficiently. The function should consider computational time complexity, code readability, and efficiency. The code should start with: ```python import math def compute_lcm_of_three(a: int, b: int, c...
Here is the Python code to solve the given problem in the markdown block: ```python import math def compute_lcm_of_three(a: int, b: int, c: int) -> int: """ Compute the Least Common Multiple (LCM) of three distinct non-negative and non-zero integers. Args: a (int): The first non-negative and non-z...
evol_instruct_66k
33,336
Write a Python function to find and return the indexes of all occurrences of a given element in a given list. The function should handle lists of any size and return an empty list if the element is not found. The code should start with: ```python from typing import List def find_all_indexes(element: int, lst: List[int...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_all_indexes(element: int, lst: List[int]) -> List[int]: """ Find and return the indexes of all occurrences of a given element in a list. Args: element (int): The element to search...
evol_instruct_66k
33,339
Write a Python function to insert a new element at the beginning of a given list. The function should modify the original list in place and return the modified list. The code should start with: ```python from typing import List def insert_at_beginning(arr: List[int], new_element: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insert_at_beginning(arr: List[int], new_element: int) -> List[int]: """ Inserts a new element at the beginning of the given list. Args: arr (List[int]): The list of integers to which the...
evol_instruct_66k
33,340
Write a Python function to generate a two-dimensional array with the given number of rows and columns, filled with random integers between 1 and 100. The function should also provide an option to return the array in either row-major or column-major order. The code should start with: ```python from typing import List, U...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union import random def generate_array(rows: int, cols: int, order: str = 'C') -> Union[List[List[int]], List[int]]: """ Generates a two-dimensional array with the given number of rows and columns, fill...
evol_instruct_66k
33,350
Write a Python function to sort an array of strings alphabetically and group them by their first character. The function should return a dictionary where the keys are the first characters of the words, and the values are lists containing the words that start with those keys, sorted alphabetically. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def group_and_sort_words(words: List[str]) -> Dict[str, List[str]]: """ Groups and sorts an array of strings by their first character. Args: words (List[str]): A list of strings to be ...
evol_instruct_66k
33,381
Write a Python function to transform a given phrase by converting it to lowercase, removing any special characters and numbers, and reversing the order of the words. The function should start with: ```python import re def transform_phrase(phrase: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def transform_phrase(phrase: str) -> str: """ Transforms the given phrase by converting it to lowercase, removing any special characters and numbers, and reversing the order of the words. Args: phrase...
evol_instruct_66k
33,390
Write a Python function to generate the first `n` numbers in the Fibonacci sequence using memoization for performance optimization. The function should avoid redundant computations by storing previously computed Fibonacci numbers in a dictionary. The code should start with: ```python from typing import List def gener...
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 using memoization. Args: n (int): The number of Fibonacci numbers to generate. Re...
evol_instruct_66k
33,391
Write a Python function to convert a number represented in scientific notation (as a string) into a floating-point value. The function should handle both positive and negative exponents and should return the floating-point representation of the number. The code should start with: ```python def scientific_to_float(sci_...
Here is the Python code to solve the given problem in the markdown block: ```python def scientific_to_float(sci_num: str) -> float: """ Converts a number represented in scientific notation (as a string) into a floating-point value. Args: sci_num (str): The number in scientific notation to be conver...
evol_instruct_66k
33,397
Write a Python function to remove all occurrences of a specified fruit (case-insensitive) from a list of lists (2D array) representing fruits. The function should handle the case where the fruit does not exist in some of the lists. The function should return the updated list of lists. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def eradicate_fruit(fruit: str, fruits: List[List[str]]) -> List[List[str]]: """ Removes all occurrences of a specified fruit (case-insensitive) from a list of lists. Args: fruit (str): The ...
evol_instruct_66k
33,398
Write a Python function to determine the number of rows and columns in a given two-dimensional array (2D array). The function should return a tuple containing the number of rows and columns. The code should start with: ```python from typing import List, Tuple def get_dimensions(array_2D: List[List[int]]) -> Tuple[int,...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Tuple def get_dimensions(array_2D: List[List[int]]) -> Tuple[int, int]: """ Determine the number of rows and columns in a given 2D array. Args: array_2D (List[List[int]]): The 2D array fo...
evol_instruct_66k
33,399
Write a Python function to sort a dictionary by its values. The dictionary consists of elements with string keys and integer values. However, for keys with the same integer values, sort them in the descending order of their string lengths. If the string lengths are the same, sort them lexicographically in ascending ord...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dictionary_by_values(d: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary by its values. For keys with the same value, sorts them by the length of the keys in descending order. If th...
evol_instruct_66k
33,419
Write a Python function to merge two nested dictionaries without losing any data. If there are conflicting keys at the same level, the value from the second dictionary should overwrite the value from the first dictionary. The function should handle nested dictionaries recursively. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def merge_nested_dicts(dict1: Dict, dict2: Dict) -> Dict: """ Merge two nested dictionaries without losing any data. If there are conflicting keys at the same level, the value from the second diction...
evol_instruct_66k
33,424
Write a Python function to process a two-dimensional list of integers and check for specific conditions using nested if statements within a loop structure. If a number is divisible by both 3 and 5, log a message. Implement error handling to catch exceptions if division by zero is attempted. The function should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_two_dim_list(two_dim_list: List[List[int]]) -> None: """ Process a two-dimensional list of integers and check for specific conditions. If a number is divisible by both 3 and 5, log a mess...
evol_instruct_66k
33,445
Write a Python function to filter out all elements from a given list of integers that are below a specified limit. The function should return a new list containing only the elements that are greater than or equal to the specified limit. The code should start with: ```python from typing import List def filter_elements...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_elements_above_limit(num_array: List[int], limit: int) -> List[int]: """ Filters out all elements from the given list that are below the specified limit. Args: num_array (List[int...
evol_instruct_66k
33,450
Write a Python function to calculate the probability of selecting a girl from a class of students, given the total number of students and the number of boys. The function should handle input validation to ensure that the total number of students does not exceed 30 and is not less than 1, and that the number of boys doe...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_probability_of_girl(total_students: int, number_of_boys: int) -> float: """ Calculate the probability of selecting a girl from a class of students. Args: total_students (int): The total number of stude...
evol_instruct_66k
33,460
Write a Python function to sort a dictionary by its values, and in case of duplicate values, sort those items by their keys in lexicographical order. The function should return a new dictionary with the sorted items. The code should start with: ```python from typing import Dict def sort_dict_by_value_and_key(input_di...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dict_by_value_and_key(input_dict: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary by its values, and in case of duplicate values, sorts those items by their keys in lexicographical ord...
evol_instruct_66k
33,479
Write a Python function to capitalize all the words in a given sentence. The function should handle various edge cases, such as punctuation and multiple spaces between words. The function should start with: ```python def capitalize_words(sentence: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def capitalize_words(sentence: str) -> str: """ Capitalizes all the words in a given sentence. Args: sentence (str): The input sentence to be capitalized. Returns: str: The sentence with all words capit...
evol_instruct_66k
33,491
Write a Python function to convert a given faulty For loop into a logically correct While loop. The original For loop increments the loop variable `i` within the loop body, which is incorrect and inefficient. The task is to correct this behavior and ensure the While loop produces the same output as the intended For loo...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_for_to_while(amt: int) -> None: """ Converts a faulty For loop into a logically correct While loop. Args: amt (int): The upper limit for the loop (exclusive). Returns: None: This function do...
evol_instruct_66k
33,496
Write a Python function to calculate the highest common factor (HCF) of two given integers, handling negative integers and zero appropriately. The function should return the HCF of the absolute values of the two integers. If either integer is zero, the function should return the absolute value of the non-zero integer. ...
Here is the Python code to solve the given problem in the markdown block: ```python def highest_common_factor(num1: int, num2: int) -> int: """ Calculate the highest common factor (HCF) of two integers, handling negative integers and zero. Args: num1 (int): The first integer. num2 (int): Th...
evol_instruct_66k
33,499
Write a Python function to analyze a given string and return a dictionary representing the count of both upper-case and lower-case instances of every unique alphabetical character in the string. The function should be optimized for performance, considering that the input string can be very large. The function should ig...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import defaultdict def count_characters(text: str) -> dict: """ Analyzes the given string and returns a dictionary representing the count of both upper-case and lower-case instances of every unique alphabetical...
evol_instruct_66k
33,516
Write a Python function to calculate the cube of each value in a given dictionary and return a new dictionary with the same keys but with the values replaced by their cubes. The function should use a single `for` loop to traverse through the dictionary. The code should start with: ```python from typing import Dict def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def cube(n: int) -> int: """ Calculate the cube of a given number. Args: n (int): The number to calculate the cube of. Returns: int: The cube of the given number. """ re...
evol_instruct_66k
33,533
Write a Python function to compute the square of each element in a given list and return a new list containing these squared values. The function should handle lists of any length and should not modify the original list. The code should start with: ```python from typing import List def compute_squares(dataset: List[i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def compute_squares(dataset: List[int]) -> List[int]: """ Computes the square of each element in the given list and returns a new list containing these squared values. Args: dataset (List[in...
evol_instruct_66k
33,541
Write a Python function to create and initialize a five-dimensional NumPy array with a specified shape and data type. The array should have 4 elements per dimensional array, each of which is an array comprising 3 double type elements. The function should allow for both initializing with zeros and with random values. T...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_5D_array(random_init: bool = False) -> np.ndarray: """ Create and initialize a five-dimensional NumPy array with a specified shape and data type. Args: random_init (bool): If True, the...
evol_instruct_66k
33,553
Write a Python function to reverse a doubly linked list without using any extra space. The function should take the head of the doubly linked list as input and return the new head of the reversed list. The doubly linked list is represented by nodes where each node has a `prev` pointer to the previous node, a `next` poi...
Here is the Python code to solve the given problem in the markdown block: ```python class Node: def __init__(self, data): self.data = data self.prev = None self.next = None def reverse_doubly_linked_list(head: Node) -> Node: """ Reverses a doubly linked list without using any extra ...
evol_instruct_66k
33,556
Write a Python function to create a dictionary that includes key-value pairs for integer values that are even from a given list of numerical inputs. The value for each key should be the string "even". The function should handle lists of integers and return a dictionary with the specified structure. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_even_dict(input_list: List[int]) -> Dict[int, str]: """ Creates a dictionary from a list of integers where the keys are even numbers and the values are the string "even". Args: ...
evol_instruct_66k
33,584
Write a Python function to reverse a given string without using built-in reverse or reordering functions. The function should also include validation checks to ensure the input is a string. If the input is not a string, the function should return an appropriate error message. The code should start with: ```python def ...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(input_str: str) -> str: """ Reverses the given string without using built-in reverse or reordering functions. Args: input_str (str): The string to be reversed. Returns: str: The rever...
evol_instruct_66k
33,598
Write a Python function to compute the factorial of a provided integer using recursion and memoization. The function should adhere to the following constraints: 1. Do not use any in-built factorial modules or libraries. 2. Implement memoization to optimize the solution for larger inputs. 3. Handle large input values, u...
Here is the Python code to solve the given problem in the markdown block: ```python import sys def factorial_with_memoization(n: int, memo: dict = {}) -> int: """ Compute the factorial of a provided integer using recursion and memoization. Args: n (int): The integer for which to compute the factor...
evol_instruct_66k
33,600
Write a Python function to create an associative array (dictionary) where the keys are the unique words in a given sentence, and the values are the counts of vowel phonetics (a, e, i, o, u) in each corresponding word. The function should handle case insensitivity and punctuation. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_vowels_in_words(sentence: str) -> Dict[str, int]: """ Create an associative array where the keys are the unique words in the sentence, and the values are the counts of vowel phonetics (a, e...
evol_instruct_66k
33,609
Write a Python function to replace empty tuples with a specified value in a given list of tuples. The function should take two parameters: a list of tuples and a value to replace the empty tuples with. The function should return the modified list. The code should start with: ```python from typing import List, Tuple, A...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any def replace_empty_tuples(tuples_list: List[Tuple[Any]], replacement: Any) -> List[Tuple[Any]]: """ Replace empty tuples in a list of tuples with a specified value. Args: tuples_l...
evol_instruct_66k
33,613
Write a Python function to convert a given string to its lowercase equivalent. The function should handle any string input, including those with special characters and numbers, and return the lowercase version of the input string. The function should start with: ```python def convert_to_lowercase(input_string: str) -> ...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_lowercase(input_string: str) -> str: """ Converts the given input string to its lowercase equivalent. Args: input_string (str): The string to be converted to lowercase. Returns: str: The ...
evol_instruct_66k
33,615
Write a Python function to extract and categorize valid email addresses from a given text. The function should return two lists: one containing Gmail addresses and the other containing other valid email addresses. The email addresses should be validated according to the following conditions: 1. It contains one `@` char...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def extract_and_categorize_emails(text: str) -> Tuple[List[str], List[str]]: """ Extracts and categorizes valid email addresses from a given text. Args: text (str): The text...
evol_instruct_66k
33,616
Write a Python function to sort a given list of strings in ascending order by their length, and in case of a tie in length, sort them in lexicographically descending order. The length of the strings should be calculated by ignoring any whitespace or special characters. 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 import re def normalize_string(s: str) -> str: """ Removes all whitespace and special characters from the given string. Args: s (str): The string to normalize. Returns: str: The...
evol_instruct_66k
33,618
Write a Python function to find the top 3 highest elements in a given list along with their respective indexes. The function should return a list of tuples, where each tuple contains the index and the corresponding element. The function should handle lists of any length and ensure that the elements are sorted in descen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_top_3_elements_with_indexes(arr: List[int]) -> List[Tuple[int, int]]: """ Finds the top 3 highest elements in the given list along with their respective indexes. Args: arr (L...
evol_instruct_66k
33,619
Write a Python function to get the n most expensive items from a given dataset efficiently. The dataset is a list of dictionaries, where each dictionary represents an item with a 'name' and a 'cost' key. The function should return a list of the n most expensive items, sorted by their 'cost' in descending order. The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def get_n_most_expensive_items(dataset: List[Dict[str, any]], n: int) -> List[Dict[str, any]]: """ Returns the n most expensive items from the given dataset. Args: dataset (List[Dict[s...
evol_instruct_66k
33,626
Write a Python function to disassemble a given text string into its individual characters. The function should return a list of characters where each character from the input string is an element in the list. The code should start with: ```python from typing import List def disassemble_string(sentence: str) -> List[st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def disassemble_string(sentence: str) -> List[str]: """ Disassembles a given text string into its individual characters. Args: sentence (str): The input string to be disassembled. Retur...
evol_instruct_66k
33,627
Write a Python function to compute the product of all distinct dictionary keys after converting them into integer values. The function should take a dictionary as input, where the keys are strings representing integers and the values are arbitrary strings. The function should return the product of these integer keys. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def compute_product_of_distinct_keys(d: Dict[str, str]) -> int: """ Computes the product of all distinct dictionary keys after converting them into integer values. Args: d (Dict[str, str]): ...
evol_instruct_66k
33,646
Write a Python function to reverse a given list and return a new list where each element is repeated twice. The function should start with: ```python from typing import List def reverse_and_double(nums: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def reverse_and_double(nums: List[int]) -> List[int]: """ Reverses the given list of integers and returns a new list where each element is repeated twice. Args: nums (List[int]): The list ...
evol_instruct_66k
33,651
Write a Python function to sort a list of movies by their release year in reverse chronological order. Each movie is represented as a tuple where the first element is the movie title and the second element is the release year. The function should return a list of tuples sorted by the release year in descending order. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sort_movies_by_year(movies: List[Tuple[str, int]]) -> List[Tuple[str, int]]: """ Sorts a list of movies by their release year in reverse chronological order. Args: movies (List[Tu...
evol_instruct_66k
33,663
Write a Python function to flatten a two-dimensional matrix comprised of integer elements into a one-dimensional list. The function should handle matrices of any size, including empty matrices. The code should start with: ```python from typing import List def flatten_matrix(matrix: 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 flatten_matrix(matrix: List[List[int]]) -> List[int]: """ Flattens a two-dimensional matrix of integers into a one-dimensional list. Args: matrix (List[List[int]]): A two-dimensional m...
evol_instruct_66k
33,676
Write a Python function to transform a given list of integer elements into a string representation where each integer is separated by a comma. The function should handle lists of varying lengths, including empty lists. The code should start with: ```python from typing import List def list_to_comma_separated_string(in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def list_to_comma_separated_string(integer_list: List[int]) -> str: """ Transforms a list of integer elements into a string representation where each integer is separated by a comma. Args: i...
evol_instruct_66k
33,681
Write a Python function to generate a Fibonacci sequence up to a given number `y`. The function should return a list of Fibonacci numbers that are less than or equal to `y`. The code should start with: ```python from typing import List def generate_fibonacci_sequence(y: 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_sequence(y: int) -> List[int]: """ Generates a Fibonacci sequence up to a given number `y`. Args: y (int): The upper limit for the Fibonacci sequence. Returns: ...