instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are working on a robotics project that involves using a Color Sensor to detect and differentiate between various colors. The Color Sensor has a function called `light_up` which sets the brightness of individual lights on the sensor. However, changing the brightness can cause the Color Sensor to switch modes, potent...
codefeedback
You are tasked with implementing a function that processes a list of strings and performs a specific operation on each string based on certain conditions. The function should take in a list of strings and return a modified list based on the following rules: 1. If a string contains the word "should" followed by the wor...
codefeedback
You are tasked with implementing a Python class that processes a dataset using the given code snippet as a reference. Your class should handle the dataset-specific fields and perform data processing operations. Your task is to create a class named `DatasetProcessor` with the following requirements: - The class should...
codefeedback
You are tasked with implementing a function that casts an attribute to a native PHP type based on the given key and value. The function should handle various data types and return the appropriate native PHP type for the given value. You are given the following function signature to guide your implementation: ```php /*...
codefeedback
You are tasked with implementing a hash function that takes a string as input and produces a 64-bit hash value. The hash function should be based on the FNV-1a algorithm, which is a simple and efficient non-cryptographic hash function. The FNV-1a algorithm uses a specific prime number and a seed value to produce the ha...
codefeedback
You are tasked with implementing a Python class that simulates a simple cache with a fixed capacity. The cache should support two operations: `get(key)` and `put(key, value)`. The `get(key)` method retrieves the value associated with the given key if the key exists in the cache, and returns -1 if it does not. The `put(...
codefeedback
You are tasked with implementing a custom attribute-based sorting mechanism for a collection of objects in C#. The goal is to create a sorting algorithm that can sort objects based on a specified property and direction using the provided `Direction` enum. You are given the following `Direction` enum definition and a s...
codefeedback
You are tasked with implementing a class for managing goods in an e-commerce system. The provided code snippet is a part of the existing implementation and contains some method calls and conditional checks. Your task is to complete the implementation of the `Goods` class by adding the necessary methods and logic to han...
codefeedback
You are tasked with implementing a custom callback for a machine learning model using the LBANN (Livermore Big Artificial Neural Network) library. LBANN is a deep learning framework designed for high-performance computing environments. In this problem, you will create a callback that monitors the training process and t...
codefeedback
You are working on a deployment automation system that involves managing a stack of resources. The code snippet provided is a part of the system and contains a function called `run_dependencies_deployment_loop`. This function is responsible for running a deployment loop for the stack's dependencies. Your task is to im...
codefeedback
You are tasked with implementing a reward system for a user management system. The system has a class `UserManager` with a method `incrementReward` that takes two parameters: the username of the user and the reward to be incremented. The reward is represented by an emoji, such as '🏅'. The method `incrementReward` shou...
codefeedback
You are tasked with implementing a callback system for a gaming server querying interface. The system should handle responses after requesting details on who is playing on a particular server. The interface should support querying individual servers and canceling in-progress queries to avoid potential crashes. Your ta...
codefeedback
You are tasked with implementing a custom generator function in Python that generates a sequence of prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your generator function should yield the next prime number each time it is called. Your task is to ...
codefeedback
You are tasked with implementing a function that processes a list of tuples representing student grades and returns the average grade for each student. Each tuple contains the student's name as a string and a list of their grades as integers. Your task is to write a function `calculate_average_grades` that takes a list...
codefeedback
You are working on a medical imaging software project and need to implement a landmark transformation algorithm. The code snippet provided is a part of the LandmarkWidget class, which is responsible for updating the properties of glyphs representing landmarks in the 3D space. The LandmarkWidget class has a method calle...
codefeedback
You are tasked with implementing a method to list all the keys stored in a secret manager. The secret manager has a method `get_key(name: str) -> Key` that retrieves a specific key by its name. Each key has a `value` attribute, which is a string in the format "prefix:key". The `prefix` indicates whether the key is encr...
codefeedback
You are tasked with creating a script to manage a process called "pdb-worker" and "pdb-manager". The script should handle command-line arguments for usage and help, and it should be able to terminate these processes. Your script should accept the following command-line arguments: 1. `-h` or `--help`: Display usage inf...
codefeedback
You are tasked with implementing a ConfigMap class that interacts with an API to manage configuration data. The class should support creating, updating, and saving configuration data to the API. Your goal is to implement the `ConfigMap` class and its methods based on the given code snippet and requirements. The `Confi...
codefeedback
You are tasked with creating a script to automate the setup of an Android cross-compiler toolchain. The script should locate the cross-compiler executable, extract the toolchain prefix, and set the CCACHE environment variable to the path of the ccache executable if available. Write a shell script that accomplishes the...
codefeedback
You are tasked with creating a script to manage the startup of Python applications. The script should take the name of the application directory as an argument and start the `app.py` file within that directory if it exists. If the directory or the `app.py` file does not exist, the script should log an error message and...
codefeedback
You are tasked with creating a Python program that simulates a file management system. Your program should implement a class called `FileManager` that allows users to perform various file management operations such as creating files, deleting files, listing files, and checking if a file exists. Additionally, the progra...
codefeedback
You are tasked with creating a Django web application for a blogging platform. The application should allow users to create articles with a title, body, and tags. Each article should also have an author, and the system should automatically generate a slug for each article based on its title. Additionally, the system sh...
codefeedback
You are tasked with implementing a recursive function to calculate the power of a given base to a given exponent. The function should utilize memoization to optimize performance by storing previously computed results. Write a Python function `power(x, n)` that takes in a float `x` as the base and an integer `n` as the...
codefeedback
You are tasked with implementing a simplified version of a protocol handshake mechanism using asynchronous tasks in Rust. The code snippet provided demonstrates the setup for two asynchronous tasks, `task_a` and `task_b`, each responsible for performing a handshake with a protocol instance `a` and `b` respectively. Yo...
codefeedback
You are given an array of integers, and your task is to find the maximum sum of a contiguous subarray within the array. A subarray is a contiguous segment of the array. For example, in the array [1, -2, 3, 4, -1, 2, 1, -5, 4], the subarray [3, 4, -1, 2, 1] has the maximum sum of 9. You need to write a function `maxSub...
codefeedback
You are tasked with creating a program to manage the characteristics of a hero in a role-playing game. The program should allow the user to add or remove points from different characteristics of the hero, such as strength, agility, intelligence, etc. The user should be prompted to input the characteristic and the numbe...
codefeedback
You are tasked with creating a Python unit test for a utility function that calculates the average of a list of numbers. The utility function is provided in the `utilities.util` module, and you need to write a test case to ensure its correctness. The test case should utilize a custom logger from `utilities.custom_logge...
codefeedback
You are tasked with implementing a function that processes GPS coordinates and determines the distance traveled by a vehicle. The function will take in a series of latitude and longitude coordinates and calculate the total distance traveled based on the Haversine formula. The Haversine formula is used to calculate the ...
codefeedback
You are tasked with creating a function that performs a soft delete operation on a database record. Soft delete, also known as logical delete, involves updating a specific column in the database to mark a record as deleted without physically removing it from the database. Your task is to implement a PHP function that p...
codefeedback
You are tasked with implementing a file system class in Python. The file system should support the addition of files and directories, as well as the ability to calculate the total size of all files within a given directory. You are provided with the following code snippet to serve as a starting point: ```python class...
codefeedback
You are tasked with implementing a Python script to train a neural network for image classification using the Keras library. The provided code snippet is a call to the `main` function with various command-line arguments. The `main` function is expected to perform the following tasks: 1. Load the weights of a pre-traine...
codefeedback
You are tasked with implementing a custom asynchronous sequence type in Swift. The sequence should be able to produce elements from a base asynchronous sequence as long as a given predicate function returns true for the elements. Your task is to complete the implementation of the `AsyncPrefixWhileSequence` struct by pr...
codefeedback
You are tasked with implementing a Java class that processes input streams to generate compressed bitmap images. The class should be able to handle various input streams and apply compression options to produce the desired output. Your task is to complete the implementation of the `InputStreamAsBitmapCallable` class by...
codefeedback
You are tasked with creating a Python class that manages common content management system (CMS) functionality. The class should inherit from the `AbstractPermalink` class and should be designed to work with a user model specified in the Django settings. Your task is to complete the implementation of the `CommonCms` cl...
codefeedback
You are tasked with implementing a final field handler interface for a structure in a Java application. The interface `FinalFieldHandler<T>` extends the `StructureFieldHandler<T>` interface and includes a method `fillFinalField` to fill a final field from a structure. Your goal is to create a concrete class that implem...
codefeedback
You are tasked with implementing a function that calculates the total number of unique ways to climb a staircase. The staircase has a specific number of steps, and you can climb either 1 or 2 steps at a time. Your task is to write a function `countWays` that takes the number of steps as input and returns the total numb...
codefeedback
You are tasked with creating a Python script that monitors the disk space usage on a Linux system and sends an alert if the usage exceeds a certain threshold. You will need to utilize the `psutil` library to retrieve disk usage information and the `smtplib` library to send an email alert. Your script should perform th...
codefeedback
You are tasked with implementing a custom exception hierarchy for a Python application. The application is designed to handle various types of errors that may occur during its execution. Your goal is to create a set of custom exception classes that inherit from the base Python `Exception` class and provide specific err...
codefeedback
You are tasked with creating a Python class that performs linear fitting for categorical target variables. Your task is to implement the `LinearFitOperator` class, which takes a pandas DataFrame as input and fits a linear model to predict a categorical target variable. The class should provide methods to process the in...
codefeedback
You are tasked with creating a Python script to preprocess text data using byte pair encoding (BPE) for language modeling. BPE is a data compression technique that replaces frequent pairs of bytes with a single byte. The given code snippet demonstrates the preprocessing steps using the GPT-2 BPE model on a small datase...
codefeedback
You are working on a version control system and need to automate the process of updating the repository based on a new version release. Your task is to write a script that performs the necessary Git commands to update the repository to a new version. The script should pull the latest changes from the remote repository,...
codefeedback
You are tasked with creating a Swift property wrapper to handle the storage and retrieval of user preferences for a currency type in a financial application. The property wrapper should utilize UserDefaults for storage and provide a default value of `CurrencyType.bitcoin` if no value is found in UserDefaults. Additiona...
codefeedback
You are tasked with creating a custom binary sensor platform for the Eldes security system in Home Assistant. The Eldes security system provides various sensors that can be integrated into Home Assistant for monitoring purposes. Your goal is to implement the `async_setup_entry` function, which is responsible for settin...
codefeedback
You are tasked with implementing a Python class that simulates a simple stopwatch. The class should have the following functionalities: - Start the stopwatch - Stop the stopwatch - Reset the stopwatch - Get the elapsed time in seconds You are provided with a partial implementation of the Stopwatch class as follows: `...
codefeedback
You are tasked with implementing a test coverage analysis tool for a Python codebase. Test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. One common metric is the percentage of code lines executed during testing. Your goal is to cre...
codefeedback
You are working on a web application that uses a PHP backend with a MySQL database. Your task is to create a function that retrieves the ID of a module based on its controller name. The given code snippet shows a PHP function `getId` that takes a controller name as a parameter and constructs a SQL query to fetch the co...
codefeedback
You are tasked with implementing a user permission management system. The system should allow users to have different levels of permissions, and it should support operations to grant, revoke, and check permissions for users. You are given the following code snippet as a starting point: ```python USER_PERMISSIONS = se...
codefeedback
You are tasked with implementing a metadata store for managing artifacts. The metadata store allows users to define artifact types, create artifacts of those types, and retrieve artifacts by their IDs. Your goal is to create a Python class that provides methods for putting artifact types and artifacts into the store, a...
codefeedback
You are given a string representing a C++ code snippet that needs to be formatted according to the rules specified in the `.clang-format` file. The `.clang-format` file contains a set of rules for formatting C++ code, including indentation, line breaks, and other style preferences. Your task is to write a program that ...
codefeedback
You are tasked with implementing a custom loot entry deserializer for a Minecraft mod. The deserializer will parse JSON data and create corresponding loot entries based on the provided information. The loot entries can be of different types, such as empty, item, or table, and may include conditions and functions. Your...
codefeedback
You are given a code snippet that performs factorization of a number using the Pollard's rho algorithm. Your task is to implement a function that takes an integer `n` as input and returns the prime factors of `n` using the Pollard's rho algorithm. The Pollard's rho algorithm is an algorithm used to find the prime fact...
codefeedback
You are tasked with creating a program that analyzes a given software license text to extract and display the permissions and conditions specified in the license. The license text is provided as a string, and the program should identify and display the permissions and conditions based on the following rules: - Permiss...
codefeedback
You are tasked with implementing a function to parse search results from a file and verify the correctness of the parsed data. The search results are expected to contain information about duplicate repositories in GitHub and Bitbucket. The function should parse the results and return the count of duplicate repositories...
codefeedback
You are working for a farm management system that tracks various types of crops and their associated data. Your task is to write a Python function that processes a list of tuples, each representing a crop, and returns a dictionary containing the average yield for each unique crop type. You are given a list of tuples, ...
codefeedback
You are tasked with creating a program that parses and analyzes metadata from a list of strings representing software licenses and programming languages. Each string in the list contains metadata in the form of key-value pairs separated by double colons (::). The keys represent different attributes of the software, suc...
codefeedback
You are working on a project to automate the setup of a Vault server using Docker and shell scripting. Your task is to write a script that sets up the Vault server, copies policy files, and performs some initial configuration. Given the following code snippet as part of the setup script: ```bash -e "VAULT_DEV_LISTEN_...
codefeedback
You are tasked with implementing a SkipGramDataGenerator class for generating training data for a SkipGram model. The SkipGram model is used for word embedding in natural language processing. The SkipGramDataGenerator takes a text file as input and generates training data in the form of word pairs for the SkipGram mode...
codefeedback
You are tasked with implementing a real-time speech-to-text transcription system. The system should continuously transcribe spoken words into text as they are being spoken. The provided code snippet is a part of the system and shows how the transcription is updated in real-time. Your task is to write a function that t...
codefeedback
You are working on a project that involves managing entities and enums in a TypeScript application. Your task is to create a utility function that can merge and export all the entities and enums from different files into a single file for easier access. You are given a directory containing multiple TypeScript files, e...
codefeedback
You are tasked with implementing a simple authentication system using Python. The system should have a class called `AuthCodeRequestHandler` that handles the generation and validation of authentication codes. The authentication code is a 6-digit alphanumeric code that is generated and sent to the user's email for verif...
codefeedback
You are tasked with implementing a method to retrieve the current login information for a user in a C# application. The `GetCurrentLoginInformations` method is part of an interface, and your goal is to create a concrete implementation for this method. The `GetCurrentLoginInformations` method returns a `Task` that resol...
codefeedback
You are tasked with creating a function that processes a list of integers and returns the maximum sum of a contiguous subarray within the list. The function should be implemented in Swift. You are given the following code snippet as a reference: ```swift deinit { var fooParam = FooStruct() #^IN_INVALID_3^# } fun...
codefeedback
You are tasked with creating a Python function that processes a list of database migration operations and generates a SQL script to apply those operations to a database. Each migration operation is represented as an instance of a migration class, and the SQL script should include the necessary SQL statements to execute...
codefeedback
You are tasked with creating a web application using Dash, a Python framework for building analytical web applications. Your goal is to implement a dynamic page routing system that generates pages based on a given integer input. You will need to create a function that takes an integer as input and returns the name of t...
codefeedback
You are tasked with implementing a generic interface for establishing a connection to an endpoint. The interface, `IConnectable<TType, TEndPoint>`, contains a single method `Connect` that takes an endpoint and a callback function as parameters. Your goal is to create a class that implements this interface and provides ...
codefeedback
You are tasked with implementing an event handling system in Python. The system should allow registering event handlers for different types of events and unregistering them when necessary. Each event handler is associated with a unique handler ID, which is returned upon registration and used for unregistration. You ne...
codefeedback
You are working on a graphics rendering engine and need to implement a function to create a Metal Render Pipeline State Object (PSO) for rendering terrain. The given code snippet is a part of the implementation and provides a static function `createTerrainPSO()` that returns the Metal Render Pipeline State. Your task ...
codefeedback
You are tasked with implementing a Python function that processes a tree structure and interacts with the user to navigate through the tree. The tree is represented as a nested list of tuples, where each tuple contains a method name and a description. The function should allow the user to traverse the tree by selecting...
codefeedback
You are tasked with creating a script to automate the download of software packages from the web. Your script should be able to parse a given URL and extract the filename and download link. Additionally, it should be able to handle different types of URLs and provide the user with feedback on the download progress. Wr...
codefeedback
You are tasked with implementing a card game strategy using object-oriented programming concepts. The provided code snippet is a part of a larger card game framework. Your goal is to complete the implementation of the `IlmiorStrategy` class, which represents a specific strategy for playing the card game. The `IlmiorSt...
codefeedback
You are tasked with creating a Python class that represents a generic data structure. The class should have a property called `datatype` that returns the data type of the elements stored in the data structure. Your task is to implement the `datatype` property in the class to achieve this functionality. Create a Python...
codefeedback
You are tasked with creating a script to manage the health checks and startup of Docker containers. The script should check if a specified container is running and if its health status is "healthy". If the container fails to meet these criteria, the script should perform cleanup and display an error message. Otherwise,...
codefeedback
You are tasked with implementing a function to compute trajectory features based on a given set of parameters and time range. The function `compute_trajectory_features_set1` takes four parameters: 1. `aligned_trajector_key_file`: A pandas DataFrame containing aligned trajectory key data. 2. `parameters`: A dictionary c...
codefeedback
You are tasked with creating a Python program that interacts with a translation API to translate a given text from a source language to a destination language. The program should handle potential errors and exceptions that may occur during the translation process. Your task is to implement a function `translate_text` ...
codefeedback
You are tasked with implementing a custom serializer and handling potential data corruption during deserialization. The `Serializer` class has a method `Deserialize<T>` which deserializes a given data into an object of type `T`. However, there is a possibility of data corruption during deserialization, which should be ...
codefeedback
You are given a code snippet that imports a module called `puzzler` and uses it to run a specific puzzle called `OneSidedTetratwigsTriangle_3` from the `tetratwigs` puzzles collection. Your task is to understand the puzzle being run and create a Python function that solves it. The `OneSidedTetratwigsTriangle_3` puzzle...
codefeedback
You are tasked with implementing a Python decorator that measures the execution time of a function and logs the result. The decorator should be designed to work with the Twisted framework, a popular event-driven networking engine. Your task is to complete the implementation of the `measure_execution_time` decorator, w...
codefeedback
You are tasked with creating a number guessing game in Python. The game should prompt the user to guess a randomly generated number between 1 and 100. If the user guesses the correct number, the game should display a congratulatory message and terminate. However, if the user guesses incorrectly, the game should prompt ...
codefeedback
You are tasked with implementing a function to rotate a 2D texture matrix in a graphics application. The given code snippet is a part of a larger codebase and contains a case statement handling the left arrow key press event. Inside this case, there is a conditional check for a macro `JOHNS`, and if it is defined, a 2D...
codefeedback
You are tasked with implementing a memory management system for a virtual reality application. The application uses the Oculus Rift SDK, and you need to create a class that manages the memory allocated for packets received from the Oculus Rift sensors. The class should handle the disposal of memory resources to prevent...
codefeedback
You are tasked with implementing a function to decrypt a wallet record using a set of keys. The function takes in a reference to a set of keys and returns a result containing the decrypted wallet record. The `decrypt_merged` function is used to decrypt the record's ID using the name key from the provided set of keys. H...
codefeedback
You are tasked with creating a Python script that automates the setup process for a specific GitHub repository and its associated dependencies. The script should clone the repository, create a new conda environment, install required packages, and activate the environment. The specific steps to be performed are as follo...
codefeedback
You are tasked with creating a function that validates appointment times based on specific business rules. The function should reject appointments that fall outside the allowed time range and should also handle cases where the appointment creation process throws an error. You are given a code snippet that tests the ap...
codefeedback
You are tasked with implementing a data processing algorithm for a performance monitoring system. The algorithm processes data and updates a database with the results. The provided code snippet is a part of this algorithm and contains a loop that iterates over a range of rows and performs various operations. Your task ...
codefeedback
You are tasked with implementing a class method for a handwriting recognition system. The method is responsible for calculating the deviation of horizontal distances between consecutive strokes in a word. The class has an attribute `_source` which holds the source of the handwriting data. The method `_distance_deviatio...
codefeedback
You are tasked with implementing a Swift library for managing and manipulating dates and times. Your goal is to create a `DateBuilder` class that allows users to easily construct and manipulate dates and times using a fluent interface. The class should provide methods for setting the date, time, and weekday, and for re...
codefeedback
You are tasked with creating a Python unit test for a function that interacts with Docker API and performs operations on a Docker container. The function to be tested is part of the `tern.load.docker_api` module. Your goal is to write a test case that ensures the correct behavior of this function. The function to be t...
codefeedback
You are tasked with implementing a memory management system for a programming language. The system should provide functionality to view the current reachable heap and obtain information about specific objects. The system also supports an optional argument for debugging purposes. Your task is to implement the `heap()` ...
codefeedback
You are tasked with implementing a Python package for handling football (soccer) match statistics. The package should provide functionality for parsing match data, calculating various statistics, and generating reports. Your task is to create a class `MatchStatistics` within the `anstoss` package that encapsulates the ...
codefeedback
You are tasked with creating a custom neural network model using the Keras library in Python. Your goal is to design a model that combines sequential and functional API components to create a complex architecture. The model should include LSTM, Dense, and Input layers, and it should be able to accept multiple inputs. Y...
codefeedback
You are working on a Django project that involves managing bibliographic records. The code snippet provided is from a test suite for the project. The test is using the pytest framework and the django_db fixture to perform database operations. The test is checking the caching behavior of a bibliographic record object. ...
codefeedback
You are tasked with implementing a password validation function that checks for various criteria to ensure the password's strength. The function should validate the password based on the following rules: 1. The password must be at least 8 characters long. 2. It should not contain characters repeated more than twice con...
codefeedback
You are working on a project that involves fitting a polynomial curve to a set of data points. To achieve this, you decide to use the `np.polyfit` function from the NumPy library, which fits a polynomial of a specified degree to the given data using a least-squares approach. However, you encounter a problem with the ou...
codefeedback
You are tasked with implementing a simple iOS application that simulates a button state transition. The application will have a button that can be in one of three states: Unknown, Checking, or Success. You need to create a Swift class that represents the button's state and provides methods to transition between these s...
codefeedback
You are tasked with creating a Java program that simulates a simple quiz game. The program should use the Scanner class to take input from the user for answering the quiz questions. The quiz should consist of multiple-choice questions, and the user's score should be calculated and displayed at the end of the quiz. You...
codefeedback
You are working on a reinforcement learning project and need to implement a function to calculate derivative data for different targets in the context of a specific environment. The environment has observation and action spaces, and the derivative data will be used for training a neural network. You are given a code s...
codefeedback
You are tasked with simulating a data collection process for an underwater vehicle's thrusters. The vehicle has multiple thrusters, each with various pulse-width modulation (PWM) values. The data collection process involves running trials for a specific duration, then resetting the thrusters, followed by a calm period ...
codefeedback
You are tasked with creating a custom decorator in TypeScript for a specific use case. The decorator should be designed to validate the providers array within a module in an Angular application. The decorator should ensure that the providers array contains a specific service called "AuthService" and that it is the firs...
codefeedback
You are tasked with implementing a custom neural network module in PyTorch for multi-task learning. The module, named `MultiTaskDense`, is designed to handle multiple tasks simultaneously and is initialized with the number of features and the number of tasks it will be handling. Additionally, it allows for a customizab...
codefeedback
You are tasked with creating a Python function that processes a generator and returns a list of items. The generator yields wallpaper items parsed from a web page using Scrapy. Each wallpaper item is represented as a dictionary containing details such as the image URL, title, and tags. Your function should take the gen...
codefeedback