messages
list
membership_label
int64
[ { "role": "user", "content": "You are tasked with implementing a simple caching mechanism for managing string data associated with unique keys. Your goal is to implement a function called `simple_cache` that takes two parameters: a list of keys and a list of values. The function should create a cache that s...
1
[ { "role": "user", "content": "Implement a function that converts a binary string into its decimal equivalent. The input will be a binary string consisting of only '0's and '1's. The function should return an integer representing the decimal value of the binary string." } ]
1
[ { "role": "user", "content": "You are tasked with creating a Python function that compares two sets of numerical data and calculates the average value for each set. The function should take in two lists of numerical values and return a tuple containing the average of the first set and the average of the sec...
1
[ { "role": "user", "content": "You need to create a function `generate_webrtc_link(ip_addr: str, port: int) -> str` that generates a WebRTC connection URL based on the given IP address and port number. The format of the generated URL should be 'https://<ip_addr>:<port>/webrtc'. Implement this function such t...
1
[ { "role": "user", "content": "You are given a list of dictionaries, where each dictionary represents a node with various attributes. Each node contains a 'name' attribute which is a string. Your task is to write a function that takes this list of dictionaries and returns a list of unique names of the nodes....
1
[ { "role": "user", "content": "You are given a list of integers where each integer represents a threshold value. Your task is to implement a function `get_threshold(threshold_id: int, thresholds: List[int]) -> int` that retrieves a threshold value from the list based on the provided `threshold_id`. If the `t...
1
[ { "role": "user", "content": "Implement a function called `greet` that returns a string greeting the world with the message 'Hello world!'." } ]
1
[ { "role": "user", "content": "You are given a list of strings representing game titles. Your task is to implement a function that removes a specified game title from the list. If the game title exists in the list, remove the first occurrence of that title and return True. If the game title does not exist in...
1
[ { "role": "user", "content": "You are tasked with creating a function `generate_calendar_days(title: str, start_date: str, end_date: str, weekdays: List[bool]) -> Dict[str, None]` that generates a calendar mapping for a specified range of dates. The function should take the following parameters: \n\n- `titl...
1
[ { "role": "user", "content": "You are tasked with creating a Python function that generates a command for synchronizing files and directories using the `rsync` utility. The function should take in the source path, destination path, and an optional flag for relative synchronization. The generated command sho...
1
[ { "role": "user", "content": "You are tasked with creating a Python function that processes a given list of file names and returns a list of all the Python files present in that list. You should exclude any files that are not Python files. The function should take a list of file names as input and return a ...
1
[ { "role": "user", "content": "Given an unsorted list of integers, write a function that finds the frequency of each unique element and returns a list of elements sorted in descending order based on their frequency. If multiple elements have the same frequency, they should be sorted in ascending order based ...
1
[ { "role": "user", "content": "Write a function to calculate the factorial of a given non-negative integer n using recursion. The function should return the factorial value. You can assume that the input n will be a non-negative integer." } ]
1
[ { "role": "user", "content": "You are tasked with implementing a Python function that takes a list of integers and returns a new list containing only the even integers from the original list. The function should preserve the order of the even integers as they appeared in the input list. You should create a ...
1
[ { "role": "user", "content": "You are tasked with implementing a Python function that simulates the creation of a simple 3D wrapper object. The wrapper is designed to take two input strings representing the names of objects (e.g., 'source_cube' and 'target_cube') and returns a tuple containing a wrapper nam...
1
[ { "role": "user", "content": "You are tasked with designing a function to manage bookings for a tutoring center. The function should accept a list of bookings, where each booking is represented as a tuple containing the day index, hour, room name, and type of booking (either 'tutorial' or 'pool'). The funct...
1
[ { "role": "user", "content": "You are tasked with representing a geographical location with specific attributes. Implement a function called `get_location_details` that takes the following parameters: `id` (integer), `latitude` (float), `longitude` (float), `design_number` (string), `creation_date` (string)...
1
[ { "role": "user", "content": "You are given two dictionaries, old_hashes and new_hashes, where the keys are filenames (strings) and the values are their corresponding hash values (strings). Write a function `is_modified` that takes a filename as input and returns True if the file has been modified, meaning ...
1
[ { "role": "user", "content": "You are tasked with implementing a function that simulates the behavior of a checkbox widget in a graphical user interface (GUI) application. The function should allow for enabling and disabling the checkbox, setting its initial state, and toggling its state. Your task is to im...
1
[ { "role": "user", "content": "Implement a function that computes the power of a number x raised to the exponent n. The function should handle cases where n can be zero or negative and should ensure that the time complexity is O(log n). Your function should be defined as follows: def power(x: float, n: int) ...
1
[ { "role": "user", "content": "You are given a list of probabilities, p, representing the likelihood of selecting each corresponding index from a list of items. Your task is to implement a function named `draw_index` that randomly selects an index based on the given probabilities. The input list `p` will con...
1
[ { "role": "user", "content": "Given a boolean value `b`, implement a function `boolean_to_string(b: Optional[bool]) -> Optional[str]` that converts the boolean value to its string representation. If `b` is None, the function should return None. If `b` is True, return the string 'true'. If `b` is False, retu...
1
[ { "role": "user", "content": "Given the lengths of the two bases of a trapezoid and its height, implement a function `calculate_area(base1: float, base2: float, height: float) -> float` that calculates the area of the trapezoid. The area can be calculated using the formula: (base1 + base2) * height / 2." ...
1
[ { "role": "user", "content": "Implement a function `my_recursive_function(data: List[int], transform_func: Callable[[int], int]) -> List[int]` that takes a list of integers `data` and a transformation function `transform_func`. The function should recursively apply `transform_func` to each element in `data`...
1
[ { "role": "user", "content": "Write a function `fibonacci_max(numbers: List[int]) -> int` that takes a list of six integers and returns the maximum value among those integers that belong to the Fibonacci sequence. If there are no Fibonacci numbers in the input, return -1." } ]
1
[ { "role": "user", "content": "You are tasked with implementing a function that processes a given layout and extracts fields from it. The layout is represented as a list, where each element can be either a string or a nested list of strings. Your task is to write a function `extract_fields(layout)` that extr...
1
[ { "role": "user", "content": "Implement a function `calculate_and_validate_grades(grade_list)` that takes a list of integers representing the grades of a student in various courses. The function should first validate each grade to ensure it is between 0 and 100. If any grade is outside this range, the funct...
1
[ { "role": "user", "content": "You are tasked with implementing a function called `add_player` that takes in a player's name, their address text, and an optional RSSI value (received signal strength indication). The function should add the player's name and address text to a global list called `players`. If ...
1
[ { "role": "user", "content": "You are tasked with implementing a custom decorator in Python that logs the execution time of a function. The decorator should log the start and end time of the function execution, along with the function name and its arguments. Additionally, the decorator should handle both po...
1
[ { "role": "user", "content": "Given a list of positive integers, implement a function `unique_odd_sum_elements(x)` that returns a sorted list of unique elements that have an odd digit sum and do not occur more than once in the input list. The final list should be sorted in ascending order. Each element in t...
1
[ { "role": "user", "content": "You are tasked with creating a Python function that processes a list of temperature readings and determines the average temperature. The function should handle potential errors such as an empty list and non-numeric values. The function should return the average temperature as a...
1
[ { "role": "user", "content": "You are tasked with creating a Python function that processes a list of integers and returns the sum of all the even numbers in the list. However, there's a catch - you must implement the function without using any conditional statements (if, else, etc.) or the modulo operator ...
1
[ { "role": "user", "content": "You are given a list of device parameters represented as dictionaries, where each dictionary contains keys 'driver', 'patched_driver', and 'vendor'. Your task is to implement a function `set_device_parameters(params: List[Dict[str, str]]) -> None` that modifies each dictionary ...
1
[ { "role": "user", "content": "You are tasked with creating a function called `dynamic_serialize` that takes in a Python object `data` and a string `format`. The function should serialize the `data` using the appropriate serialization method based on the `format` string and return the serialized data. The fu...
1
[ { "role": "user", "content": "Given two lists of integers, `graph` and `subgraph`, determine if `subgraph` is a spanning subgraph of `graph`. A subgraph is considered spanning if it contains all unique elements from `graph`. Implement a function `is_spanning(graph: List[int], subgraph: List[int]) -> bool` t...
1
[ { "role": "user", "content": "Write a function `extract_unique_words(text: str) -> set` that takes a string `text`, extracts all unique words from it while ignoring punctuation marks, and returns them in a set. The function should treat words as case-insensitive, meaning 'Word' and 'word' are considered the...
1
[ { "role": "user", "content": "Implement a function that generates the Fibonacci sequence up to the 'n-th' position, where 'n' is a non-negative integer provided as an argument. The function should return the 'n-th' Fibonacci number. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) ...
1
[ { "role": "user", "content": "You are given a staircase with 'n' steps. You can reach the top of the staircase by taking either 1 or 2 steps at a time. Your task is to implement a function `countWays` that takes an integer `n` as input and returns the total number of distinct ways to reach the top of the st...
1
[ { "role": "user", "content": "You are given a list of dictionaries where each dictionary represents a bot with the following attributes: 'user_id', 'bot_id', 'mu', 'sigma', 'score', 'games_played', 'version_number', 'language', 'update_time', 'compile_status', and 'organization_id'. Your task is to implemen...
1
[ { "role": "user", "content": "You are given a list of 2D coordinates representing the corners of a contour in a 2D space, along with the dimensions of a rectangular area (width and height). Your task is to determine if the contour touches any of the corners of the rectangle. If it does, you need to add the ...
1
[ { "role": "user", "content": "You are given a string representing a font name in SHX format. Your task is to map it to its corresponding True Type Font (TTF) file name according to a predefined mapping. The mapping is as follows: 'TXT' -> 'txt_____.ttf', 'ARIAL' -> 'arial.ttf', 'VERDANA' -> 'verdana.ttf', '...
1
[ { "role": "user", "content": "You are working on a bioinformatics project that involves processing genetic data. Your task is to implement a function `generate_batch_file(gene_name: str, location: str, threshold: int, start: int, end: int) -> str` that generates a batch file for processing genetic data. The...
1
[ { "role": "user", "content": "You are tasked with creating a function that validates a comma-separated string of email addresses. The function should ensure that each email address in the string is valid according to a specific validation rule. An email address is considered valid if it follows the standard...
1
[ { "role": "user", "content": "You are tasked with implementing a function that simulates a simple robotic system that can move in a grid. The grid is represented by a 2D list where '0' indicates an empty cell and '1' indicates an obstacle. The robot starts at the top-left corner of the grid (0, 0) and can o...
1
[ { "role": "user", "content": "You are tasked with implementing a function that generates a cache key for a web application based on a user account ID. The key format for caching the verification codes is defined as follows: `VCODE_KEY = 'VCode-%s'`, where `%s` is a placeholder for the user account ID. Your ...
1
[ { "role": "user", "content": "You are given a list of integers representing the values of some operations. Your task is to identify if the sequence of operations corresponds to a specific pattern defined as follows: The operation sequence must consist of exactly three operations with the following types in ...
1
[ { "role": "user", "content": "You need to implement a function that initializes a directory service object based on a given node name. The function should accept a single parameter, 'nodename', which is a string representing the name of the directory service node. If the node name is not empty and contains ...
1
[ { "role": "user", "content": "Given a string `s` and an integer `k`, remove all occurrences of any character that appears consecutively `k` or more times in the string. Return the modified string after all such characters have been removed. If no characters remain, return an empty string. For example, given...
1
[ { "role": "user", "content": "Given an integer x, write a function `solve(x)` that reverses the digits of the integer and returns the reversed integer. If the reversed integer exceeds the 32-bit signed integer range, return 0. The function should handle both positive and negative integers. For example, if t...
1
[ { "role": "user", "content": "You are given a URL query string that may contain parameters for 'style' and 'locale'. Write a function that takes this query string as input and returns the values associated with the 'style' and 'locale' parameters. If a parameter is not present, return 'None' for that parame...
1
[ { "role": "user", "content": "Given a time in milliseconds, write a function that converts this time into a string format representing hours, minutes, and seconds. The output should be in the format 'HH:MM:SS'. If the input is less than 0, return '00:00:00'. For inputs greater than or equal to 0, the functi...
1
[ { "role": "user", "content": "You are tasked with developing a Python function that simulates data retrieval and processing from a hypothetical data source. The function should take the following input parameters: a list of data items, a batch size, and a processing function. The goal is to retrieve data in...
1
[ { "role": "user", "content": "Given a 2D array of positive integers, calculate the mean of each column and return the results as a 1D array. The mean should be rounded down to the nearest integer. The input will be a matrix of shape (m, n) where m is the number of rows and n is the number of columns. You ne...
1
[ { "role": "user", "content": "You are tasked with implementing a function that simulates a simple bank account. The function should take a list of operations, where each operation is either a deposit (represented by a tuple ('deposit', amount)) or a withdrawal (represented by a tuple ('withdraw', amount)). ...
1
[ { "role": "user", "content": "Write a function `remove_duplicates(input_list)` that takes a list of elements and returns a set of unique integers derived from the list. The function should handle erroneous inputs by only including valid integers in the final set. If an element cannot be converted to an inte...
1
[ { "role": "user", "content": "You are given two dictionaries, `dict_a` and `dict_b`, which may contain nested dictionaries as values. Write a function `merge_dicts(dict_a, dict_b)` that merges `dict_b` into `dict_a`. The merging process should handle the following rules: If a key exists in both dictionaries...
1
[ { "role": "user", "content": "Write a function `cryptic_code(length)` that generates a secure cryptic code of the specified length. The code should include uppercase letters, lowercase letters, numbers, and special characters. The function must validate the input to ensure that it is a positive integer. If ...
1
[ { "role": "user", "content": "You are tasked with measuring the electrical properties of a circuit. Write a function `measureProperties` that simulates measuring both resistance and frequency based on the given parameters. The function will take the following parameters: `board` (an integer), `switch` (an i...
1
[ { "role": "user", "content": "You are tasked with implementing a function that simulates managing a book's reading progress. The function should take three parameters: the author of the book (a string), the initial location of the book (a string), and the number of pages to turn (an integer). The function s...
1
[ { "role": "user", "content": "You are tasked with implementing a function `check_keep_alive_timeout(client_timeout: int, server_timeout: int) -> str` that determines whether a client will maintain its connection with the server based on their keep-alive timeouts. The function takes two parameters: `client_t...
1
[ { "role": "user", "content": "You are given a string containing multiline text that may include newline characters. Write a function `format_multiline_string(s: str) -> str` that formats this string into a single line by replacing all newline characters with a space, and ensuring that there are no extra spa...
1
[ { "role": "user", "content": "You are tasked with determining if a given string represents an error status in a logging system. Implement a function that checks if the input string is equal to 'error'. The function should return True if the input string is 'error', and False otherwise. Your function should ...
1
[ { "role": "user", "content": "You are given a list of distances and a list of revenues corresponding to different nodes. Your task is to find the optimal alpha value between 0.0 and 1.0 (inclusive) that maximizes the overall savings calculated using the formula: saving = distance_saving * (1 - alpha) + reve...
1
[ { "role": "user", "content": "You are tasked with generating a SQL ORDER BY clause from a list of fields and their corresponding sort orders. Implement a function `generate_order_by(fields: List[str], sort_orders: List[str], table_pre: str = '') -> str` that takes the following parameters: \n\n- `fields`: A...
1
[ { "role": "user", "content": "Implement a function `score_person(age: int, city: str) -> int` that takes an individual's age and city of residence as input and returns a score based on the following criteria: If the person is under 30 and lives in 'Los Angeles', then score = 10; If the person is under 30 an...
1
[ { "role": "user", "content": "You are tasked with creating a function that simulates the response of a webhook when an account is created. The function should accept two parameters: `entity_id` (a string representing the unique ID of the account) and `entity_name` (a string representing the name of the acco...
1
[ { "role": "user", "content": "Implement a function `intricate_frequency_analyzer(test: str) -> dict` that takes in a string composed of space-separated characters, including uppercase and lowercase alphabets, numeric characters, and punctuation. The function should return a dictionary featuring the highest ...
1
[ { "role": "user", "content": "Given a list of dictionaries representing users, each containing 'name', 'age', 'profession', and 'location', implement a function `filter_users` that filters the users based on their profession, and returns a list of users who are of the specified profession and fall within a ...
1
[ { "role": "user", "content": "Given a string representing a file path, write a function that checks if the path is valid. A valid path contains only alphanumeric characters, underscores, hyphens, and periods. The function should return True if the path is valid and False otherwise. For example, 'valid_path....
1
[ { "role": "user", "content": "Implement a function that takes a list of strings as input and returns a new list containing the concatenation of the 9th and 10th characters from each string. If a string is less than 10 characters long, it should be ignored. The function should also raise a ValueError if the ...
1
[ { "role": "user", "content": "You are given a string that contains information about various queues in a specific format. Each queue's details are separated by the phrase 'Display Queue details'. The details for each queue include its label, current depth, maximum depth, and type in the following format: 'Q...
1
[ { "role": "user", "content": "You are tasked with updating an internal list with the contents from a provided list. Write a function `update_internal_list(list_name: str, new_items: List[str]) -> List[str]` that takes in a list name and a list of new items. It should merge the new items into the internal li...
1
[ { "role": "user", "content": "You are given a list of state variable names and a list of invocation contexts, represented as dictionaries. Each dictionary contains various state variables as keys. Your task is to implement a function `deduce_state_variables(state_names: List[str], contexts: List[Dict[str, A...
1
[ { "role": "user", "content": "Given an integer representing a precision level (or None), implement a function that converts this integer into a list containing that integer if it is not None, or an empty list if it is None. The function should return this list. The integer will be between 0 and 100 inclusiv...
1
[ { "role": "user", "content": "You are tasked with implementing a function that simulates a simplified file locking mechanism. The function should take two parameters: a list of strings `keys` representing the keys for the files, and a string `path` representing the directory path where the lock files would ...
1
[ { "role": "user", "content": "Implement a function `process_and_find_min_odd_index(arr: List[int]) -> int` that takes a list of unique integers and performs the following operations: First, sort the array in ascending order without using built-in sort functions. Then, swap the values at even and odd indices...
1
[ { "role": "user", "content": "You are tasked with implementing a Python function that processes a list of strings representing USB endpoints and returns the first OUT endpoint found. An OUT endpoint is a type of USB endpoint used for sending data from the host to the device. Each USB endpoint is represented...
1
[ { "role": "user", "content": "You need to implement a function that takes a string representing JSON data and returns the corresponding dictionary. The string will be well-formed and contain valid JSON. Implement the function `parse_json_string(json_string: str) -> dict:`. The function should handle decodin...
1
[ { "role": "user", "content": "You are tasked with implementing a function that processes a list of event signals and their corresponding handlers. The function should take two parameters: a list of event signals and a dictionary that maps each event signal to its handler function. The function should return...
1
[ { "role": "user", "content": "Given two integers x and y, write a function `compute_root(x, y)` that returns the y-th root of x. You can assume that x is a non-negative integer and y is a positive integer. The function should handle cases where the result is not an integer by returning a float value. If y i...
1
[ { "role": "user", "content": "You are tasked with creating a simple hash table that supports basic operations of inserting, retrieving, and removing key-value pairs using a separate chaining method to handle collisions. Your hash table should be able to store integer values associated with string keys. You ...
1
[ { "role": "user", "content": "You are tasked with creating a function that simulates a simple banking operation. The function should accept an initial transaction limit and a series of operations in the form of tuples. Each operation can either be a deposit or a withdrawal. The function should return the fi...
1
[ { "role": "user", "content": "You are given a list of command line arguments as strings that would typically be passed to a program. Your task is to parse these arguments and return a dictionary where the keys are the argument names (without the leading '--') and the values are the corresponding argument va...
1
[ { "role": "user", "content": "Implement a function that takes three coefficients of a quadratic equation, a, b, and c, and returns the two roots of the equation ax^2 + bx + c = 0. The roots should be returned as a tuple of complex numbers. If the roots are real, they should still be returned as complex numb...
1
[ { "role": "user", "content": "You are tasked with creating a custom exception class and implementing a function that simulates searching for a package in a package management system. Your custom exception class, named `PackageNotFoundError`, should inherit from the `Exception` class and accept a package nam...
1
[ { "role": "user", "content": "You are given a list of directed edges represented as pairs of integers in the form of a 2D array, where each pair (i, j) signifies a directed edge from node i to node j. Your task is to create a new list of edges that includes both the original edges and their reverse counterp...
1
[ { "role": "user", "content": "You are tasked with calculating the volume of a truncated prism given the dimensions of two triangular bases and the height of the prism. Implement the function `run_truncated_prism_volume(a1, b1, c1, a2, b2, c2, h)` that takes the lengths of the sides of the first triangle (a1...
1
[ { "role": "user", "content": "You are given a directed graph represented as an adjacency list and a start node. Your task is to implement a breadth-first search (BFS) algorithm to find the shortest path from the start node to a target node. Write a function `shortest_path(graph, start, target)` that takes i...
1
[ { "role": "user", "content": "Implement a function `prime_numbers(n)` that takes an integer `n` as input and returns a list of all prime numbers up to and including `n`. A prime number is defined as a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. The functio...
1
[ { "role": "user", "content": "Implement a function `is_palindrome_string(s: str) -> bool` that checks if a given string forms a palindrome, while ignoring spaces, punctuation, and case sensitivity. The function should return True if the cleaned string is a palindrome and False otherwise. A palindrome is def...
1
[ { "role": "user", "content": "Implement a function `Fibonacci(n: int) -> int` that returns the nth Fibonacci number. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. The function should handle cases where n is a non-negative integer (0 or greater)." }...
1
[ { "role": "user", "content": "You are tasked with implementing a function that retrieves the logarithmic scale factor for a given time unit. The time units can be one of the following: 'fs' (femtoseconds), 'ps' (picoseconds), 'ns' (nanoseconds), 'us' (microseconds), 'ms' (milliseconds), or 'sec' (seconds). ...
1
[ { "role": "user", "content": "You are given a list of dictionaries, where each dictionary represents the state of a system with the following keys: 'pcad_mode', 'clocking', 'fep_count', and 'ccd_count'. Write a function `find_modifiable_states(state_data: List[Dict[str, Union[str, int]]]) -> Tuple[List[int]...
1
[ { "role": "user", "content": "Implement the function `BurrowsWheelerTransform(string: str) -> str` that applies the Burrows-Wheeler Transform (BWT) method to a given string. The BWT is achieved by generating all circular permutations of the input string, sorting them, and returning the last column of the so...
1
[ { "role": "user", "content": "Given a list of integers representing the payoffs of a game for each player, write a function `calculate_social_welfare(payoffs: List[int], mix: List[float]) -> float` that calculates the expected social welfare of a mixed strategy profile. The `payoffs` list contains the payof...
1
[ { "role": "user", "content": "You are tasked with implementing a function that manages a simple in-memory settings dictionary for a hypothetical application. The settings dictionary should be initialized with a token when the function is called. The function should provide two capabilities: fetching the cur...
1
[ { "role": "user", "content": "You are tasked with creating a function that fills in missing IDs in a given dictionary structure. The function should take in a dictionary representing a mapping of sheet names to rows, where each row maps to an ID that may be either an integer or None. The function should fil...
1
[ { "role": "user", "content": "You are tasked with converting a list of numeric values into a list of floating-point numbers. Write a function `convert_to_float` that takes a list of integers or floats as input and returns a new list containing the same numbers converted to floats. The function should handle...
1
[ { "role": "user", "content": "Given two positive integers, implement a function `compute_gcd(a: int, b: int) -> int` to compute and return their Greatest Common Divisor (GCD). The GCD of two integers is the largest positive integer that divides both numbers without leaving a remainder." } ]
1
[ { "role": "user", "content": "You are tasked with calculating the center of mass of a system of particles in a 3D space. Given a list of particles' coordinates in 3D space and their respective masses, your function should compute the center of mass of these particles. The center of mass can be calculated us...
1