instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function that manages user activities for a sports training application. The function `addOrDeleteComparableUser` takes two parameters: `userId`, a string representing the user's ID, and `addUser`, a boolean indicating whether to add or delete the user from the list of comparable user...
codefeedback
You are tasked with implementing a protein site mapper that takes in a set of conditions and returns a mapped site based on those conditions. The code snippet provided is a part of a larger protein mapping system and includes the definition of a default site mapper class and a method for mapping protein sites based on ...
codefeedback
You are tasked with creating a class that represents a student (aluno) in a university system. The student class should have attributes for the student's name, country, and the professor who is responsible for mentoring the student. Additionally, you need to implement a method to retrieve the professor's information ba...
codefeedback
You are tasked with creating a command-line utility that extracts and prints specific information about the machine's hardware. The utility should accept various command-line options to specify which hardware information to display. The code snippet provided is a part of the utility's implementation, using the Rust pro...
codefeedback
You are tasked with creating a SwiftUI app that integrates with ArcGIS to display a map with custom layers. Your goal is to implement a feature that allows users to toggle the visibility of different map layers using SwiftUI controls. You will need to create a SwiftUI view that contains a map view with multiple layers ...
codefeedback
You are tasked with implementing a custom widget for an image editing application. The widget, named `PixlrWidget`, will be used in the `HomePageView` of the application. The `HomePageView` is a part of the application's UI and is created using UiBinder. The `HomePageView` class has a nested interface `Binder` which ex...
codefeedback
You are tasked with creating a program that simulates a simplified version of a CPU scheduler. The scheduler will be responsible for managing a set of processes and allocating CPU time to each process based on their priority. The processes will be represented by a set of integers, where each integer represents the prio...
codefeedback
You are tasked with implementing a binary search algorithm to find a specific element within a sorted array. The binary search algorithm works by repeatedly dividing in half the portion of the array that could contain the item, until the possible locations are narrowed down to just one. The algorithm compares the middl...
codefeedback
You are tasked with creating a Python class that represents a configuration for a project. The configuration should include a boolean flag for verbosity and a set of paths for the project. Your task is to define the class `AppConfig` with the following specifications: - The `AppConfig` class should be a dataclass with...
codefeedback
You are tasked with creating a Rust function that processes HTTP requests using the Hyper and http crates. Your function will need to handle generic types and traits, and ensure that the input and output types are correctly managed. Your function signature should resemble the following: ```rust fn process_request<R,...
codefeedback
You are tasked with creating a program that can analyze the structure of HTML code and identify the number of nested elements within a given HTML snippet. For the purpose of this problem, an element is defined as any tag enclosed within angle brackets, such as `<div>`, `<section>`, or `<main>`. The nesting level of an ...
codefeedback
You are tasked with implementing a custom neural network layer in PyTorch for natural language processing (NLP) tasks. The layer will incorporate word embeddings, dropout, and LSTM (Long Short-Term Memory) units. Your goal is to create a class that initializes these components and applies them to input sequences of wor...
codefeedback
You are working on a project to analyze brain activity data collected from multiple participants. The data is organized into a 3D array where the dimensions represent the participant, time window, and features. Your task is to create a function that processes this data to generate a prediction matrix for each time wind...
codefeedback
You are tasked with creating a custom email notification system using Laravel's Mailable and Queue features. Your goal is to implement a system that sends out personalized email notifications to users based on specific events. To achieve this, you need to create a Mailable class that extends the Illuminate\Mail\Mailabl...
codefeedback
You are working on a project that involves reading data from a file, processing it, and then resizing it. The code snippet provided is a part of this project. The snippet shows the following operations: 1. Reading data from a file using the `fromfile` method of an array `a`. 2. Closing the file after reading. 3. Conver...
codefeedback
You are tasked with implementing a utility function to validate the input data in a C# application. The `Utility` class contains a method `HasValue` that checks whether the input object has a non-null and non-empty string representation. Your task is to extend this utility class by adding a new method that validates wh...
codefeedback
You are tasked with implementing a feature benchmarking system for various computer vision algorithms. The system will evaluate the performance of different feature extraction algorithms on a specific dataset. The code snippet provided initializes the benchmarking system and imports different feature extraction modules...
codefeedback
You are given a Python code snippet that reads data from a file and processes it. Your task is to create a function that simulates the `design_size` function used in the code snippet. The `design_size` function takes a file name as input and returns the number of nodes and edges in the design represented by the file. T...
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. Your task is to write a function that calculates the player's total score based...
codefeedback
You are given a list of coordinates representing the vertices of a polygon in 2D space. Each coordinate is represented as a pair of latitude and longitude values. Your task is to write a function to calculate the area of the polygon defined by these coordinates. Write a function `calculatePolygonArea(coordinates)` tha...
codefeedback
You are tasked with implementing a game AI for a real-time strategy (RTS) game. The game features various types of weapons, and your AI needs to control the behavior of a specific weapon object. The given code snippet is a part of the AI logic for controlling a weapon object. The snippet includes a series of commands t...
codefeedback
You are tasked with writing a Python script to parse a given JSON configuration and extract specific information related to file copies for different operating systems and architectures. The JSON configuration contains a list of file copies for different build configurations, and your script needs to extract the destin...
codefeedback
You are tasked with creating a Python function that processes a list of data extracted from a web page and extracts specific information related to vessel coordinates and position received time. The function should take the list of data as input and return a dictionary containing the vessel name, coordinates, and the p...
codefeedback
You are tasked with implementing a unique queue data structure in Python. The unique queue should only allow unique elements to be enqueued, and it should maintain the order of insertion. To achieve this, you need to complete the `UniqueQueue` class by implementing the `enqueue` and `__init__` methods. The `UniqueQueu...
codefeedback
You are given an array of non-negative integers representing the maximum number of steps you can take from each position in the array. Write a function `minJumps` to find the minimum number of jumps needed to reach the last index of the array, starting from the first index. If it is not possible to reach the last index...
codefeedback
You are tasked with creating a Python program that reads data from an input file, processes it, and writes the result to an output file. The input file contains a series of integers, each represented as 4 bytes in little-endian format. Your program should read these integers, calculate their sum, and write the result a...
codefeedback
You are tasked with simulating a simple load testing scenario for a web application using a bash script. The script should continuously send a specified number of HTTP requests to a given URL and monitor the number of running pods in a Kubernetes cluster. The provided code snippet is a simplified version of a bash scr...
codefeedback
You are tasked with creating a script to automate the training process for a deep learning model using FlowNet2 for optical flow estimation. The provided code snippet is a part of a larger script that sets up the necessary environment for running the FlowNet2 training process. Your task is to complete the script by inc...
codefeedback
You are tasked with creating a script to automate the setup of a Yocto Project environment for building embedded Linux systems. The Yocto Project is an open-source collaboration project that provides templates, tools, and methods to help create custom Linux-based systems for embedded products. Your script should clone ...
codefeedback
You are tasked with implementing a function that simulates a memory allocation strategy using the Best Fit algorithm. The Best Fit algorithm allocates the smallest free partition that is large enough to accommodate the incoming process. You are given a list of free memory blocks and a list of processes with their respe...
codefeedback
You are working on a 3D geometry visualization library that supports various geometric shapes and transformations. Your task is to implement a function that takes a geometric object and its properties as input and generates the necessary visualization code. The code snippet provided is a part of the visualization funct...
codefeedback
You are tasked with creating a Python package for shortening URLs. Your package should include a module named `link` that provides functionality for shortening and expanding URLs using a third-party service. The package should be able to interact with the specified third-party service to perform URL shortening and expa...
codefeedback
You are tasked with implementing a neural network architecture for image processing using PyTorch. The given code snippet is a part of the network architecture definition and includes a sequence of operations applied to the input data. Each operation is represented by a PyTorch module, such as convolutional layers, act...
codefeedback
You are tasked with implementing a custom progress tracking system in Swift. The system should consist of a `ProgressSource` class and a `Progress` class. The `ProgressSource` class will be responsible for updating the progress value, while the `Progress` class will be responsible for tracking and reporting the progres...
codefeedback
You are working as a system administrator for a company that uses a Linux server to host various services. Your task is to automate the setup and configuration of the server using a shell script. The script should perform the following tasks: 1. Compile and install any necessary software using the `make` command. 2. U...
codefeedback
You are tasked with creating a layout for a mobile application's bottom banner view. The code snippet provided contains constraints for positioning two labels, `timeRemainingLabel` and `distanceRemainingLabel`, within the `bottomBannerView`. The constraints are written in Swift using the Auto Layout system. Your task ...
codefeedback
You are tasked with creating a Python function that can determine whether a specified build directory can be set using an environment variable. The function should take two parameters: `changedir` and `tmpdir`. The `changedir` parameter represents the current working directory, and the `tmpdir` parameter represents a t...
codefeedback
You are tasked with implementing a robustness testing algorithm for a machine learning model. The model is to be tested using a given test dataset. The model and test dataset are represented by the functions `model()` and `testdata()` respectively. The `test()` function is provided to perform the robustness testing. T...
codefeedback
You are tasked with implementing a custom extension for the UIImageView class in Swift. The extension should add a method that asynchronously loads an image from a given URL and sets it on the image view. Additionally, the method should handle caching the downloaded images to improve performance. Your task is to compl...
codefeedback
You are tasked with creating a Python program that utilizes the `pyuv` library to handle asynchronous I/O operations. The program should implement a simple file watcher that monitors a specified directory for any changes and logs the details of the changes to the console. Your task is to complete the `FileWatcher` cla...
codefeedback
You are tasked with implementing a Python class that simulates a social media state. The class, `_SocialState`, should support the addition and retrieval of social media providers. Additionally, it should raise an `AttributeError` when attempting to access an attribute that does not exist within the state. Your task i...
codefeedback
You are tasked with simulating a simple unreliable data packet transmission system using Python. The code snippet provided is a simplified version of a packet transmission system using the `ioloop` module for asynchronous event handling. The `packet_send` function is responsible for sending packets, and the `packet_los...
codefeedback
You are tasked with analyzing and visualizing the instantaneous frequency (IF) and phase of a signal using Python's matplotlib and numpy libraries. The given code snippet is part of a larger program that processes and plots the IF and phase information for different cycles of a signal. Your task is to complete the impl...
codefeedback
You are tasked with implementing a resolution manager for a client-server application. The resolution manager is responsible for building a resolver map, which contains a list of resolvers used to handle different types of data. Each resolver is a class that implements a specific resolution strategy. The resolvers are ...
codefeedback
You are tasked with implementing a parallel job scheduling algorithm for a distributed computing system. The system consists of multiple worker nodes and a master node. The master node is responsible for distributing jobs to the worker nodes and collecting the results. The provided code snippet is a part of the master...
codefeedback
You are tasked with implementing a function to calculate the minimum auto-completion velocity for a rotation animation based on the given parameters. The function should consider various conditions and adjust the distance to complete accordingly. You are given the following variables and their meanings: - `previousTim...
codefeedback
You are tasked with creating a C# class that represents a simple banking account. The account should support depositing and withdrawing funds, and should also provide a method to calculate the interest accrued over a certain period of time. Additionally, the account should raise an event whenever a deposit or withdrawa...
codefeedback
You are tasked with creating a custom data structure to store and manage a collection of `DtoEntry` objects. The `DtoEntry` class represents an entry with a string property called `Entry`. Your task is to implement a custom data structure called `DtoEntryCollection` that allows adding, removing, and retrieving `DtoEntr...
codefeedback
You are tasked with implementing a reinforcement learning algorithm for a simple game. The game has a reward system, and the player's actions may trigger a reset of the game state. The reinforcement learning algorithm will receive the current state of the game and must return two values: the reward gained from the curr...
codefeedback
You are tasked with implementing a program that simulates a simple encryption algorithm. The algorithm involves transforming a given string using a set of rules and operations. The input string will consist of lowercase letters, uppercase letters, and digits. The encryption algorithm follows these steps: 1. Reverse th...
codefeedback
You are tasked with implementing a class for managing spice inventory. The class should support adding, removing, and checking the availability of various spices. Additionally, the class should provide a method to compare two instances of the inventory and ensure that they contain the same spices in the same quantities...
codefeedback
You are tasked with implementing a neural network training algorithm using Python and NumPy. The given code snippet is part of the backpropagation process in a neural network with three layers: input layer, hidden layer, and output layer. The code snippet calculates the gradients of the cost function with respect to th...
codefeedback
You are working as a DevOps engineer for a company that uses Kubernetes for managing its containerized applications. As part of your responsibilities, you need to automate the process of accessing the Kubernetes dashboard using a script. The Kubernetes dashboard is accessible via a specific URL, and it requires a token...
codefeedback
You are tasked with implementing a simple graphical user interface (GUI) for a timer application using Python's Pygame library. The given code snippet is part of a larger program that sets up the initial display of the GUI. The `self.Screen` object represents the main display surface, and various buttons and controls a...
codefeedback
You are tasked with implementing a class for managing the running of several page watchers. The class, `WatcherManager`, should be designed to handle a collection of `PageWatcher` instances and provide functionality for managing their execution. The `WatcherManager` class should have the following features: - A constr...
codefeedback
You are tasked with creating a Python function that generates unique usernames for new users in a web application. The function should take a string representing the user's first name and a string representing the user's last name as input and return a unique username based on the following rules: 1. The username shoul...
codefeedback
You are working on a project that involves generating reports using JasperReports, a popular Java reporting library. As part of this project, you need to understand and manipulate font extensions using the SimpleFontExtensionHelper class. Your task is to create a Java method that takes a font file path and a font fami...
codefeedback
You are tasked with implementing a function to process a list of strings and remove any trailing whitespace from each string. Additionally, you need to compare the processed strings with their original versions and identify any differences. You are given the following code snippet as a starting point: ```python trim_...
codefeedback
You are tasked with implementing a Python decorator that handles errors for a given function. The decorator should catch a specific type of exception and perform a specific action when that exception is raised within the decorated function. Your task is to complete the implementation of the `handle_request_error_gen` d...
codefeedback
You are tasked with implementing a program to simulate the movement of disks between towers in the classic "Tower of Hanoi" puzzle. The Tower of Hanoi consists of three rods and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size...
codefeedback
You are tasked with creating a Python function that processes Facebook video URLs and downloads the videos based on their source. The function should take a URL as input and determine the source of the video (either from the "watch" section or a group) and then download the video accordingly. The function should be na...
codefeedback
You are tasked with implementing a shift cipher algorithm for encoding a given input string. A shift cipher, also known as a Caesar cipher, is a type of substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. For example, with a shift of 3, 'A' would be repl...
codefeedback
You are tasked with implementing a Python class that simulates a stack data structure. The stack should support the following operations: 1. `push(item)`: Add an item to the top of the stack. 2. `pop()`: Remove and return the item at the top of the stack. 3. `peek()`: Return the item at the top of the stack without rem...
codefeedback
You are tasked with implementing a file reading and processing system for a dictionary file in a C++ program. The provided code snippet is a part of the `open_d1` function in the `DCTRD` class. The function is responsible for opening and reading a dictionary file, and it calls the `ReadFileInfo` function to read the di...
codefeedback
You are tasked with implementing a simplified version of a neural network layer using Python and NumPy. The layer to be implemented is a max-pooling layer, which takes an input tensor and applies max-pooling to it. The max-pooling operation involves dividing the input tensor into non-overlapping subregions and computi...
codefeedback
You are tasked with creating a Python program that simulates a simple game of rock-paper-scissors. The program should allow a user to play against the computer and keep track of the score. The game should consist of a series of rounds, and the winner of each round should be determined based on the classic rules of rock...
codefeedback
You are tasked with creating a program to calculate the total number of days in a given range of years, accounting for leap years. A leap year occurs every 4 years, except for years that are divisible by 100 but not by 400. The program should consider the number of days in each month and account for leap years accordin...
codefeedback
You are tasked with implementing a database utility function for updating records in a table. The function `update` takes four parameters: `$tablename` (the name of the table to update), `$field_name` (the name of the field to use for the update condition), `$field_value` (the value to match in the specified field), an...
codefeedback
You are tasked with implementing a message sender component using Java and Spring Framework. The `AuthorSender` class is responsible for sending messages to a JMS (Java Message Service) queue using the `JmsTemplate` provided by Spring. Your task is to complete the implementation of the `AuthorSender` class by adding a...
codefeedback
You are tasked with writing a script to handle backup configurations using the given code snippet as a reference. The script should source a configuration file, set the RSYNC_PASSWORD environment variable if a password file exists, and configure the RSYNC_CONNECT_PROG and BACKUPURL variables based on the presence of th...
codefeedback
You are given the following Python code snippet that manipulates a binary tree using a stack: ```python stack = [root] while stack: node = stack.pop() if node.left: stack.append(node) stack.append(node.left) node.left = None elif node.right: # Missing code snippet ``` Your...
codefeedback
You are tasked with implementing a function to create a new XKB (X Keyboard Extension) state for a given X11 core keyboard device using the xkb-rs library in Rust. The xkb-rs library provides Rust bindings for the X Keyboard Extension, which allows for advanced keyboard input handling. You are provided with a partial ...
codefeedback
You are given a code snippet that is part of a primality testing algorithm. The code checks whether a given number `n` is a probable prime using the Jacobi symbol and modular exponentiation. Your task is to implement a function that completes the primality testing algorithm using the given code snippet as a reference. ...
codefeedback
You are tasked with implementing a Python class that manages a daemon process. The class, named `Daemon`, should provide methods for starting, stopping, and restarting the daemon process. The daemon process is responsible for performing a specific task in the background, such as monitoring a directory for file changes....
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should be able to handle multiple user accounts, allowing users to check their balance, deposit funds, withdraw funds, and transfer money between accounts. The program should also be able to display a transaction history for each...
codefeedback
You are tasked with creating a Python class that simulates a simple job scheduler for a high-performance computing (HPC) system. The job scheduler will be responsible for submitting, monitoring, and managing jobs on the HPC system. Your task is to implement the `JobScheduler` class with the following functionalities: ...
codefeedback
You are tasked with implementing a priority queue data structure using a max-heap. A priority queue is a data structure that maintains a set of elements, each associated with a priority. The max-heap property states that the priority of a parent node is always greater than or equal to the priorities of its children. Yo...
codefeedback
You are working on a project to optimize a neural network model for deployment on edge devices. As part of this optimization, you need to implement a graph-based transformation on the model's operations. The given code snippet is a part of the transformation process, where operations and tensors are connected in a grap...
codefeedback
You are tasked with implementing a function to optimize a parameter for a quantum algorithm using the given code snippet as a reference. The function `loss_func` takes two parameters: `new_param` (an array of parameters) and `shots` (an integer representing the number of shots for the quantum algorithm). The goal is to...
codefeedback
You are tasked with creating a Python class that interacts with an OAuth-protected API. Your class should be able to handle the authentication process and make requests to the API endpoints. You are provided with a code snippet that initializes an OAuthAPIClient using the LMS_ROOT_URL, api_client_id, and api_client_sec...
codefeedback
You are tasked with creating a Python class to manage actions within a reliability, availability, and maintainability (RAM) software tool. The class should be able to perform various operations on action records, such as adding, deleting, and updating them in a database. Your task is to implement the `RAMSTKAction` cl...
codefeedback
You are tasked with implementing a scheduling service for a company. The service should provide methods to create, update, and delete schedules. You are given a code snippet that outlines the interface for the scheduling service: ```typescript interface SchedulingService { create(category: CreateScheduleDto); upda...
codefeedback
You are tasked with implementing a Python class method that calculates the total message processing time for a subscription. The class `Subscription` has the following attributes: - `consumerGroupId`: The ID of the consumer group. - `endPoint`: The endpoint for the subscription. - `messageInvisibleTimeInSeconds`: The t...
codefeedback
You are tasked with implementing a class that utilizes the `IUnderlyingExecutor` interface to execute a query asynchronously and process the results. The `IUnderlyingExecutor` interface has a single method `ExecuteAsync` that takes a `Query` object and a `Uri` representing the data location, and returns an asynchronous...
codefeedback
You are tasked with implementing a custom TensorFlow operation for calculating the mean and standard deviation of a given input tensor. The operation should be implemented using TensorFlow's custom op API and should be able to handle tensors of any shape. The mean and standard deviation should be calculated along a spe...
codefeedback
You are tasked with implementing a message queuing system using Python and Redis. The provided code snippet demonstrates the process of creating a task in the message queue and pushing items into a list within Redis. Your goal is to extend this functionality by implementing a function that retrieves and processes items...
codefeedback
You are tasked with implementing a file delta computation function for a version control system. The function `compute_delta` takes in a rule path, a mode, and a list of source paths. The rule path specifies the rule file to be used for computing the delta, the mode specifies the mode of computation, and the source pat...
codefeedback
You are tasked with implementing a TypeScript function that validates the properties of a `DialogBoxParameters` object. The `DialogBoxParameters` interface represents the parameters for a dialog box, and your function should ensure that the required properties are present and have the correct data types. The `DialogBo...
codefeedback
You are tasked with implementing a decorator function in JavaScript that modifies the behavior of a given function. The decorator function should intercept the return value of the decorated function and replace it with a specified value if the original return value matches a certain condition. You are provided with th...
codefeedback
You are tasked with implementing a market tagging system for a trading platform. The system should allow users to tag various market events with specific tags for easy categorization and filtering. Your task is to create a class that manages these market tags and provides methods for adding, removing, and querying tags...
codefeedback
You are tasked with implementing a function that recalculates the polygonization of text lines in an image. The function takes an input image and a list of dictionaries, where each dictionary contains information about a text line, including its boundary, baseline, and the actual text. The goal is to modify the polygon...
codefeedback
You are tasked with implementing a retry mechanism for handling HTTP response status codes in a Python program. The program interacts with an external API and needs to handle specific status codes by retrying the request after a certain delay. The provided code snippet demonstrates a part of the retry logic for handlin...
codefeedback
You are tasked with implementing a function that takes an integer as input and returns a Promise that resolves to a string. The function should handle the case where the input is not a number and should reject the Promise with an appropriate error message in such cases. Additionally, the function should handle the case...
codefeedback
You are tasked with creating a part-of-speech (POS) tagging system for Chinese text using a pre-trained model and evaluating its performance. The code snippet provided demonstrates the loading of a pre-trained tagger model, tagging a sample sentence, evaluating the model's performance on a test dataset, and then saving...
codefeedback
You are tasked with implementing a custom file handling class in Python. The class should support setting and getting attributes for the file, while also providing the ability to restrict certain attribute names from being set. Your task is to complete the implementation of the `FileHandler` class by adding the necessa...
codefeedback
You are tasked with creating a function that processes plugin manifests to generate target settings for a project. The plugin manifests contain information about the plugins, such as their paths, helper directories, and template directories. Your goal is to implement a function that takes the plugin manifests as input ...
codefeedback
You are tasked with implementing a frequency modulation (FM) modulator using C++. The modulator should take an input signal and modulate it using frequency modulation before outputting the modulated signal. You are provided with the `modulator.hpp` header file, which contains the necessary class and function declaratio...
codefeedback
You are tasked with creating a custom error handling system for a media player application. The application uses the FMOD library for audio processing and encounters various file-related errors during runtime. Your goal is to implement a custom error handling mechanism that can interpret and handle these file-related e...
codefeedback
You are tasked with creating a program to validate passport data based on strict rules. The passport data is represented as a series of key-value pairs separated by spaces and newlines. Each key-value pair is in the format "key:value". A passport is valid if it contains the following fields: - byr (Birth Year) - four ...
codefeedback
You are tasked with implementing a custom progress dispatcher in Swift. The progress dispatcher should be able to handle the dispatching of progress updates and errors. You need to create a subclass of the `ProgressDispatcher` class and implement the required functionality. Your task is to complete the implementation ...
codefeedback