instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Java program to build document relations based on a specific type of array key. The program should extend a given class and override a method to build the relation name. The relation name should be constructed based on the type property of the parent and child nodes.
Your task is to comp... | codefeedback |
You are working on a computational chemistry software project and need to implement a class for handling electronic structure calculations. The class should include methods for calculating the number of alpha and beta electrons, as well as for building a file in the formatted checkpoint (fchk) format.
You are given a ... | codefeedback |
You are tasked with creating a layout manager for a custom alert view in an iOS application. The alert view should be positioned within a parent view using Auto Layout constraints. The alert view has properties for its center, leading, and trailing spaces relative to the parent view. Your task is to implement a method ... | codefeedback |
You are working on a project to develop a deep learning model for identifying planes in aerial images. As part of this project, you need to create a data loader for the training dataset and perform data augmentation using the `albumentations` library. Additionally, you need to implement a specific test-time augmentatio... | codefeedback |
You are tasked with implementing a class that utilizes the `IAsyncRunnable` interface to execute asynchronous tasks. The `IAsyncRunnable` interface contains a single method `Run` that returns a `Task`. Your task is to create a class `AsyncTaskRunner` that can execute an array of `IAsyncRunnable` tasks concurrently and ... | codefeedback |
You are tasked with implementing a simple reactive system for a user management application. The provided code snippet shows a class with three properties marked as reactive using an attribute. The `Reactive` attribute indicates that the properties should trigger events when their values change. Your task is to create ... | codefeedback |
You are tasked with implementing a Python function that simulates a simplified version of a command-line interface for running an agent in a virtual environment. The function should handle the configuration settings and environment preparation based on the provided input.
You are given the following code snippet as a ... | codefeedback |
You are tasked with creating a script to automate the deployment of Kubernetes clusters using the `kind` tool. The script should take user input for the Kubernetes version and registry, and then generate a configuration file for `kind` to create the cluster. The script should also handle the scaling of a Kubernetes dep... | codefeedback |
You are tasked with creating a server-side program for a step counting device. The server listens for incoming connections, receives step count data from clients, and prints the received step count. The server's IP address and port are dynamically obtained and displayed upon initialization.
Your task is to implement t... | codefeedback |
You are given an integer `x`. Write a function to determine if `x` is a palindrome. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not.
You should not convert the integer to a string to solve the problem. Additionally, consider the case of negative ... | codefeedback |
You are given a snippet of code that attempts to change the current directory to its parent directory. However, the code is incomplete and contains a syntax error. Your task is to complete the code by writing a function that correctly changes the current directory to its parent directory.
You are to implement the func... | codefeedback |
You are tasked with implementing a Python function that calculates the frequency of each word in a given text and returns the result as a dictionary. The function should ignore case sensitivity and consider only alphanumeric characters as part of a word. Punctuation and special characters should be disregarded.
Functi... | codefeedback |
You are tasked with implementing a function that calculates the total number of occurrences of a given word in a list of strings. The function should be case-insensitive and should count partial matches as well. For example, if the word is "cat", it should count occurrences of "cat", "cats", "category", etc. The functi... | codefeedback |
You are tasked with creating a Python function that manages socket connections based on a given configuration. The function takes in three parameters: `setting` (a dictionary containing connection details), `binding` (a boolean indicating whether to bind the connections), and `logger` (a logging.Logger object for loggi... | codefeedback |
You are tasked with designing a system to automate the process of fetching movie data from various sources and inserting it into a centralized database. The system will involve multiple processes, each responsible for retrieving specific information about movies from different platforms and then storing it in the datab... | codefeedback |
You are tasked with implementing a function to validate and format a phone number. The phone number is represented as a 10-digit string, and the formatting should follow the pattern "xxx-xxx-xxxx". The provided code snippet gives a starting point for the formatting process, but it is incomplete. Your task is to complet... | codefeedback |
You are tasked with creating a Python function that interacts with a PostgreSQL database using the `psycopg2` library. The function should retrieve data from a specific table and return it as a list of dictionaries. The table contains information about employees, including their ID, name, and department. The function s... | codefeedback |
You are tasked with creating a Python class that simulates a home security system. The class should have the ability to change its state based on different inputs and should be able to return the current state of the system.
Your task is to implement the `SecuritySystem` class with the following specifications:
- The ... | codefeedback |
You are tasked with creating a machine learning model for a text classification problem. The given code snippet initializes some variables and imports necessary libraries for the task. Your goal is to complete the model creation process by implementing the missing code.
The code snippet provided sets a seed for random... | codefeedback |
You are tasked with creating a simple onboarding screen for a mobile app using SwiftUI. The onboarding screen will display a series of pages, each containing an image and a description. Your task is to create a SwiftUI view that can display these onboarding pages and allow the user to swipe through them.
You are given... | codefeedback |
You are tasked with implementing a simple physics simulation for entities in a 2D space. The entities have positions, speeds, and gravitational forces acting on them. Your goal is to calculate the final positions of the entities after a given time interval.
You are given the following code snippet as a starting point:... | codefeedback |
You are working on a web application that displays known issues and bug categories. The code snippet provided is from a Django view function that retrieves all known issues and bug categories from the database and passes them to the 'index.html' template for rendering. Your task is to implement a function that processe... | codefeedback |
You are tasked with implementing a Python class that represents a measurement unit converter. The class should be able to convert between different units of measurement for a specific quantity. The supported units of measurement are 'poles', 'lines', 'rakes', and 'radians'. The conversion rates are as follows:
- 1 pole... | codefeedback |
You are tasked with implementing a class to manage a homepage component in a mobile application. The component can scroll in a specified direction and display cells in a specified flow direction. Additionally, the component's content size is defined relative to a 750px width screen. Your task is to create a class that ... | codefeedback |
You are tasked with implementing a function that calculates the weighted sum of logits based on input masks and replace masks. The function takes in three parameters: `true_features_dict`, `fake_model_dict`, and `none_replace_mask`. The `true_features_dict` contains a key 'input_mask' which represents the input mask as... | codefeedback |
You are tasked with creating a custom CSS-in-JS component for a pop-over element in a web application. The pop-over should have a dynamic background color based on the theme, a minimum width of 10rem, a minimum height of 2rem, and a maximum width of 40rem. Additionally, the pop-over should have a border radius of 0.25r... | codefeedback |
You are working on a natural language processing (NLP) project and need to create a labeling function that can process text data and assign labels based on certain criteria. Your task is to implement a Python class that defines an NLP labeling function using the provided code snippet as a reference.
Your class should ... | codefeedback |
You are working on a Python program that interacts with a MySQL database using the `mysql-connector-python` library. Your task is to write a function that executes SQL queries and returns the results based on the given requirements.
You are provided with a partially completed Python function that uses the `mysql-conne... | codefeedback |
You are tasked with designing a notification system for a messaging app. The app uses Firebase for real-time data synchronization and employs a refresh mechanism to update the user interface. Your goal is to implement a notification manager that handles the cleanup of Firebase observers and triggers UI refresh notifica... | codefeedback |
You are tasked with implementing a C++ class that manages a collection of database rows and their associated content identifiers. The class should provide methods for adding rows and content identifiers, as well as for retrieving specific rows and identifiers.
You are given the following code snippet as a starting poi... | codefeedback |
You are tasked with implementing a custom tab bar component for a mobile application. The provided code snippet is a part of the custom tab bar's initialization process. The `MagiTabBar` class is being initialized with a target object and a tag value. It sets up two touch-up-inside event targets for the tab bar, both p... | codefeedback |
You are tasked with creating a Python function that simulates a simplified version of a stock trading system. The function should take in a list of stock prices over a period of time and determine the maximum profit that can be achieved by making a single buy and sell transaction. The buy must occur before the sell.
C... | codefeedback |
You are tasked with implementing a 2D game character movement system. The character should smoothly accelerate towards a target position based on the time elapsed and the maximum speed allowed. The code snippet provided contains relevant calculations for this movement system.
Your task is to write a function that take... | codefeedback |
You are tasked with implementing a feature for a calendar view in a mobile app. The app uses the JTAppleCalendarView library, and you need to handle the display of cells for specific dates. The `HistoryViewController` class has been extended to conform to the `JTAppleCalendarViewDelegate` protocol. Within this extensio... | codefeedback |
You are tasked with implementing a custom data structure in Swift that provides a way to manage and display rows of data in a table view. The data structure should support adding, removing, and accessing rows, as well as notifying observers of any changes to the data.
Your task is to create a `RowsProvider` protocol a... | codefeedback |
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The game should allow a user to input their choice (rock, paper, or scissors) and then randomly generate a computer's choice. The program should then determine the winner based on the standard rules of rock-paper-scissors.
Your... | codefeedback |
You are working on a home automation system that utilizes the KNX (Konnex) protocol for communication between devices. The system includes various components such as gateways, routers, and interfaces for managing the KNX network. Your task is to implement a Python class that represents a KNXIPInterface for establishing... | codefeedback |
You are tasked with implementing a database upgrader for MySql databases using the provided code snippet as a reference. The `MySqlDatabase` method is used to create an upgrader for MySql databases, and it takes an `IConnectionManager` as a parameter. Your task is to create a class that implements the `IConnectionManag... | codefeedback |
You are given a 2D matrix and are required to design a data structure that supports the following two operations:
1. `NumMatrix(vector<vector<int>> matrix)`: Constructor to initialize the data structure with the given matrix.
2. `int sumRegion(int row1, int col1, int row2, int col2)`: Method to return the sum of the el... | codefeedback |
You are tasked with creating a program that simulates a simplified version of a file searching tool similar to `fzf` in a Unix-like environment. The program should take a list of file names as input and allow the user to search for files using a fuzzy search algorithm. The fuzzy search algorithm should match the input ... | codefeedback |
You are tasked with implementing a function to find the root of a given mathematical function using the Newton-Raphson method. The Newton-Raphson method is an iterative technique for finding the roots of a real-valued function. It requires an initial guess and refines it successively to approach the root of the functio... | codefeedback |
You are tasked with creating a custom MXNet operator for a 2D matrix multiplication (gemm) and integrating it into an MXNet model. Your custom operator should perform the matrix multiplication operation on two input matrices and return the result. The goal is to understand the process of creating and integrating custom... | codefeedback |
You are working on a machine learning project and need to implement a quantization process for a neural network model. Quantization is a technique used to reduce the precision of the weights and activations of a model, which can lead to reduced memory and computational requirements. In this problem, you are tasked with... | codefeedback |
You are tasked with implementing an AI player for a game using a decision tree model. The AI player is provided with a pre-trained decision tree model stored in a file named "decisionTree" using Python's pickle module. The AI player is also given a time limit of 3 seconds for making a move and has the option to enable ... | codefeedback |
You are tasked with implementing a simplified version of a thread-safe message queue in Java. The message queue should support the following operations:
1. `enqueue(message)`: Add a message to the queue.
2. `dequeue()`: Remove and return the message at the front of the queue. If the queue is empty, return null.
3. `isE... | codefeedback |
You are tasked with implementing a language detection and translation system. The system should be able to detect the language of a given text and translate it to a specified target language. You are provided with a code snippet that attempts to detect the language of the input text and initializes a translator if the ... | codefeedback |
You are tasked with creating a function that processes data and returns a JSON response. The function should take an array of data as input and return a JSON response with specific structure and content. The response should include a status, message, errors (if any), and the processed data as the result.
Write a funct... | codefeedback |
You are tasked with implementing a method to filter and manipulate a list of menu items based on certain conditions. The menu items are represented by the `Menu` class, which has attributes such as `MENU_NAME`, `MENU_ID`, `NoCheck`, and `Target`. The method should take into account the user's role type and user ID to d... | codefeedback |
You are tasked with implementing a C++ template class that determines the base type of a given constant integer. The template class should be able to identify whether the constant integer is of type `int`, `long`, `long long`, or any other integral type. Your task is to complete the implementation of the `ConstIntegerB... | codefeedback |
You are tasked with creating a program to parse and extract specific information from a given JSON-like data structure. The data structure contains key-value pairs, where the keys represent different types of information and the values are the corresponding data. Your task is to extract and format the email address fro... | codefeedback |
You are working on a social media analytics platform that requires access to Twitter's API for data retrieval. To access the API, you need to use OAuth 1.0a authentication, which involves using consumer keys and secrets, as well as access tokens and secrets. Your task is to write a Python function that takes in these k... | codefeedback |
You are tasked with creating a Rust macro that generates code based on the presence of certain features. The macro should conditionally include or exclude modules based on the enabled features.
Your task is to implement a macro called `conditional_modules` that takes in a list of features and modules, and generates co... | codefeedback |
You are tasked with implementing a function that converts a Blackbird operation into an instruction. Blackbird is a quantum programming language, and the function should take a mapping of Blackbird operation names to corresponding instruction classes and a Blackbird operation dictionary as input. The function should th... | codefeedback |
You are tasked with creating a Python program that reads a JSON file containing information about a collection of books and performs various operations on this data. The JSON file contains an array of objects, each representing a book with attributes such as title, author, genre, and publication year. Your program shou... | codefeedback |
You are tasked with implementing a program to process a file containing records and sub-records. Each record may contain multiple sub-records, and the program needs to read and process these sub-records based on certain conditions.
Your task is to write a function `processRecords` that takes in a file path as input an... | codefeedback |
You are tasked with implementing a simple stack data structure using a linked list. The stack should support the following operations: push, pop, and peek. Additionally, you need to implement a function that checks if the parentheses in a given string are balanced using the stack data structure.
Your task is to implem... | codefeedback |
You are tasked with implementing a thread-safe lock management system in C++. The given code snippet is a function `SystemGetThreadLockState` that is intended to return a pointer to the thread-local `ThreadLockState` object. The `ThreadLockState` object is used to manage the lock state for a particular thread. Your tas... | codefeedback |
You are tasked with creating a Python GUI application using the tkinter library. Your application should allow the user to input a file extension and change the extension of all files in a specified directory to the input extension.
You need to implement a function `change_file_extension(directory_path, new_extension)... | codefeedback |
You are given a set of items, each with a weight, and a target sum. Your task is to determine whether it is possible to select a subset of the items such that the sum of their weights equals the target sum. You need to implement a function or method that takes the weights of the items and the target sum as input and re... | codefeedback |
You are working on a healthcare management system that includes a scheduling module for appointments. The system uses Angular for the front-end and communicates with a backend API to handle appointment-related operations. You are tasked with implementing a feature that involves patching appointment data and adding codi... | codefeedback |
You are tasked with implementing a custom gesture handler for a mobile application development framework called Droar. The DroarGestureHandler.swift file contains the initial structure for the gesture handler. Your goal is to complete the implementation by adding specific gesture handling functionality.
The Droar fram... | codefeedback |
You are tasked with implementing a simple server application that can handle incoming requests and respond accordingly. The server application should be able to start and listen for incoming connections on a specified port. Once a connection is established, the server should be able to process the incoming request and ... | codefeedback |
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score, excluding the highest and lowest scores.
Write a function `calculate_average_score(scores: List[int]) -> float` that takes in a list of integers `scores` and returns the average score... | codefeedback |
You are tasked with implementing a custom dependency injection pipeline for a web application. The application uses the ASP.NET Core framework and OpenAPI (Swagger) to document and interact with its RESTful APIs. The given code snippet is a part of the configuration for the dependency injection pipeline.
Your task is ... | codefeedback |
You are tasked with implementing a Python function that processes a JSON object and returns a list of all the keys that have a boolean value of `True`. The JSON object may contain nested objects and arrays, and the function should consider all levels of nesting.
The function signature is:
```python
def find_true_keys(... | codefeedback |
You are given a code snippet that reads text from a file, processes it, and stores the result in an array. Your task is to understand the code and identify the specific processing steps applied to the input text.
Your task is to write a function that replicates the processing logic described in the code snippet. The f... | codefeedback |
You are tasked with creating a Python function that interacts with the eBay API to retrieve information about items based on a given search query. Your function should take in the search query and the maximum number of items to retrieve as input and return a list of dictionaries, each containing information about a spe... | codefeedback |
You are tasked with creating a Python class that simulates a simple signal processing flow using GNU Radio. Your task is to complete the implementation of the `SignalProcessor` class by adding the missing method `process_signal`. The `process_signal` method should take a list of input samples and return the processed o... | codefeedback |
You are tasked with creating a Python function to generate records for a cross-validation dataset. The function should take a directory path as input and create records for a specific model, in this case, "S2_unet". Each record should be stored in a separate file within the specified directory.
The function should be ... | codefeedback |
You are tasked with implementing a custom list data structure in TypeScript. The list should have a maximum capacity of 24 elements and should support the following operations:
1. `add(item: T): void`: Adds an item to the list if the list is not at full capacity.
2. `remove(item: T): void`: Removes the first occurrenc... | codefeedback |
You are tasked with implementing a simple toast notification system in an Angular application. The provided code snippet is a part of the `ToasterContainerComponent` class, which is responsible for managing the toast notifications. The `ToasterContainerComponent` has a `ViewContainerRef` named `container` that represen... | codefeedback |
You are tasked with designing a C++ class hierarchy for rendering graphics in a Wayland-based system. The Wayland display server protocol is a modern replacement for the X Window System, and it is designed to be more efficient and flexible. Your task is to create a class structure for rendering graphics using OpenGL ES... | codefeedback |
You are working on a proof assistant tool that manipulates proof states in a formal system. The code snippet provided is a part of a function that handles a specific tactic called "revert" in the proof assistant. The "revert" tactic is used to revert a hypothesis in the current proof state. The code snippet is written ... | codefeedback |
You are tasked with implementing a custom user administration system for a web application. The system should allow for the management of user accounts, including creating, updating, and deleting user information. To achieve this, you need to create a custom user admin class that extends the `admin.BaseUserAdmin` class... | codefeedback |
You are tasked with creating a function that generates a unique file name for saving audio files. The function should take into account the existing files in the directory and ensure that the new file name is not already in use. The file names are in the format "file_1.wav", "file_2.wav", and so on. Your task is to imp... | codefeedback |
You are tasked with creating a Python function that can encode a given string using a specified character encoding and then generate a QR code from the encoded data. Your function should take the following inputs:
- `data`: A string containing the data to be encoded.
- `encoding`: A string specifying the character enco... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. However, if the last two turns have the same score, the player's score is doubled. You need to write a function that calculates the total score for the game based... | codefeedback |
You are tasked with implementing a program that processes a list of transactions and calculates the total balance for a specific account. Each transaction consists of a date, a description, and an amount. The program should be able to handle deposits (positive amounts) and withdrawals (negative amounts). The balance sh... | codefeedback |
You are tasked with implementing a database model for storing citizenship records. The `Citizenship` model has three properties: `personName` (String), `countryName` (String), and `native` (Boolean). Your goal is to create a method to insert a new citizenship record into the database and another method to fetch a speci... | codefeedback |
You are tasked with implementing a ClusterBuilder class that is responsible for building a cluster from an OMElement representation. The ClusterBuilder class has two constructors, one of which takes an AxisConfiguration object as a parameter. The buildCluster method is used to populate the cluster from the provided OME... | codefeedback |
You are tasked with creating a program to calculate the amount of fuel needed for each part of a vehicle based on its weight and fuel efficiency. The program should prompt the user to input the weight and fuel efficiency of the vehicle, and then calculate and display the amount of fuel required for each part.
The prog... | codefeedback |
You are tasked with creating a program that simulates a simple job scheduling system for a high-performance computing (HPC) cluster. The cluster uses the IBM Load Sharing Facility (LSF) for job management and scheduling. The LSF system allows users to submit jobs with specific resource requirements and execution comman... | codefeedback |
You are tasked with implementing a custom serialization mechanism for a complex object structure. The object structure consists of various types of objects, and the serialization process should handle objects with a type mapping. The serialization process should recursively serialize any child objects that have a type ... | codefeedback |
You are given a positive integer `n`. Your task is to write a program that prints a pattern of asterisks and spaces in the shape of a diamond.
The pattern should be printed using the following rules:
- The top half of the diamond should have asterisks (*) and spaces, with each row containing one more asterisk than the... | codefeedback |
You are given a Python function that takes in a list of integers and returns a modified list. However, the function is incomplete and the code snippet provided is the last line of the function. Your task is to complete the function according to the given requirements.
The function signature is:
```python
def modify_li... | codefeedback |
You are tasked with creating a Python script that automates the process of setting up a testing environment for a software project. The script should utilize various utility functions and modules to perform tasks such as running environment setup scripts, handling file operations, network testing, and interacting with ... | codefeedback |
You are tasked with implementing a custom instruction encoder for a PowerPC machine code emitter. The provided code snippet is part of the implementation and contains a method `encodeInstruction` responsible for encoding machine instructions into binary code. Your task is to complete the implementation of the `encodeIn... | codefeedback |
You are tasked with creating a Python program to analyze and visualize data from a hypothetical NFL stadium dataset. The dataset contains information about various NFL stadiums, including their names, locations, seating capacity, and other relevant details. Your program should perform the following tasks:
1. Connect t... | codefeedback |
You are tasked with implementing a simple file management system using Rust. The system should allow users to update and delete folders. You are provided with the following trait definition:
```rust
trait FolderService {
fn update(&self, request: UpdateRequest) -> Result<Folder, ServiceError>;
fn delete(&self,... | codefeedback |
You are tasked with creating a Python program that interacts with an external module to process time data. The external module provides functions for time manipulation and formatting. Your program should utilize the provided `extern` module to perform various time-related operations.
Your task is to implement a Python... | codefeedback |
You are tasked with implementing a class that represents a simple data structure for storing and manipulating a list of integers. The class should provide methods for adding elements to the list, removing elements from the list, and finding the maximum element in the list.
You are provided with a partial code snippet ... | codefeedback |
You are tasked with creating a Python class that simulates a simple banking account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should have a method for applying interest to the account balance. The interest should be calculated based... | codefeedback |
You are tasked with implementing a program that simulates a simple text-based game. The game involves a character navigating through a grid-based world, collecting treasures, and avoiding obstacles. The character's movements are controlled by a sequence of commands, and the game state is displayed on the console.
Your... | codefeedback |
You are given a text file containing a software license agreement. Your task is to write a Python program to extract the name of the software license and the copyright holder from the file.
The software license name is always preceded by the word "LICENSE" in all capital letters, and the copyright holder is always pre... | codefeedback |
You are tasked with implementing a function to orthogonalize two matrices, representing a feature matrix X and a property matrix Y, with respect to a selected set of samples. The function should take the indices of the selected samples, the feature matrix X, the property matrix Y, and an optional tolerance value. The o... | codefeedback |
You are tasked with implementing a function to calculate the individual coefficients of determination for a given set of scores. The coefficient of determination, denoted as R^2, is a statistical measure that represents the proportion of the variance for a dependent variable that's explained by an independent variable.... | codefeedback |
You are tasked with implementing a function that parses a given input string and extracts specific fields from it. The input string represents a serialized data structure in a custom format, and the goal is to extract the "type" and "id" fields from it.
You are provided with a code snippet that demonstrates the struct... | codefeedback |
You are tasked with implementing a function to determine whether a given set of points forms a "squarish" shape. A shape is considered "squarish" if the following conditions are met:
1. All side lengths are approximately the same, with a given threshold for acceptable deviation.
2. All angles are approximately the same... | codefeedback |
You are tasked with implementing a Python class that processes a given code snippet to identify and handle errors related to a specific set of keywords. The class should have a method to identify and handle errors related to these keywords.
You are given a partial code snippet as a starting point:
```python
class Cod... | codefeedback |
You are tasked with implementing a multi-threaded evaluation function for a CPU device. The function `MultiThreadsEvaluation` is responsible for performing parallel evaluation of a given task on the CPU. Your goal is to complete the implementation of the `MultiThreadsEvaluation` function using the provided code snippet... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.