messages
list
membership_label
int64
[ { "role": "user", "content": "You are tasked with creating a function that performs a search on a list of strings. The function should take two parameters: a list of strings `items` and a string `query`. The function should return a list of strings that contain the `query` as a substring, case-insensitively...
0
[ { "role": "user", "content": "Define a function `create_animal(species: str, weight: float) -> dict` that takes a species as a string and a weight as a float and returns a dictionary representation of an animal with the keys 'species' and 'weight'." } ]
0
[ { "role": "user", "content": "You are tasked with developing a function that takes a list of form URLs as input and returns a list of unique forms extracted from these URLs. Each form URL is a string that may contain the same form multiple times, but the output list should contain each form only once. Imple...
0
[ { "role": "user", "content": "You are given a 2D array (list of lists) representing an arena with different shapes denoted by integers. Your task is to implement a function `assign_shape(extent, x_pos, y_pos)` that takes in the extent (a floating-point number), and the coordinates (x_pos and y_pos) of a pos...
0
[ { "role": "user", "content": "You are tasked with creating a function that takes in a dictionary of parameters for a clustering algorithm. The function should validate the parameters to ensure that they meet certain criteria. Specifically, the parameter dictionary must contain a key 'n_clusters' with a valu...
0
[ { "role": "user", "content": "You are tasked with validating configuration settings for a bot application. You need to implement a function called `validate_bot_config` that checks if the provided configuration settings are valid. The configuration settings will be passed as parameters to the function. The ...
0
[ { "role": "user", "content": "Given a string, implement a function that returns the first three unique alphabetic characters found in the string. The function should treat uppercase and lowercase letters as equivalent and ignore any non-alphabetic characters. If there are fewer than three unique alphabetic ...
0
[ { "role": "user", "content": "Given an array of integers, implement a function `length_of_LIS(nums)` that returns the length of the longest increasing subsequence in the array. An increasing subsequence is a sequence of numbers where each number is greater than the previous one. If the array is empty, the f...
0
[ { "role": "user", "content": "Implement a function `calculate_total_cost(cart_items: List[Dict[str, Union[str, float]]]) -> float` that takes a list of shopping cart items, where each item is represented as a dictionary containing the item's name and price. The function should return the total cost of all i...
0
[ { "role": "user", "content": "You are tasked with creating a function that determines the version of a software plugin given its module name as a string. The function should check if the module can be imported and return the module's version if it exists, otherwise return None. Implement the function `get_p...
0
[ { "role": "user", "content": "Given an array of integers, write a function that returns the number of distinct integers present in the array. For example, in the array [14, 12, 13, 11, 15], the function should return 5 because all numbers are distinct." } ]
0
[ { "role": "user", "content": "Implement a function `create_object()` that initializes an object with three attributes: `attribute1`, `attribute2`, and `attribute3`. The function should return a dictionary containing these attributes, initialized to `None`." } ]
0
[ { "role": "user", "content": "Implement a function `calculate_area` that calculates the area of a specified shape based on input parameters. The function should take in the following parameters: \n- `shape` (string): Represents the shape for which the area needs to be calculated. It can be either 'rectangle...
0
[ { "role": "user", "content": "You are tasked with implementing a function that processes a simulated response from a web request. The function should take a dictionary that simulates the response object and return the appropriate type based on the response properties. The response may contain the following ...
0
[ { "role": "user", "content": "Given a string, implement a function `string_analysis(s: str) -> Tuple[int, bool, str]` that returns a tuple containing the count of vowels in the string, a boolean indicating if the string is a palindrome, and the reversed version of the string. The function should handle empt...
0
[ { "role": "user", "content": "Given a list of strings representing the names of news providers that a user is subscribed to, implement a function `delete_news_site(news_sites: List[str], news_name: str) -> List[str]` that removes the specified `news_name` from the list. If the `news_name` is not found in th...
0
[ { "role": "user", "content": "You are tasked with implementing a URL routing system for a web application. Your job is to create a function that takes a URL as input and returns the name of the view function that matches the given URL based on predefined URL patterns. The URL patterns are defined using regu...
0
[ { "role": "user", "content": "Given a list of users represented by their usernames, implement a function that returns a list of unique usernames sorted in alphabetical order. Each username is a string and the function should ensure that there are no duplicates in the final list. The input will be a list of ...
0
[ { "role": "user", "content": "You are tasked with implementing a function that takes a word and a list of its pronunciations, and yields pairs of the word and its corresponding pronunciations. The function should handle the case where the number of pronunciations may be less than, equal to, or greater than ...
0
[ { "role": "user", "content": "You are tasked with implementing a job schema validator. A job schema is defined by a name and a list of required fields it must contain. Your goal is to write a function `validate_job_schema(schema_name: str, schema_fields: List[str], data: Dict[str, Any]) -> bool` that takes ...
0
[ { "role": "user", "content": "You are tasked with implementing a function that retrieves all the values from a specific column in a given dataset. The dataset is represented as a list of dictionaries, where each dictionary contains key-value pairs corresponding to column names and their respective row value...
0
[ { "role": "user", "content": "You are tasked with creating a function called `merge_sorted_arrays` that takes two sorted lists of integers and merges them into a single sorted list. The function should maintain the order of elements from the original lists. Write a function that accepts two lists of integer...
0
[ { "role": "user", "content": "Implement a function `is_happy(s: str) -> Union[bool, str]` that determines if a given string `s` is 'happy'. A string is considered 'happy' if it meets the following criteria: 1. It contains only lowercase alphabets, 2. Its length is at least 3, 3. No three consecutive charact...
0
[ { "role": "user", "content": "You are tasked with writing a function that generates commands to configure a Virtual Routing and Forwarding (VRF) instance. The function should accept a list of VRF names and a configuration action ('add' or 'delete'). Based on the action, it should return a list of command st...
0
[ { "role": "user", "content": "You are tasked with implementing a function that takes a list of strings as input and cleans up the names in the list according to a predefined mapping. The mapping is as follows: 'str' -> 'string', 'bool' -> 'boolean', 'int' -> 'integer'. Your function should return a new list...
0
[ { "role": "user", "content": "You are given a list of tasks, where each task is represented as a dictionary with the keys 'name', 'author', and 'completed'. Write a function `get_task_by_id(tasks: List[Dict[str, Union[str, bool]]], task_id: int) -> Dict[str, Union[str, bool]]` that retrieves a task from the...
0
[ { "role": "user", "content": "You are tasked with creating a Python function that translates a given text message from English to emoji language. The emoji language is represented by a dictionary where English words or phrases are mapped to their corresponding emoji symbols. Implement a function `translate_...
0
[ { "role": "user", "content": "You are tasked with implementing a function that simulates a simple messaging service. The function `message_service(messages)` takes a list of messages, where each message is represented as a dictionary with the keys 'sender', 'receiver', and 'message'. Your task is to return ...
0
[ { "role": "user", "content": "Implement a function `math_operations` that accepts two integers `int1` and `int2` and returns a dictionary containing the results of the following operations: addition, subtraction, multiplication, division (as a float), and modulo. If `int2` is zero, the division result shoul...
0
[ { "role": "user", "content": "You are tasked with implementing a function that checks if a given URL can be correctly reversed based on a predefined mapping of URL names to their corresponding paths. Write a function called `reverse_url` that takes a single argument `url_name`, a string representing the nam...
0
[ { "role": "user", "content": "You are tasked with implementing a function `exponential_backoff(max_retries: int, initial_delay_sec: float, delay_growth_factor: float, max_delay_sec: float) -> List[float]`. This function simulates a retry mechanism for a process that fails, where the wait time between retrie...
0
[ { "role": "user", "content": "You are given a list of file names and a search pattern in the form of a string that may contain a wildcard character '*'. Your task is to implement a function that returns a set of file names that match the given pattern. The wildcard character '*' can represent zero or more c...
0
[ { "role": "user", "content": "You are tasked with creating a function that simulates the processing of an image by an external command-line tool. The function should take two string parameters: an input image path and an output image path. Instead of actually processing the image, the function will simply r...
0
[ { "role": "user", "content": "You are tasked with implementing a function `read_dictionary_data(raw_bytes: bytes, num_values: int, converted_type: Optional[str]) -> List[Any]`. This function takes in three parameters: a byte string `raw_bytes`, an integer `num_values`, and an optional string `converted_type...
0
[ { "role": "user", "content": "Implement a function `flatten_and_sort(nested_list)` that takes a nested list, potentially containing integers and non-integer elements, and returns a sorted list of all the integers found within the nested structure. The function should handle varying depths of sublists and fi...
0
[ { "role": "user", "content": "You are given a tuple of area codes and a tuple of places associated with those area codes. Your task is to implement a function that takes in a tuple of area codes and returns a tuple of states corresponding to those area codes. If an area code does not exist in the provided a...
0
[ { "role": "user", "content": "You are given a list of anchors represented as rectangles in the format [x1, y1, x2, y2], where (x1, y1) is the top-left corner and (x2, y2) is the bottom-right corner. Write a function `shift_anchors(anchors: List[List[int]], direction: str) -> List[List[int]]` that shifts the...
0
[ { "role": "user", "content": "You are tasked with implementing a function that simulates waiting for a user event based on a given mask. The function should take an integer mask, an optional key represented as a string, an optional mouse position represented as a tuple of (x, y) coordinates, and a boolean i...
0
[ { "role": "user", "content": "Implement a function `check_anagram(string1: str, string2: str) -> bool` that determines if two distinct strings are anagrams of each other. An anagram is defined as a rearrangement of the letters of one string to form another string. The function should not use any built-in Py...
0
[ { "role": "user", "content": "You are given a list of monthly temperature readings and a corresponding list of monthly precipitation readings for a specific region. Your task is to calculate the average temperature and total precipitation for the months where the temperature is above a certain threshold. Im...
0
[ { "role": "user", "content": "Given a specific number of students in a class and the ratio of boys to girls in the form of a string (for example, '3:4'), write a Python function `calculate_students(total_students: int, ratio: str) -> List[int]` that calculates the number of boys and girls in the class based...
0
[ { "role": "user", "content": "Create a function that takes a list of strings and/or nested lists of strings up to N levels deep and returns a single list containing all the strings in a flattened format. Ensure that the function can handle errors and edge cases correctly. If the input is not a list, or if t...
0
[ { "role": "user", "content": "You are given a list of integers representing the heights of columns in a histogram. Write a function `max_rectangle_area(heights: List[int]) -> int` that calculates the area of the largest rectangle that can be formed in the histogram. The rectangle must be formed by contiguou...
0
[ { "role": "user", "content": "You are tasked with creating a function that processes a list of product dictionaries and extracts specific information about each product. Each product dictionary contains details about a particular product, and your function needs to extract and store relevant details in a re...
0
[ { "role": "user", "content": "You are tasked with implementing a function that calculates the total number of frames in a cycle based on the frames in one cycle and how many times all the other frames of the cycle repeat. Write a function `calculate_total_frames` that takes in two parameters: `frames_in_cyc...
0
[ { "role": "user", "content": "You are tasked with creating a function that simulates a simple context creation process. The function `create_context(policy: str, name: str) -> str` takes two parameters: a policy (a string describing the policy) and a name (a string representing the context name). The functi...
0
[ { "role": "user", "content": "You are given two strings, `corpus` and `directory`. Your task is to create a function `copy_files(corpus: str, directory: str) -> List[str]` that simulates copying all characters from the `corpus` string into a new string `directory`. The `directory` string should contain all ...
0
[ { "role": "user", "content": "You are given a list of summoner spell names represented as strings. Your task is to implement a function that returns a new list containing only the names of the summoner spells that start with the letter 'F'. The function should preserve the order of the spells from the input...
0
[ { "role": "user", "content": "You are tasked with implementing a function that initializes a configuration object for an application. The function should accept the following parameters: `name` (a string representing the application name), `host` (a string representing the host address), `port` (an integer ...
0
[ { "role": "user", "content": "You are tasked with creating a function that generates a specific string format based on two input parameters: location_id and conversation_id. The function should take in a list of two integers, where the first integer represents the location_id and the second integer represen...
0
[ { "role": "user", "content": "You are tasked with creating a function that formats a price given as a decimal number into a string representation with a maximum of 10 digits, including 2 decimal places. The function should take a single parameter, `price`, which is a decimal number. If the input exceeds the...
0
[ { "role": "user", "content": "You are given a list of summoner data and a profile name. Each summoner in the list is represented as a dictionary containing the following keys: 'profileIconId' (an integer), 'summonerLevel' (an integer), and 'duration' (an integer representing playtime for matches). Your task...
0
[ { "role": "user", "content": "You are tasked with implementing a function that evaluates the value of an integer variable, \"M\", and returns a specific message based on its value. Your function should take a single integer parameter, \"M\", and return the following messages: \n- If \"M\" is less than 10, r...
0
[ { "role": "user", "content": "Given two matrices A and B, both of dimensions m x n, write a function `compare_matrices(A: List[List[int]], B: List[List[int]]) -> bool` that checks if the two matrices are equal. Two matrices are considered equal if they have the same dimensions and all corresponding elements...
0
[ { "role": "user", "content": "You are tasked with generating a sequence based on a third-order linear recurrence relation. Given the first three terms of the sequence, a0, a1, and a2, and the coefficients a3, a4, and a5, your goal is to implement a function that returns the n-th term of the sequence. The se...
0
[ { "role": "user", "content": "You are given a unique identifier for a switch, represented as an integer, and a boolean flag indicating whether to raise an exception when the switch is missing. Your task is to implement a function `get_switch_status(switch_id: int, exception_when_missing: bool) -> str` that ...
0
[ { "role": "user", "content": "You are tasked with implementing a simple function that simulates the behavior of a GUI application with two buttons: \"OK\" and \"Cancel\". The function should take two boolean parameters, `ok_clicked` and `cancel_clicked`, which represent whether the \"OK\" button or the \"Ca...
0
[ { "role": "user", "content": "You are tasked with creating a function that constructs a URL based on a given endpoint and an object type. The function should accept two parameters: an endpoint (a string) and an object type (a string). It should return a formatted URL string in the form: '{endpoint}/{object_...
0
[ { "role": "user", "content": "You are given a list of questions for an exam, where each question has a score associated with it. You also have a list of submitted choices, which indicates whether a question was answered correctly or not. Your task is to implement a function `calculate_exam_grade(questions: ...
0
[ { "role": "user", "content": "Implement a function called `is_prime(n)` that determines if a given integer `n` is a prime number. A prime number is defined as a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. Your function should return `True` if `n` is prime,...
0
[ { "role": "user", "content": "You are tasked with creating a function that processes a string representing an edition indicator. Your function should take a string input, and if the string contains the substring 'ed.', it should return the string with 'ed.' removed. If the substring 'ed.' is not present in ...
0
[ { "role": "user", "content": "Given a dictionary representing a geographical site, implement a function `get_lat_lng(site)` that retrieves the latitude and longitude of the site from the 'org_coordinates' key. The function should return a tuple of (latitude, longitude) if the 'org_coordinates' key is presen...
0
[ { "role": "user", "content": "Implement a function that merges two nested dictionaries. The function should recursively combine the dictionaries such that if a key exists in both dictionaries and its value is a dictionary in both cases, the values should be merged. If the value is not a dictionary in one of...
0
[ { "role": "user", "content": "You are tasked with implementing a function named `validate_recovery` that takes three parameters: `file_a_size` (an integer representing the size of the first file), `file_b_size` (an integer representing the size of the second file), and `recovered_state` (a string representi...
0
[ { "role": "user", "content": "You are tasked with creating a function `format_message(message: str) -> str` that formats a given message by prepending a predefined hostname '[MyHost]' to it. The function should return the formatted message. For example, if the input message is 'Hello, World!', the output sh...
0
[ { "role": "user", "content": "You are tasked with creating a function that calculates the number of snapshots with the same hash and the number of lost snapshots from a list of file snapshots. Each snapshot can be represented by its relative path, modification time, file size, and an optional hash value. Gi...
0
[ { "role": "user", "content": "You are given a list of sentences and a list of character names. Your task is to implement a function that returns a dictionary where each key is a character name and the corresponding value is a list of sentences that contain that character's name. The comparison should be cas...
0
[ { "role": "user", "content": "Given a list of sentences, write a function `get_vocabulary(sentences: List[str]) -> Tuple[List[str], Dict[str, int]]` that computes the vocabulary of the provided sentences. The function should return a tuple containing two elements: a sorted list of unique words in descending...
0
[ { "role": "user", "content": "You are tasked with creating a function that simulates a simple decision-making process based on user input. The function should take a string input that represents the user's choice to either continue with a predefined action or to initiate a new action. The function should re...
0
[ { "role": "user", "content": "Given two integer arrays A and B, your task is to implement a function that returns the maximum number of uncrossed lines that can be drawn between the two arrays. A line can be drawn between A[i] and B[j] if A[i] == B[j], and the lines must not intersect. Each number from both...
0
[ { "role": "user", "content": "You are tasked with writing a function that takes a file name as input and simulates loading a database dump from that file. The function should return a string indicating the success or failure of the operation. If the file name ends with '.sql', return 'Database dump loaded s...
0
[ { "role": "user", "content": "Given a list of integers, implement a function that returns a new list containing only the unique elements from the original list while preserving the original order. The function should take one parameter, a list of integers, and return a list of integers. For example, if the ...
0
[ { "role": "user", "content": "Given a value, implement a function `template_check` that checks if the value is a string that equals 'true' (case-insensitive). If the value is a string, return `True` if it equals 'true' (case insensitive), otherwise return `False`. If the value is not a string, return the va...
0
[ { "role": "user", "content": "You are tasked with creating a function that takes a dictionary of integers and a multiplier as input. The function should return a new dictionary where each value in the original dictionary is multiplied by the given multiplier. If the input dictionary is empty or None, the fu...
0
[ { "role": "user", "content": "You are tasked with implementing a function that checks for overlap between two rectangles in a 2D space. The function takes in the positions and dimensions of the two rectangles and returns a boolean value indicating whether the rectangles overlap or not. The function signatur...
0
[ { "role": "user", "content": "Given a list of integers and decimals, implement a function that returns the list in a surprising arrangement. The surprising arrangement should obey these instructions: Begin with the greatest value, followed by the smallest among the rest, and continue this pattern by alterna...
0
[ { "role": "user", "content": "Implement a function that takes a list of video titles and a search keyword, and returns a list of titles that contain the keyword (case insensitive). The function should be named `search_videos` and it should accept two parameters: a list of strings `titles` and a string `keyw...
0
[ { "role": "user", "content": "Given an array of integers, `nums`, and an array of `requests` where each request is represented as a pair of indices `[starti, endi]`, write a function that returns the maximum total product of all requests among all permutations of `nums`. The product of any two adjacent elem...
0
[ { "role": "user", "content": "You are tasked with creating a custom function that serializes a dictionary representing an Airtable model. The Airtable model has four fields: 'base', 'table', 'category', and 'api_key'. Your function should take a dictionary with these four keys and return a serialized string...
0
[ { "role": "user", "content": "Given two points in a 2D plane represented by their coordinates (x1, y1) and (x2, y2), write a function `calculate_distance(x1: float, y1: float, x2: float, y2: float) -> float` that calculates the Euclidean distance between the two points. The Euclidean distance is defined as ...
0
[ { "role": "user", "content": "Implement a function that performs the bubble sort algorithm on a given list of integers. The function should take a list as input and return a new sorted list in ascending order. The original list should remain unchanged." } ]
0
[ { "role": "user", "content": "Write a function `compare_strings` that takes two strings as input and returns a list of indices where the two strings differ. If the strings are of different lengths, the function should only compare up to the length of the shorter string. The comparison should be case-sensiti...
0
[ { "role": "user", "content": "Implement a function `advanced_filter(lst)` that takes a list of integers `lst`, which may include negative numbers and zeros. The function should return a new sorted list containing only the even numbers that meet the following criteria: they must be located at non-prime indic...
0
[ { "role": "user", "content": "You are tasked with implementing a simple interpreter error handling system. Your goal is to create a custom exception class called `UndefinedVariableError` that inherits from a base exception class called `InterpreterRuntimeError`. This exception should be raised when the inte...
0
[ { "role": "user", "content": "You are tasked with creating a function that checks if a user exists based on their user ID from a list of user dictionaries. The function should take a list of user dictionaries and a user ID as parameters. Each user dictionary contains a 'userId' key. The function should retu...
0
[ { "role": "user", "content": "You are tasked with implementing a function that simulates adding a file information entry with some default values. The function should accept a dictionary containing file attributes and update it with default values for 'updated_at', 'file_index', and 'id'. The 'path' attribu...
0
[ { "role": "user", "content": "You are given a shape represented as a dictionary with a key 'lineWidth' that defines the width of the line associated with that shape. Write a function `applyLineWidth(shape: dict, lineWidth: float) -> None` that updates the 'lineWidth' of the provided shape dictionary with th...
0
[ { "role": "user", "content": "Given a list of integers, write a function that returns the maximum sum of any contiguous subarray within the list. A contiguous subarray is defined as a sequence of elements that are consecutive in the array. You need to implement a single function `max_subarray_sum(arr: List[...
0
[ { "role": "user", "content": "You are tasked with generating a command string based on provided parameters. Write a function `generate_command_string` that accepts keyword arguments representing different parameters and constructs a command string in the following format: 'command --param1 value1 --param2 v...
0
[ { "role": "user", "content": "Write a function called `is_geometric_progression` that takes a list of numbers as input and returns a boolean indicating whether the numbers form a geometric progression. A sequence of numbers is said to be in geometric progression if the ratio between consecutive elements is ...
0
[ { "role": "user", "content": "You are tasked with creating a Python function that compares two version numbers represented as strings and determines which version is greater. The version numbers are in the format 'x.y.z', where x, y, and z are non-negative integers, and may also contain fewer than three seg...
0
[ { "role": "user", "content": "Implement a function in Python that checks if two strings are anagrams of each other. The comparison should be case-insensitive and should consider special characters and numbers as well. The function should return True if the strings are anagrams, and False otherwise." } ]
0
[ { "role": "user", "content": "Given a string, write a function that counts the total number of palindromic substrings of all lengths in the string. A palindromic substring is a substring that reads the same forward and backward. The function should take a single string as input and return the count of all p...
0
[ { "role": "user", "content": "Implement a function `intersperse` that accepts a list of integers `numbers` and a single integer `delimiter`. The function should return a new list with the integer `delimiter` inserted between each pair of consecutive elements in `numbers`. If `delimiter` is negative, you sho...
0
[ { "role": "user", "content": "You are tasked with implementing a Python function that calculates the average score for a given set of students based on their performance in a series of tests. The function should take in a dictionary containing the test scores for each student and return a new dictionary wit...
0
[ { "role": "user", "content": "You are given a dictionary of constants where the keys are constant values and the values are their corresponding names as strings. Write a function `get_constant_name(constant_dict: Dict[int, str], value: int) -> str` that returns the name of the constant associated with the g...
0
[ { "role": "user", "content": "Given a positive integer n, write a function `find_divisors(n)` that returns a list of all unique numbers that divide evenly into n. The output list should be sorted in ascending order." } ]
0
[ { "role": "user", "content": "You are tasked with creating a program that simulates a simple game using a 5x5 grid. The game involves a player navigating through the grid to reach a goal while avoiding obstacles. The player's position and the goal position are represented by specific indices on the grid (fo...
0
[ { "role": "user", "content": "You are tasked with implementing a simple OAuth authentication mechanism. Your goal is to create a function named `oauth_response` that simulates the responses for different OAuth-related actions based on given parameters. The function should take the following parameters: \n- ...
0
[ { "role": "user", "content": "You are tasked with creating a function that checks if a user has the necessary authorization headers based on their provided username and password. The function should accept three parameters: a URL (string), a username (string or None), and a password (string or None). If eit...
0