instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are given two arrays of strings `queries` and `words`, where `queries[i]` is a query and `words[j]` is a word. Each query `queries[i]` consists of lowercase English letters, and the length of `queries[i]` is less than or equal to 10. Each word `words[j]` consists of lowercase English letters, and the length of `wor...
codefeedback
You are tasked with parsing and extracting specific information from a JSON object representing a car model. The JSON object contains various attributes such as the car's number, name, manufacturer, fuel type, safety options, and convenience options. Your goal is to write a program that extracts and displays the follow...
codefeedback
You are working on a task scheduler system that manages dependencies between tasks. Each task is represented by a task ID, and dependencies between tasks are defined by specifying which tasks need to be completed before another task can start. Your task is to implement a function that, given a list of tasks and their d...
codefeedback
You are working on a scientific data analysis project and need to implement a method for calculating the median and 1-sigma measurement of a parameter called "ddt" (without a lambda correction factor). The code snippet provided is part of a larger class that handles different types of likelihood measurements. Your task...
codefeedback
You are working on a localization feature for a web application, and you need to implement a function that will parse a given array of key-value pairs representing translations and return a new array containing only the keys that have a specific prefix. You are given an array `$translations` in the following format: `...
codefeedback
You are tasked with creating a script to automate the generation of a SLURM job submission file for a computational chemistry application. SLURM (Simple Linux Utility for Resource Management) is a job scheduler used in high-performance computing environments. The provided code snippet is a part of a script that generat...
codefeedback
You are tasked with implementing a shell script that simulates the behavior of the `exec` command for managing Docker containers. The script should handle the execution of a specified command within a running container. The script should also provide a help message for users to understand its usage. Your task is to co...
codefeedback
You are tasked with implementing a progress tracking system for a game development project. The provided code snippet is part of a larger system responsible for managing the progress of replacing prefabs in a game scene. The `ReplaceWithLoaded` method is an asynchronous operation that replaces existing prefabs with loa...
codefeedback
You are given a function `trackbackNodes` that takes in three parameters: `startNode`, `endNode`, and `prev`. The `prev` parameter is an object that represents the previous node for each node in a directed graph. The function is expected to return an array containing the path from `startNode` to `endNode` based on the ...
codefeedback
You are tasked with implementing a command-line interface (CLI) for a cloud computing application using Python's `argparse` module. The CLI should support various options for configuring the application's settings. However, the given code snippet contains some issues that need to be addressed. Your task is to identify...
codefeedback
You are tasked with implementing a function to handle maintenance actions for a distributed system. The code snippet provided is a part of a larger system and contains a function `paasta_maintenance` that is called when the program is executed. The function `paasta_maintenance` is responsible for checking if a host is ...
codefeedback
You are given a 2D array representing a game board. Each cell in the array contains an integer representing the score of that cell. The game board is represented as a numpy array. Your task is to implement a function that finds the maximum score that can be obtained by moving from the top-left cell to the bottom-right ...
codefeedback
You are given a Python code snippet that involves testing a convolution operation. Your task is to implement a function to perform a 2D convolution on a given input matrix using a specified weight matrix, and then compare the result with another method for performing the same convolution. The code snippet provided is ...
codefeedback
You are tasked with creating a PHP program that utilizes the ReactPHP library to implement a simple ZeroMQ (ZMQ) subscriber. The program should subscribe to a ZMQ publisher and output any messages received. Your task is to complete the PHP program by adding the necessary code to subscribe to a ZMQ publisher and handle...
codefeedback
You are tasked with creating a program that parses a given text to extract the license information. The license information is enclosed within a specific format and may appear multiple times within the text. Your program should extract all occurrences of the license information and store them in a list. Write a functi...
codefeedback
You are tasked with implementing a class for a vehicle in a racing game. The class, named `Vehicle`, has attributes for speed, top speed, pivot rotation, and drift speed. The provided code snippet shows part of the logic for handling speed and drift speed constraints within the class. Your task is to complete the imple...
codefeedback
You are tasked with creating a Python function that processes a list of FastCGI targets and generates corresponding health check targets based on certain rules. The input list `fcgi_targets` contains strings representing FastCGI targets. Your task is to create a function `generate_healthcheck_targets(fcgi_targets)` tha...
codefeedback
You are tasked with creating a script to automate the setup of a CouchDB instance, including starting the service, creating a user, and optionally creating a database. Your script should handle the necessary checks and commands to ensure the successful setup of the CouchDB environment. Given the provided code snippet ...
codefeedback
You are tasked with implementing a subclass of an OAuth2 authenticator in a Java application. The `LiveAuthenticator` class needs to extend the `OAuth2Authenticator` class and provide specific functionality for authenticating users with a live service. The `OAuth2Authenticator` class is responsible for handling the OAu...
codefeedback
You are tasked with creating a program that simulates a simple text-based game where the player navigates through a maze. The maze is represented as a 2D grid, with each cell containing a specific symbol to denote the type of terrain or obstacle. The player can move up, down, left, or right within the maze, but cannot ...
codefeedback
You are tasked with creating a simple iOS app that allows users to manage a to-do list. The app should have a main screen displaying the list of tasks and an "Add" button to add new tasks. When the user taps on a task, a pop-up alert should appear, displaying the details of the selected task. To achieve this, you need...
codefeedback
You are tasked with implementing a function to parse and process JSON-RPC responses in a Swift application. The JSON-RPC protocol is used for making remote procedure calls using JSON-encoded data. In this scenario, you need to create a function that can handle the response from a specific JSON-RPC request and extract t...
codefeedback
You are tasked with creating a Python function that processes a given text file containing Chinese sentences. The function should read the file, split the sentences into words, remove any empty strings, and then shuffle the sentences for later validation set partitioning. Your task is to implement the `process_chinese...
codefeedback
You are tasked with implementing a memoization decorator in Python to optimize the performance of a function. Memoization is a technique used to store the results of expensive function calls and return the cached result when the same inputs occur again. The provided code snippet shows a Python property decorated with a...
codefeedback
You are tasked with creating a web application that manages user accounts. The application uses the Laravel framework, and the code snippet provided is from a Blade template file. The `@section('content')` directive is used to define a section of the template, and the `<div class="container">` tag is used to create a c...
codefeedback
You are tasked with creating a Python script that automates the process of running a BodyPix model using OpenGL on an i.MX platform. The provided code snippet is from a shell script named `run_bodypix_gl_imx.sh`, which invokes the Python script `bodypix_gl_imx.py` with specific command-line arguments. Your task is to w...
codefeedback
You are tasked with creating a Python function that generates Verilog code for combinational logic circuits. The function should take a dictionary representing the combinational logic circuit as input and produce the corresponding Verilog code as output. The input dictionary will have the following structure: ```pytho...
codefeedback
You are given a code snippet that involves appending values to a list based on calculations using `keypoint_coords`, `x0`, `y0`, and `y_diff`. Your task is to create a function that takes these variables as input and returns the resulting list `h` after performing the given calculations. The variables and their meanin...
codefeedback
You are tasked with implementing a simple reference-counted smart pointer in Rust. Reference counting is a technique used to track the number of references to a resource so that the resource can be deallocated when it is no longer in use. In this problem, you will create a reference-counted smart pointer using Rust's `...
codefeedback
You are working on a project that involves handling protocol buffer messages in C++. Your task is to implement a function that serializes a specific protocol buffer message type, `DiscardRequest`, into a byte array. The `DiscardRequest` message has a required string field named `message` with field number 1. You need t...
codefeedback
You are working on a data processing script for a multinational company. The script is responsible for cleaning and formatting a dataset containing employee information. The dataset is stored in a file named `filename` located in the `download` directory. The script contains several functions to perform various data pr...
codefeedback
You are tasked with creating a multi-threaded program to process a queue of numbers. The program should utilize a thread pool to efficiently handle the workload. Each thread in the pool will retrieve a number from the queue and perform some operations on it. The operations include printing the number being worked on, c...
codefeedback
You are given a code snippet that involves the use of the NumPy library in Python. Your task is to write a function that takes a NumPy array as input and performs a specific transformation on it. The transformation involves reshaping the input array and then applying a mathematical operation to the elements based on ce...
codefeedback
You are tasked with implementing a filtering feature for an e-commerce website. The website has a `Filter` component that needs to be integrated with the backend service to fetch and display product data based on the selected filters. The backend service provides a type `TProductFilterData` that contains the necessary ...
codefeedback
You are tasked with creating a Python program that reads a list of names from a file, manipulates the data, and then writes the modified content back to the file. The program should handle potential errors and ensure the file is properly closed after use. Your task is to complete the Python program by implementing the...
codefeedback
You are tasked with creating a file upload validation system for a web application using PHP. You need to implement a method within the `Files` class that validates the uploaded file based on certain rules. The `Files` class is a model class that represents files in the application. It has a public property `$file` wh...
codefeedback
You are tasked with implementing a custom macro for generating a hash map in Rust. The macro should take a list of key-value pairs and produce a hash map with the provided pairs. The macro should also support specifying the type of the keys and values. Your task is to create the macro `hash_map!` that fulfills these re...
codefeedback
You are tasked with implementing a simple stack data structure in Swift. A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. It has two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack. Your task is to creat...
codefeedback
You are tasked with creating a Python script that automates the installation of Docker and its Python library. The script should install Docker Community Edition (CE) using the package manager `apt` and then upgrade the `pip` package manager before installing the `docker` Python library for the current user. Additional...
codefeedback
You are tasked with implementing a template metaprogramming problem in C++. Given the provided code snippet, you need to create a template metaprogram that associates a specific bit with a given value. The code snippet demonstrates the usage of the `lp::assoc_bit` template to associate a bit with a particular value. Y...
codefeedback
You are tasked with implementing a data encryption and persistence function in PHP. The function should accept sensitive data, encrypt it using a specified key and associated data, and then persist the encrypted data to a specified file path. You need to implement the `encryptAndPersist` function with the following si...
codefeedback
You are working on a project that involves training a deep learning model using PyTorch. As part of the data preprocessing pipeline, you need to create a custom dataset class and a corresponding data loader to efficiently load and process the training data. Your task is to implement a custom dataset class and then use ...
codefeedback
You are tasked with creating a Python class that simulates a progress bar with a spinner animation. The progress bar should be able to display progress in a graphical user interface (GUI) and include a spinner animation while the progress is being updated. Your task is to implement the `ProgressBarWithSpinner` class wi...
codefeedback
You are tasked with implementing a program to process log entries from a security system. Each log entry is represented by a `Line` struct, containing an ID, a date and time, and an action. The date and time are represented using the `DateTime` type from the `chrono` crate. The `Line` struct and its associated methods ...
codefeedback
You are given a Python code snippet that initializes a list of clock names and a delay ratio variable. Your task is to write a function that calculates the delay for each clock based on the delay ratio and returns a dictionary mapping each clock name to its corresponding delay. The delay for each clock is calculated u...
codefeedback
You are tasked with implementing a Java class to simulate the movement of a robot on a 2D grid. The robot can move in four directions: up, down, left, and right. The initial position of the robot is at the coordinates (0, 0) on the grid. You need to create a class called `Robot` with the following functionalities: 1. A...
codefeedback
You are tasked with creating a simple virtual machine that can execute WebAssembly (Wasm) code. Your task is to implement a function that initializes and runs a Wasm module. You are given a code snippet representing a Wasm module in a custom format. The module contains a global variable `$g` initialized to 0 and a fun...
codefeedback
You are tasked with implementing a custom decorator function in JavaScript that modifies the behavior of another function. Decorators are a common pattern in JavaScript, often used in frameworks like React to enhance the functionality of components. Your task is to create a decorator function called `withLogging` that...
codefeedback
You are tasked with creating a Python function that processes a JSON payload to generate a token. The function should take a JSON payload as input and return a token as output. The token should be generated based on the data in the payload using a specific algorithm. Write a Python function `generate_token(payload: di...
codefeedback
You are tasked with creating a Python program that simulates a simple console-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player can move up, down, left, or right within the grid, and the game ends when the player collects all the treas...
codefeedback
You are working on a project to model biochemical pathways using a graph-based approach. The code snippet provided is a part of the program that constructs a graph representing interactions between various biochemical entities. The entities include abundances of chemical compounds, proteins, and their relationships. Y...
codefeedback
You are tasked with creating a program to validate email addresses using a regular expression pattern. Your program should take a string as input and determine whether it is a valid email address based on the following criteria: - The email address should consist of a local part and a domain part separated by an '@' sy...
codefeedback
You are tasked with implementing a function to validate International Standard Book Numbers (ISBN-10). An ISBN-10 is a 10-digit code, with the last digit possibly being 'X' to represent 10. The function should take a string `isbn` as input and return `True` if the input is a valid ISBN-10, and `False` otherwise. A va...
codefeedback
You are tasked with implementing a Rust module loader that can handle both sequential and parallel iteration over modules. The given code snippet shows a collection of Rust module files and their corresponding modules. The modules are organized into different sub-modules, such as `chunk`, `chunk_exact`, `into_iter`, `i...
codefeedback
You are working on a quantum computing project and need to implement a function to process stabilizer operators. Stabilizer operators are represented as QubitOperators or lists of stabilizers. However, the existing code snippet contains some error handling and processing logic that needs to be completed. You are taske...
codefeedback
You are given a Python code snippet that prints a pattern of "B" and "G" characters. The code snippet is as follows: ```python print("B",end="") else: print("G",end="") print("") ``` Your task is to write a Python function that takes an integer `n` as input and prints a pattern of "B" and "G" characters based on...
codefeedback
You are tasked with implementing a class that manages the provisioning state of private endpoints. The class should include validation rules for specific attributes and a mapping of attributes to their corresponding keys and types. Your task is to create the class with the required functionality and ensure that the val...
codefeedback
You are tasked with implementing a function that reshapes an input tensor and applies a multi-layer perceptron (MLP) to it using TensorFlow. The function takes an input tensor of shape [B, n, d_in], where B represents the batch size, n represents the number of observations, and d_in represents the input dimension. Addi...
codefeedback
You are tasked with implementing a method to extract variable parts from a given URI pattern using regular expressions. The URI pattern may contain placeholders enclosed in curly braces, representing dynamic parts of the URI. Your task is to extract these variable parts and store them in a list. Write a function or me...
codefeedback
You are tasked with implementing a Python function that processes input data to extract information about houses from a file. The file contains data about various houses, and the function should parse this data and return a list of houses with their attributes. You are given a code snippet that includes a test case fo...
codefeedback
You are tasked with implementing a function that will parse a given HTML snippet and count the number of nested HTML elements within it. For the purpose of this problem, we will consider the following HTML elements: `<div>`, `<form>`, and `<h6>`. The nesting level of an element is determined by the number of its ancest...
codefeedback
You are tasked with implementing a Prolog interpreter in Python. Prolog is a logic programming language that uses a form of symbolic logic for expressing queries and inference rules. Your goal is to create a Python function that simulates the behavior of a Prolog interpreter for a specific set of rules and queries. Yo...
codefeedback
You are tasked with implementing a function to calculate the Jacobian determinant of a given transformation matrix. The Jacobian determinant is a crucial concept in calculus and is used in various fields such as physics, engineering, and computer graphics. The Jacobian determinant represents how the volume changes unde...
codefeedback
You are tasked with implementing a simple asynchronous task scheduler for a microcontroller using the Arduino Uno platform. The scheduler should allow tasks to be scheduled for execution at specific intervals. The microcontroller has a single-core processor and limited memory, so the scheduler needs to be efficient and...
codefeedback
You are tasked with simulating the processing and escalation of messages within a system. The system consists of a `MessageProcessor` class responsible for processing basic and rich messages, a `Script` class containing basic and rich messages, a `Snapshot` class representing a snapshot of the system's state, an `Escal...
codefeedback
You are tasked with creating a Python function that emulates the behavior of the `pull` and `push` functions used in the given code snippet, which are used to transfer variables between Python and R environments. The `pull` function retrieves a variable from the R environment and returns it as a Python object, while th...
codefeedback
You are tasked with creating a script to automate the transfer of data from a remote server based on the modality specified in a configuration file. The configuration file contains lines in the format "key,value" where "key" represents the modality and "value" represents the specific details for transferring data. You...
codefeedback
You are tasked with creating a program that parses a configuration file for the Sphinx documentation builder and extracts specific information from it. The configuration file is in a simple text format and contains various options and settings for the documentation builder. Your goal is to extract and display the paths...
codefeedback
You are tasked with implementing a deep copy method for a class hierarchy in Java. The provided code snippet is a part of an abstract class `Continuation` that requires a deep copy method to be implemented. A deep copy is a type of copy where not only the object itself is duplicated, but also all the objects referenced...
codefeedback
You are tasked with implementing a generic `Filter` method for a custom `Result` class in C#. The `Filter` method should take two parameters: a predicate function and an exception mapping function. The `Filter` method should return a new `Result` object based on the following conditions: - If the input `Result` object ...
codefeedback
You are tasked with implementing a Python class method that crops an image to a specified mask. The method should take the coordinates of the mask's bounding box and return the cropped region of the image. The image is represented by a class instance with attributes `top`, `bottom`, `left`, and `right` representing the...
codefeedback
You are tasked with creating a script that simulates the behavior of a never-ending daemon. Your script should include an initialization message, set the appropriate permissions for a file, and create a startup/init script to be executed as a non-root user. Your script should perform the following tasks: 1. Output the...
codefeedback
You are tasked with implementing a Python class that calculates the edge betweenness centrality of a given graph. Edge betweenness centrality is a measure of the importance of an edge in a network, based on the number of shortest paths that pass through it. Your class should take into account the weight of the edges an...
codefeedback
You are tasked with implementing a simple computational graph framework in Python. A computational graph is a directed graph where the nodes represent operations and the edges represent data flow. Each node performs a specific operation on its input data and produces output data. Your task is to implement the `Node` cl...
codefeedback
You are tasked with implementing a proxy manager class in Python. The class should have a method to fetch new proxies if the number of available proxies falls below a certain threshold. The proxy manager should maintain a list of available proxies and have a low-water mark to determine when to fetch new proxies. Your...
codefeedback
You are tasked with implementing a gambling feature in a game. The game's code snippet below shows a part of the logic for processing the gambling result. The `response` object contains information about the gambling result, including the response code (`RespCode`) and the amount won in the gamble (`GambleWonAmount`). ...
codefeedback
You are given a Java code snippet that manipulates arrays, points, sparse arrays, and hash sets. Your task is to implement a method that processes the given data structures and performs specific operations on them. You are provided with the following data structures and methods: - `array3`: An array list of objects. -...
codefeedback
You are tasked with implementing a command-line interface for managing and running experiments. The provided code snippet demonstrates the setup of a command-line interface using the `argparse` module in Python. Your task is to extend this interface by adding functionality to handle the commands `run`, `trials`, and `v...
codefeedback
You are tasked with creating a Python class that simulates a simple library management system. The class should handle the administration of student records, allowing for the addition, retrieval, and search of student information. Create a class `StudentAdmin` that includes the following functionalities: - A method `a...
codefeedback
You are tasked with implementing a function to analyze a series of trust results and determine the overall trustworthiness of a system. The trust results are represented by an enum called `TrustResult`, which has three possible values: `.proceed`, `.unspecified`, and `.deny`. The function should take in an array of `Tr...
codefeedback
You are given a 2D terrain represented by a list of strings. Each string represents a row of the terrain, and each character in the string represents a position in that row. The characters can be either '.' (open space) or '#' (tree). You are also given a horizontal movement value `hor` and a vertical movement value `v...
codefeedback
You are tasked with creating a Python function that checks the version of the `numpy` library and installs a specific version if the current version is greater than or equal to 1.22. Your function should take the current version of `numpy` as input and return the command needed to install a version less than 1.22 if th...
codefeedback
You are tasked with implementing a decorator-based permission system for a web application. The application has a function `editCategory` that is responsible for editing a category. The function is decorated with three custom decorators: `@helpers.csrf_protect`, `@helpers.category_exists`, and `@helpers.check_permissio...
codefeedback
You are tasked with implementing a C++ template function that uses SFINAE (Substitution Failure Is Not An Error) to conditionally enable a specific specialization based on a template parameter. Your task is to complete the implementation of the `testme` function template, which should return 0 if the template parameter...
codefeedback
You are tasked with creating a program to analyze disassembled code. The disassembly result is represented by the `DisassemblyResult` struct, which contains information about functions and their corresponding blocks of instructions. You need to implement two functions: 1. `count_api_calls(disassembly_result: &mut Disa...
codefeedback
You are tasked with creating a Python script that processes command-line arguments for a reinforcement learning algorithm. The script should parse the provided arguments and use them to configure the algorithm's parameters. Your task is to implement the argument parsing and configuration logic based on the given code s...
codefeedback
You are tasked with implementing a queue data structure in JavaScript. A queue is a linear data structure that follows the First In First Out (FIFO) principle, where elements are added to the back and removed from the front. Your task is to create a JavaScript class `Queue` with the following functionalities: 1. `enqu...
codefeedback
You are tasked with implementing a simple command-line interface for a marbles game. The game is played by two players who take turns removing marbles from a pile. The pile initially contains a certain number of marbles, and players can choose to remove 1, 2, or 3 marbles from the pile on their turn. The player who rem...
codefeedback
You are tasked with creating a Python program to process and decode Automatic Identification System (AIS) messages from binary data. AIS messages are used for ship-to-ship, ship-to-shore, and shore-to-ship communication. The AIS messages are encoded in binary format and need to be decoded to extract relevant informatio...
codefeedback
You are tasked with implementing a task scheduler for a mobile application. The application has three specific lifecycle methods that need to be managed: `applicationWillResignActive`, `applicationDidEnterBackground`, and `applicationWillEnterForeground`. Each of these methods has specific tasks that need to be execute...
codefeedback
You are tasked with creating a Python program to manage and display information about different zones and their associated rates and terms. The program should allow for the administration of zones and provide filtering and pagination options for the displayed data. Your task is to implement a class-based solution that...
codefeedback
You are tasked with implementing a custom iterator class in Python. Your iterator class should have a method to return the next element in the iteration. Additionally, you need to implement a method to create an iterator object. Your task is to complete the implementation of the custom iterator class by adding the nec...
codefeedback
You are tasked with implementing a class method for an optimization algorithm. The method is responsible for performing a series of operations, including error handling, system setup, debugging, and iteration control. Your task is to complete the implementation of the method by filling in the missing code based on the ...
codefeedback
You are tasked with creating a Python script that acts as a wrapper around another script called `verify_order`. The purpose of the wrapper script is to write a stamp file upon successful execution of `verify_order`. The script should also allow for the specification of a developer directory path to Xcode. Your task i...
codefeedback
You are tasked with creating a Python package that provides model profile sections for a machine learning monitoring tool. The package should be structured in a way that allows for easy access to the model profile sections. Additionally, you need to handle the deprecation of an old import statement and provide a warnin...
codefeedback
You are tasked with implementing a TypeScript class that manages event subscriptions and triggers. The class should allow users to subscribe to events with callback functions and trigger those events with optional event data. The class should also handle unsubscribing from events. You are given the following TypeScrip...
codefeedback
You are given a Python function `process_data` that takes in a 3D NumPy array `x_in` and an integer `k` as input. The function performs some operations on `x_in` and returns a modified 2D NumPy array `result`. Your task is to understand the operations performed in the function and implement a similar function `process_...
codefeedback
You are tasked with implementing a simple event system in C#. The event system should allow objects to subscribe to and receive notifications when a specific event occurs. You are provided with a base class `EventPublisher` and a derived class `ValueEventPublisher`. The `EventPublisher` class contains a list of subscri...
codefeedback
You are tasked with implementing a function to serialize a list of image IDs and send the serialized data over a WebSocket connection. The provided code snippet is a part of a Rust function that attempts to achieve this. Your task is to complete the implementation of the `send_success` function by serializing the image...
codefeedback
You are tasked with implementing a Python class that interacts with a peripheral device using the Serial Peripheral Interface (SPI) protocol. The class, named `SPIDevice`, has a method `read_status_register` that reads a status register from the device. However, the method should raise an exception if the provided addr...
codefeedback