instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Python class that manages a library's book inventory. The class should allow for adding new books, removing existing books, and displaying the current inventory. Additionally, you need to implement a method that calculates the total value of the inventory based on the individual book pric... | codefeedback |
You are tasked with creating a class for synthesizing sound waves in a music application. The class should include properties for waveform, phase distortion, pitch bend, vibrato depth, and vibrato rate. Additionally, the class should have properties for attack duration, decay duration, sustain level, and release durati... | codefeedback |
You are tasked with implementing a program that simulates a simple banking system. The program should allow users to create accounts, deposit funds, withdraw funds, and check their balance. Each account should have a unique account number, and the program should support multiple accounts.
Your task is to implement the... | codefeedback |
You are tasked with implementing a class that performs validation on an Entity-Relationship (ER) diagram for a database. The ER diagram consists of entities, attributes, and relationships between entities. Your task is to implement the `ERDiagramValidator` class, which contains the following methods:
1. `clear()`: A m... | codefeedback |
You are tasked with implementing a Python program to read a file containing JSONL (JSON Lines) data and write a modified version of the data to a new file. The input file contains a list of JSON objects, each representing a data record, and the program should modify the data before writing it to the output file.
Your ... | codefeedback |
You are tasked with writing a script to automate the setup of a DNS deployment environment. The script should perform the following tasks:
1. Clone a Git repository from a specific URL to a local directory.
2. Check if two specific directories exist, and if not, print an error message and exit with a status code of 1.... | codefeedback |
You are tasked with creating a script to automate the installation of Nagios and its plugins on a Linux system. The script should download the specified versions of Nagios and Nagios plugins, compile and install them, and then configure the necessary settings for Nagios to run properly.
Your script should perform the ... | codefeedback |
You are tasked with implementing a data encoding algorithm that converts a string of characters into a binary representation. The algorithm uses a custom encoding scheme that involves converting characters into binary sequences and then combining them into a single binary string.
The custom encoding scheme works as fo... | codefeedback |
You are tasked with creating a Python class that manages a set of laboratory devices and their configurations. The class should have a method to generate configuration results for each device based on specific parameters. Your task is to implement the `LabManager` class and its method `generate_config_results`.
The `L... | codefeedback |
You are tasked with implementing a program that simulates a simple inventory management system for a small retail store. The program should allow users to add, remove, and display items in the inventory. Each item in the inventory has a unique identifier, a name, a quantity, and a price.
Your task is to implement the ... | codefeedback |
You are tasked with implementing a simplified version of a Generative Adversarial Network (GAN) in Python. A GAN consists of two neural networks, a generator and a discriminator, which are trained together to generate realistic data. The provided code snippet includes methods for moving the GAN and its components betwe... | codefeedback |
You are tasked with creating a Docker container for a Node.js application. The entrypoint for the container is defined in the `entrypoint.sh` script. Your goal is to write a Dockerfile that sets up the Node.js environment and uses the `entrypoint.sh` script as the entrypoint for the container.
Your Dockerfile should p... | codefeedback |
You are tasked with implementing a function that performs seamless cloning of an image. Seamless cloning is a technique used in image processing to blend the content from a source image into a target image in a seamless and natural manner. The function should take the source image, target image, and a mask as input, an... | codefeedback |
You are tasked with implementing a function that applies a given state to a view. The view is represented as a 2D array of integers, where each integer represents the height of a particular point on the view. The state is represented as a 2D array of integers of the same dimensions as the view. Each integer in the stat... | codefeedback |
You are tasked with creating a Python plugin system for a task management application. The application should be able to load task plugins dynamically and execute them based on certain conditions. Each task plugin will have access to a set of predefined constants and will be required to implement a specific interface.
... | codefeedback |
You are tasked with creating a movie list application that allows users to click on a movie item to view its details. The code snippet provided is from the `onClick` method of a movie item click listener in an Android application. The `transitionName` is generated based on the position of the movie item in the adapter,... | codefeedback |
You are working on a messaging application that communicates with a server to retrieve user information. The server uses encryption and decryption methods to secure the data transmission. Your task is to implement a Python class that handles the encryption and decryption of data sent to and received from the server.
Y... | codefeedback |
You are tasked with creating a program that processes HTML code to extract information about different packages offered by a company. Each package is represented by a `div` element with the class `package` followed by a specific color class (e.g., `purple-package`). The package name is enclosed within an `h3` element w... | codefeedback |
You are given a Java code snippet that manipulates a doubly linked list. Your task is to implement a method to insert a new node after a specified node in the list.
The Node class is defined as follows:
```java
class Node {
Node prevNR;
Node nextNR;
boolean isInNR;
int sizeNR;
// Other methods... | codefeedback |
You are tasked with implementing a reference counting mechanism for a custom string class. The custom string class has a method `refs()` that returns the current reference count of the string object. The reference count represents the number of references to the string object. When a new reference to the string object ... | codefeedback |
You are tasked with implementing a logging system for a Flask web application. The application should log all INFO level messages to a file named "flaskapi_info.log" located at "/var/log/uwsgi/". Additionally, the application should handle 404 errors by returning a JSON response with a 404 status code and a correspondi... | codefeedback |
You are tasked with implementing a subscription management system for handling events in a multi-tenant application. The system should allow adding, removing, and retrieving event handlers for specific events and virtual hosts. You are provided with a partial code snippet from the subscription management system, and yo... | codefeedback |
You are tasked with creating a Python class to manage a stock portfolio. The class should have methods to track the buying and selling of stocks, calculate the profit from the transactions, and determine the profit rate. Your task is to implement the `StockPortfolio` class with the following methods:
1. `__init__(self... | codefeedback |
You are tasked with implementing a function `unique_values(pairs)` that takes a list of pairs as input and returns a list of unique values from the pairs. Each pair is represented as a tuple with two elements, where the first element is the key and the second element is the value. If multiple pairs have the same value,... | codefeedback |
You are tasked with creating a program to help players of a video game find hidden collectibles scattered throughout the game world. The game world is represented as a 3D coordinate system, and each collectible is located at a specific coordinate. Additionally, each collectible has a description of its location to help... | codefeedback |
You are given a 2D array `a` of size `n x m` containing integers. Your task is to find the maximum sum of a subarray within the 2D array. A subarray is defined as a contiguous block of elements within the 2D array. The maximum sum of a subarray is the largest possible sum that can be obtained by summing the elements of... | codefeedback |
You are tasked with implementing a custom data structure in Swift that mimics the behavior of a stack, but with an added feature to efficiently retrieve the minimum element in the stack at any given time. You need to create a class `MinStack` with the following methods:
1. `push(_ val: Int)`: Add an element to the sta... | codefeedback |
You are tasked with implementing a mission objective system for a simulation game. The objective system is represented by the `MissionObjectiveData` class, which contains various tunable parameters and constants. Your goal is to create a method within this class that determines the state of a mission objective based on... | codefeedback |
You are tasked with creating a Django model and admin interface for managing recipes and their ingredients. Your task is to implement the necessary models and admin configurations to achieve this functionality.
You are provided with the following code snippet as a starting point:
```python
User = get_user_model()
cl... | codefeedback |
You are tasked with implementing a B-tree leaf node iterator in Java. A B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. The leaf node iterator will be used to iterate through the leaf nodes of the B-tree dat... | codefeedback |
You are tasked with creating a custom data loader for a machine learning project using PyTorch. The data consists of images and corresponding labels, and you need to implement a custom dataset class and a data loader to efficiently load and preprocess the data for training.
Your custom dataset class should be named `C... | codefeedback |
You are tasked with creating a function to generate a unique payment ID for a payment system. The payment ID should consist of a specific format: a prefix character followed by a two-digit number. The function should retrieve the highest existing payment ID from the database, increment it by 1, and return the new payme... | codefeedback |
You are working on a quantum computing simulation project and need to implement a function to process a sequence of quantum gates. Quantum gates are represented as strings, and the sequence of gates is stored as a list of lists. Each inner list represents a single gate sequence, and the outer list contains multiple gat... | codefeedback |
You are working on a machine learning project and need to implement a custom loss function for a neural network. The loss function is defined as the mean squared error (MSE) between the predicted values and the ground truth, with an additional regularization term. The regularization term penalizes the model for large g... | codefeedback |
You are given an integer `n` followed by `n` lines of space-separated integers. Each line contains `n` integers representing a square matrix `arr` of size `n x n`. Your task is to calculate and print an array `ans` of size `n` such that `ans[i]` is equal to the square root of the product of the elements in the `i`-th r... | codefeedback |
You are tasked with implementing a function that optimizes a city tour algorithm. The algorithm takes an array of indexes representing the city tour and the time taken to complete the algorithm. The goal is to modify the algorithm to minimize the time taken to complete the tour.
You are given the following code snippe... | codefeedback |
You are given a set of points in a 3D space, represented as (x, y, z) coordinates. Your task is to implement a function that finds the maximum error point and then adds a new point within a hypercube around the maximum error point. The size of the hypercube should be equal to the distance to the nearest point from the ... | codefeedback |
You are tasked with implementing a custom pausable operator for a reactive programming framework. The pausable operator should allow pausing and resuming a sequence of values based on certain conditions.
You are given a `pauserSubject` that emits `true` to pause the sequence and `false` to resume it. Additionally, you... | codefeedback |
You are tasked with creating a Python program that utilizes the `pyttsx3` library to convert a given text into speech. The program should take user input for the text to be converted and then use the `pyttsx3` library to speak out the input text. Additionally, the program should allow the user to specify the speech rat... | codefeedback |
You are tasked with creating a program that simulates a simple build system. The build system takes a list of tasks and executes them concurrently using a specified number of threads. Each task can depend on other tasks, and the build system must ensure that tasks are executed in the correct order to satisfy their depe... | codefeedback |
You are given a list of integers representing the scores of a game. Your task is to implement a function `highestScore(scores)` that returns the highest score achieved in the game. If the list is empty, the function should return 0.
Example:
For the list of scores: [75, 80, 95, 60, 85], the function should return 95. | codefeedback |
You are tasked with implementing a function that calculates the total number of GitHub stars for a given user's repositories. You are provided with a code snippet that includes a function to handle key presses in a React application.
Your task is to create a function `calculateTotalStars` that takes a GitHub username ... | codefeedback |
You are tasked with creating a Python function that interacts with a remote API to upload a file preview. The function should take the host URL, API key, and the file to be uploaded as input parameters. The provided code snippet serves as a starting point for your task.
Your function should perform the following steps... | codefeedback |
You are tasked with implementing a simple memory management system for a game simulation. The game has various entities such as system, rooms, spawns, flags, and creeps, and each entity has its own memory storage. Your goal is to create a memory management system that initializes memory storage for these entities and c... | codefeedback |
You are tasked with implementing a custom documentation system for a programming language. The system should support the `@inheritdoc` tag, which allows a method or function to inherit documentation from another method or function.
The `@inheritdoc` tag should be used in the documentation of a method or function to in... | codefeedback |
You are given a list of daily temperatures, where temperatures are represented as an array of integers. Your task is to create a program that, for each day in the input, finds the next day where the temperature will be higher. If there is no such day, the output should be 0 for that day.
For example, given the input a... | codefeedback |
You are tasked with creating a program that processes files in a given directory and its subdirectories. The program should identify and list all the web font files present in the directory based on a specific regular expression pattern. Additionally, the program should have the option to exclude font files found withi... | codefeedback |
You are tasked with creating a Python program that processes Java and C++ code files. The program should include a class for parsing Java code using the JavaParser library and a method for cleaning C++ code files. Your task is to complete the implementation of the Python program by writing the missing parts of the code... | codefeedback |
You are tasked with creating a script to process and filter data from multiple trials using a set of parameters. The script should read in a set of trials, apply a specific key, and filter out any lines containing the strings "VAST" or "Both". The filtered results should be saved to separate files for each trial.
You ... | codefeedback |
You are tasked with creating a simple physics simulation program for a game. The program should simulate the behavior of falling objects with different shapes and materials. Your task is to implement a class hierarchy for different types of falling objects and their corresponding physics behaviors.
You are provided wi... | codefeedback |
You are tasked with creating a Python function that calculates the total number of stars for a given GitHub repository. The function should take the repository name as input and return the total number of stars for that repository. You can assume that the repository name is a string and that the GitHub API can be used ... | codefeedback |
You are tasked with creating a function to extract color information from a given HTML string. The function should parse the HTML string and return a list of tuples, where each tuple contains the color code and the content enclosed within the corresponding font tag.
You are provided with a partial code snippet that in... | codefeedback |
You are tasked with implementing a function to analyze video frames and track the movement of objects within the frames. The given code snippet is part of a larger program that processes video frames in iterations and records the movement of objects using centroid area history.
Your task is to implement the `get_centr... | codefeedback |
You are tasked with creating a Python program to manage a library's book inventory using object-oriented programming. The program should allow the addition, removal, and display of books in the library's collection. Additionally, it should provide the functionality to register and manage library members' profiles.
You... | codefeedback |
You are tasked with implementing a generic function that takes a value of type `S` and converts it into a `String`. The function signature is as follows:
```rust
fn convert_to_string<S: Into<String>>(value: S) -> String {
// Your implementation here
}
```
Your task is to implement the `convert_to_string` function... | codefeedback |
You are tasked with implementing a value visitor/mapper in Java to process entries in a data structure. The data structure contains various entries, and the visitor/mapper is responsible for handling each entry based on its value. However, there is a need for a unique symbol to represent an unhandled entry. Your task i... | codefeedback |
You are tasked with implementing the game of life, a cellular automaton devised by the British mathematician John Horton Conway. The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. The game is played on an infinite two-dimensional grid of square cel... | codefeedback |
You are tasked with implementing a Python function that generates training examples for a board game. The function takes in several parameters and returns a list of examples in a specific format.
The function signature is as follows:
```python
def generate_training_examples(episodeStep: int, tempThresholdStep: int) ->... | codefeedback |
You are tasked with creating a Python program that fetches data from a given URL and processes it to extract specific information. The program should utilize the `urllib` module to make a GET request to the URL and then parse the retrieved data to extract relevant details. Specifically, you need to extract the number o... | codefeedback |
You are tasked with creating a custom derive macro for a struct builder in Rust. The macro should generate a builder pattern for the given struct, allowing for fluent and ergonomic construction of instances of the struct with optional fields.
Your task is to implement the custom derive macro `IBuilder` that generates ... | codefeedback |
You are working on a chemical database management system that stores thermodynamic data for various chemical compounds. Your task is to write a Python function that processes and inserts new thermodynamic data into the database. The function should take the following inputs:
- `thermo`: An object containing thermodynam... | codefeedback |
You are tasked with implementing a function to process a list of payment transactions in Python. Each transaction is represented as a dictionary with the following keys: 'payer', 'iban', 'bic', 'id', and 'amount'. The 'payer' key holds the name of the payer in the format "Last, First Last". The 'iban' key holds the Int... | codefeedback |
You are tasked with implementing a JavaScript function that calculates the distance between a point and a plane in 3D space. The plane is defined by its normal vector and a point it passes through. The function should take the coordinates of the point, the normal vector of the plane, and a point on the plane as input, ... | codefeedback |
You are tasked with creating a neural network model using Keras for a specific problem. The model architecture involves various layers and configurations. Your goal is to implement the model architecture as described below.
You are given the following requirements for the neural network model:
1. The input layer shoul... | codefeedback |
You are tasked with implementing a Python function that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player's goal is to reach the end of the grid while collecting as many treasures as possible.
You are provided ... | codefeedback |
You are tasked with creating a Python function that generates a similarity map for visualizing the atomic contributions to the similarity between two molecules. The function should take as input a string in the SDF (Structure Data File) format containing exactly two molecules and produce a similarity map as output.
Th... | codefeedback |
You are tasked with implementing a Swift function that processes a collection of messages and extracts specific information from them. Each message is represented as an instance of a custom `Message` class, which contains various properties and methods for accessing its content. The function should filter the messages ... | codefeedback |
You are tasked with implementing a class that manages the reconnection attempts for a network service. The class should have an initializer that allows setting a multiplier for the reconnection time. Additionally, it should provide a method to calculate the time interval to wait before the next reconnection attempt bas... | codefeedback |
You are tasked with implementing a 2D diffusion solver for a scientific simulation. The solver class, `SolveDiffusion2D`, needs to be initialized with physical parameters and an initial condition function. Your goal is to write the necessary code to fulfill these requirements.
You are provided with a code snippet that... | codefeedback |
You are tasked with creating a function that parses HTML code to extract the URLs and their corresponding labels from a given sidebar menu. The HTML code for the sidebar menu is provided as a string. Each menu item is represented by a `<div>` element with the class "sidebar-item", containing an `<a>` element with the U... | codefeedback |
You are tasked with implementing a simple event handling system for a graphical application. The application uses a library that provides a `Session` struct for managing the application's state and a `connect` object for handling events. The `connect` object has an `event` method that asynchronously waits for events an... | codefeedback |
You are tasked with creating a Python function that parses a given HTML code snippet and extracts the URLs and corresponding social media platform names from the embedded image tags. The function should return a dictionary containing the platform names as keys and their respective URLs as values.
The HTML code snippet... | codefeedback |
You are tasked with implementing a Python function that approximates the square root of a given number using the Python values for perfect squares and the Chakravala method for non-perfect squares. The function should take two arguments: `n` (an integer representing the number for which the square root is to be approxi... | codefeedback |
You are tasked with creating a Python class that interacts with a CCG (Combinatory Categorial Grammar) parser service and performs various linguistic processing tasks. The CCG parser service is accessed through gRPC (Google Remote Procedure Call) and is initialized in the `setUp` method of the `PossessiveTest` class. Y... | codefeedback |
You are tasked with implementing a custom hit collector for a search operation in a document retrieval system. The hit collector will use a bit array to store the matching document IDs.
You are given a code snippet that initializes a bit array and uses an `IndexSearcher` to search for documents matching a given query.... | codefeedback |
You are tasked with creating a custom regular expression matcher in Bash. The custom matcher should be able to validate a specific pattern within a given string. The custom matcher is defined in the "support/custom_matcher.sh" file and is imported by the "spec_helper.sh" file.
Your task is to implement the custom regu... | codefeedback |
You are tasked with implementing a type trait to determine if a given type is streamable to a `std::stringstream`. Streamability in this context refers to the ability to insert the type into a `std::stringstream` using the `<<` operator. Your task is to create a type trait `is_streamable` that, when provided with a typ... | codefeedback |
You are tasked with creating a Python function that processes a given code snippet to extract specific information about the user interface (UI) window and its components. The code snippet provided is a part of a larger script for creating a UI window using the Maya Python API (PyMEL). Your task is to write a function ... | codefeedback |
You are tasked with creating a program that processes a list of test targets and their dependencies. Each test target is represented by a name and a list of its dependencies. Your goal is to write a function that takes in this list of test targets and their dependencies and organizes them into a hierarchical structure.... | codefeedback |
You are tasked with creating a simple Desmos wallet generator. Desmos is a blockchain-based social network that utilizes a unique address format for its wallets. The address format is represented by a specific regular expression and is generated from a given mnemonic phrase.
Your task is to implement a function that g... | codefeedback |
You are tasked with creating a Python program that reads an Avro schema from a file, validates the schema, and then prints the fields and their corresponding data types. Avro is a data serialization system that provides rich data structures and a compact, fast, binary data format. The Avro schema is defined using JSON ... | codefeedback |
You are tasked with designing a database schema for a soccer (football) management system. The system needs to store information about soccer matches, including details about goals, yellow cards, and red cards.
Your task is to create a database schema using the provided code snippet as a reference. The schema should i... | codefeedback |
You are tasked with creating a Python program that simulates a simplified file and project management system. Your program should parse input data, create a project, and perform specific operations on the project files.
You are given a code snippet that includes a function `parse_and_create_project` which takes two pa... | codefeedback |
You are tasked with implementing a custom control builder for a mobile web application. The control builder is responsible for parsing and processing the markup of mobile controls defined in the application. The provided code snippet is a partial implementation of the `MobileControlBuilder` class, which inherits from `... | codefeedback |
You are working on a crime analysis system that utilizes a machine learning model to predict crime occurrences in a city. The model has been trained and is ready for deployment. The code snippet provided is a part of the system's workflow. The `no.run(model)` function is used to run the trained model, and the `model.cr... | codefeedback |
You are tasked with implementing a SystemSleepPreventionToken class in Swift. The SystemSleepPreventionToken class is designed to prevent the system from entering sleep mode by acquiring a token and releasing it when it is no longer needed. The class should provide a mechanism to prevent the system from sleeping and al... | codefeedback |
You are tasked with implementing a custom annotation processor for a Java application. The annotation, `@FragmentScope`, is used to mark classes that should be scoped to a particular fragment in the application. Your goal is to create an annotation processor that processes classes annotated with `@FragmentScope` and ge... | codefeedback |
You are tasked with implementing a function that takes in a SQL query and a set of values, and returns a formatted SQL query string with the provided values inserted into the query. The function should handle different types of SQL queries and values, ensuring that the resulting SQL query is properly formatted and safe... | codefeedback |
You are tasked with implementing a dependency ordering utility for a list of items. Each item has a key and an optional array of dependent keys. The goal is to order the items in such a way that no item comes before its dependencies. If there are multiple valid orderings, the utility should return any one of them. You ... | codefeedback |
You are tasked with creating a script to automate the setup of multipath devices on a Linux system. Multipath allows for the use of multiple physical paths between a server and storage to provide fault tolerance and performance enhancement. The script should detect the available multipath devices and set them up for us... | codefeedback |
You are tasked with implementing a function to decode a string containing Unicode escape sequences into their corresponding characters. Unicode escape sequences are represented as `\u` followed by a four-digit hexadecimal number, which represents the Unicode code point of the character.
You need to write a function `d... | codefeedback |
You are tasked with creating a Python function that processes a list of file paths and their associated GitHub stars, and returns a sorted list of file paths based on the range of GitHub stars provided.
You are given a list of tuples, where each tuple contains a file path and the range of GitHub stars it has. The ran... | codefeedback |
You are tasked with implementing a generic data structure in Rust that can store elements of any type. The data structure should support adding elements, removing elements, and checking if it contains a specific element. You need to implement the `GenericDataStructure` module with the following methods:
1. `new()`: Cre... | codefeedback |
You are tasked with implementing a C++ concept checker for ranges. A concept in C++ is a set of requirements for a type to be used in a particular way. In this problem, you are given a code snippet that uses the `models_not` macro to check if a given range does not model the `SizedRange` and `OutputRange` concepts. You... | codefeedback |
You are tasked with implementing a C++ class to manage properties of objects within a specific namespace, class, and instance. The class, named `properties`, should have the ability to store and manipulate properties associated with the objects.
The `properties` class should have the following functionalities:
1. A de... | codefeedback |
You are tasked with creating a program to manage a database of options for advertisements. Each advertisement option has a set of attributes that need to be stored in the database. Your task is to create a class or function that can take in the attributes of an advertisement option and store them in the database using ... | codefeedback |
You are tasked with implementing a function that generates a directed graph in the DOT language format based on a given set of dependencies between components. The DOT language is commonly used to describe graphs and is often visualized using tools like Graphviz.
You are given a Python code snippet that initializes a ... | codefeedback |
You are tasked with implementing a data caching system for a learning platform. The platform has a `LearnerCreator` class responsible for creating and managing learner data. The `LearnerCreator` class relies on a data cache, represented by the `ILearnerCreatorDataCache` interface, to store and retrieve learner data eff... | codefeedback |
You are working on a text editor application and need to implement a feature for handling key button presses. The application uses the `nk` and `kb` libraries for handling user interface and keyboard input, respectively. The provided code snippet shows part of the implementation for handling key button presses in the a... | codefeedback |
You are tasked with implementing a function to compute the centroids of clusters based on given data points and their assigned clusters. The function signature is as follows:
```cpp
template<typename DATA_t = double, typename INDEX_t = int, typename CLUSTER_t = int, class V>
void compute_centroids(int ndim, INDEX_t no... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.