instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a Python class that simulates a simple recipe book. The class should have the ability to add recipes, retrieve recipes by name, and list all available recipes. Additionally, the class should be able to compare the expected ingredients and their quantities for a given recipe with the actual ...
codefeedback
You are tasked with creating a Django model for a social media platform that includes fields for user posts and comments. The model should have fields for the user's post content, the post's creation time, and the comment's creation time. Additionally, the model should automatically update the post's update time whenev...
codefeedback
You are tasked with implementing a NullResultConverter class in C# that adheres to a specific interface. The IConvertsJintEvaluationResult interface is used for converting the result of a Jint evaluation, and the NullResultConverter class should wrap an existing implementation of this interface, providing a null result...
codefeedback
You are tasked with implementing a class for performing eQTL (expression quantitative trait loci) analysis. The class, named `eQTLAnalyzer`, has the following attributes and methods: Attributes: - `annot`: a DataFrame containing annotation information, with a column 'pos' representing positions. - `dosages`: a DataFra...
codefeedback
You are tasked with implementing a generic function that takes a vector of any type and returns the maximum value in the vector. The function should be able to handle vectors of integers, floats, or any other comparable types. You need to define the function signature and implement the function to achieve this function...
codefeedback
You are tasked with designing a system to manage the sub-systems of an active building model. The building model includes the following sub-systems: HVAC, Lift Control, Lighting, Security, Smart Energy (Solar Panels), and Miscellaneous Functions. Each sub-system has specific requirements and functionalities that need t...
codefeedback
You are tasked with implementing a user management system that involves enabling and disabling user aliases, as well as changing user passwords. The system provides a `UserManager` class with various methods for managing user accounts. The code snippet provided demonstrates the usage of the `UserManager` class to perfo...
codefeedback
You are tasked with creating a class that represents a participant in a replay game. The class should have properties for the participant's ID, summoner ID, summoner name, champion ID, and team ID. Your goal is to implement the class with the required properties and ensure that certain constraints are met. Create a C#...
codefeedback
You are working on a continuous integration (CI) system, and you need to write a script to clean up certain files and directories before a build process. The script should remove specific files and directories from the build directory to ensure a clean environment for the build. You are given the following code snippe...
codefeedback
You are tasked with implementing a learning rate scheduler for a machine learning model. The learning rate scheduler should reduce the learning rate by a factor of 'gamma' every 'step_size' epochs. Your task is to write a function that takes the initial learning rate, gamma, and step_size as input and returns a learnin...
codefeedback
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods to initialize an account, deposit funds, withdraw funds, and check the balance. Additionally, the class should have a class method to set up the initial bank balance. Your task is to complete the implement...
codefeedback
You are tasked with implementing a simplified version of a function reference wrapper in C++. The `function_ref` class is designed to store a reference to a function, allowing it to be called later. Your task is to complete the implementation of the `function_ref` class by providing the necessary member functions to st...
codefeedback
You are tasked with creating a function that processes and generates HTML code for a form to select resources and their units. The function should take an array of resources and their available units as input and produce the corresponding HTML code. The function should have the following signature: ```php function gen...
codefeedback
You are tasked with implementing a simple key-value store using Java. Your goal is to create a class that allows for the storage and retrieval of objects based on unique keys. The class should be thread-safe and capable of handling concurrent access. You are provided with a partial code snippet for a Java class called...
codefeedback
You are given a series of assignments to a variable `num` in a Python program. Each assignment updates the value of `num`. Your task is to write a Python function that takes a list of such assignments and returns the final value of `num` after all the assignments have been executed. The input to the function will be a...
codefeedback
You are tasked with creating a program to manage employee attendance records. The program should be able to read a file containing the attendance data and perform various operations on it. The attendance data is stored in a CSV file with the following format: ``` NIP,Tanggal Masuk,Jam Keluar,Keterangan 12345,2022-01-0...
codefeedback
You are tasked with creating a Java class that utilizes the Jackson library to serialize a given object into a JSON string. The class should be able to handle various types of objects and produce the corresponding JSON representation. Your task is to implement the `JsonSerializer` class with a method `serializeObject` ...
codefeedback
You are tasked with implementing a Python class method that calculates the size of a recurrent neural network (RNN) based on certain conditions. The method should return the size of the RNN based on the following rules: 1. If the `_rnn_size` attribute of the class is set, the method should return the value of `_rnn_si...
codefeedback
You are working on a system that monitors an email inbox for messages with a specific subject and processes their contents. The system uses the IMAP protocol to connect to the email server and retrieve unread emails with the subject "OCRE". Once retrieved, the system extracts the text content from the emails and proces...
codefeedback
You are given a code snippet that includes a function call `solution(n)` and some expected output values. Your task is to reverse-engineer the function `solution` based on the provided outputs and write a function that replicates its behavior. The function `solution` takes a single integer `n` as input and returns an ...
codefeedback
You are tasked with implementing a simple car engine simulation program. The program should model the behavior of a car engine, including starting, stopping, and running. The engine can be in one of three states: off, starting, or running. The engine starts in the "off" state and can transition to the "starting" state ...
codefeedback
You are tasked with implementing a function to parse and extract information from an XML file containing data about medical ultrasound devices. The XML file follows a specific format and contains details about various ultrasound devices. Your task is to write a C++ function that reads the XML file, extracts the relevan...
codefeedback
You are tasked with implementing a Python function that calculates the total number of parameters in a convolutional neural network (CNN) model. The CNN model is defined using the PyTorch library, and the provided code snippet shows a part of the model definition. The function should take the model as input and return...
codefeedback
You are tasked with creating a custom derive macro for a Rust struct that implements a specific trait. The trait requires the struct to have a method that calculates the sum of all its fields. Your task is to implement the custom derive macro that generates the necessary code to fulfill this requirement. You are given...
codefeedback
You are tasked with creating a Python class that interacts with an external FemzipAPI for finite element analysis. The FemzipAPI provides methods for importing, exporting, and analyzing finite element models. Your task is to create a Python class that encapsulates the functionality of the FemzipAPI and provides a more ...
codefeedback
You are tasked with writing a program to determine whether a given point lies within a polygon. The polygon is defined by a set of vertices, and the point is represented by its coordinates. The program should take the coordinates of the point and the vertices of the polygon as input and output whether the point lies wi...
codefeedback
You are tasked with implementing a Java class that manages filtering and clearing of form fields for a data query application. The class, `FormManager`, should provide methods for filtering data based on user input and clearing the form fields when needed. The class should also support event handling for filter actions...
codefeedback
You are tasked with implementing a function to generate file fragments based on a given file extension. The function should take the file extension as input and return a list of file fragments that match the extension. The function signature is: ```python def make_frags(extension: str) -> List[str]: pass ``` For ...
codefeedback
You are tasked with creating a function that will analyze a given code snippet and count the occurrences of specific methods within the code. The code snippet will be provided as a string, and the methods to be counted will also be provided as an array of strings. Your function should return a dictionary where the keys...
codefeedback
You are tasked with implementing a Python decorator that logs the details of variable assignments within a function. The decorator should capture the line number, column number, and the assigned value for each assignment statement within the function. Your task is to create the `__report_assign` decorator and apply it ...
codefeedback
You are tasked with writing a program to find the final Fibonacci number based on the first and last letters of a given surname. The final Fibonacci number is obtained by adding the Fibonacci numbers corresponding to the positions of the first and last letters of the surname. To achieve this, you need to follow these ...
codefeedback
You are tasked with implementing a function to perform pairwise bilateral filtering on an input image. Bilateral filtering is a non-linear, edge-preserving, and noise-reducing smoothing filter for images. The function `addPairwiseBilateral` takes several parameters to control the filtering process: - `sxy`: The spatia...
codefeedback
You are given a list of integers representing the daily stock prices of a company. Your task is to write a function to calculate the maximum profit that can be obtained by buying and selling the stock at most once. If it is not possible to make any profit, the function should return 0. For example, given the input lis...
codefeedback
You are tasked with implementing a Python class that manages the scheduling of events. The class should allow for the scheduling of a single event to occur at a specified time, with the option to repeat the event at regular intervals. The class should also support the persistence of scheduled events across different pr...
codefeedback
You are tasked with creating a Python class that represents a rating system for champions in the popular online game League of Legends. The provided code snippet shows the creation of two specific classes, `NA_Quinn_Top_Heimerdinger` and `NA_Quinn_Top_Illaoi`, which inherit from a base class `Ratings`. Your task is to ...
codefeedback
You are tasked with implementing a recursive division algorithm to generate a maze with rooms. The algorithm should take a grid representing the maze and divide it recursively to create rooms and corridors. Each room should be surrounded by walls, and corridors should connect the rooms. The algorithm should stop dividi...
codefeedback
You are tasked with creating a RESTful API endpoint for updating a city record in a database. The existing code snippet is from a Laravel controller method responsible for handling the update operation. The `edit` method is used to retrieve the city data based on its ID and return it as a JSON response. Your task is t...
codefeedback
You are tasked with implementing a class that manages a list of employee tasks. The class should provide methods to add, remove, and retrieve tasks, as well as to calculate the total time spent on tasks for a given employee. You are given a partial code snippet for the `EmployeeTaskManager` class, which includes a pri...
codefeedback
You are tasked with creating a custom caching mechanism for a PHP application using the PSR-16 Simple Cache interface. The cache should support the ability to store and retrieve data, as well as handle cache expiration. Additionally, you need to implement a class that utilizes the Tebru Gson library to serialize and de...
codefeedback
You are tasked with simulating the growth of a cellular automaton using a given set of rules. The cellular automaton is represented as a one-dimensional array of cells, where each cell can be in one of two states: alive ('#') or dead ('.'). The growth of the automaton is determined by applying a set of rules to each ge...
codefeedback
You are tasked with creating a Java program that processes movie recommendation data using a collaborative filtering algorithm. The program should read user and item models from specified files, perform matrix predictions, and write the results to an output file. Your program should accept the following command-line a...
codefeedback
You are tasked with creating a geolocation tracking feature for a React application. Your goal is to implement a custom hook that utilizes the browser's geolocation API to fetch the user's current coordinates. Additionally, you need to handle loading states and error scenarios. Your task is to create a custom React ho...
codefeedback
You are tasked with implementing a class hierarchy for a content management system that models various types of online posts. The provided code snippet is a partial representation of a PHP class `BlogPosting` that extends another class `SocialMediaPosting`. Your task is to complete the class hierarchy by defining the m...
codefeedback
You are tasked with implementing a custom dataset class for image data manipulation in Python using the PyTorch library. Your goal is to create a class that loads test images and their corresponding labels for machine learning tasks. The dataset class should be able to handle image transformations and target transforma...
codefeedback
You are tasked with creating a command-line interface (CLI) tool to manage a distributed job scheduling system. The tool should be able to interact with the system's Raft consensus protocol to list the peers connected to the system. Your task is to implement a function that takes the following inputs: - `command`: A s...
codefeedback
You are tasked with implementing a function to serialize an HTML tag node into a writer. The HTML tag node is represented by the `HtmlTagNode` struct, which contains the tag name, attributes, and child nodes. The `HtmlTagNode` struct is defined as follows: ```rust struct HtmlTagNode { tag: String, attrs: Vec<(...
codefeedback
You are tasked with implementing a module resolution system for a JavaScript project. The project has a directory structure where each module is represented by a file, and modules can be organized into subdirectories. The module resolution system should be able to resolve and export modules based on their file paths. ...
codefeedback
You are tasked with implementing a function to calculate the total number of elements in a multi-dimensional array. The function should take the array as input and return the total number of elements present in the array, considering all dimensions. You are provided with a code snippet that demonstrates a test case fo...
codefeedback
You are tasked with implementing a battery state-of-charge (SoC) management system for a renewable energy system. The system consists of a battery, grid connection, and photovoltaic (PV) generation. The provided code snippet is a part of the battery SoC management model, specifically focusing on the increase in battery...
codefeedback
You are tasked with implementing a string calculator class in C# that can handle negative numbers and custom delimiters. The string calculator should be able to handle negative numbers by throwing an exception and should also support custom delimiters. Your task is to complete the implementation of the `StringCalculat...
codefeedback
You are tasked with implementing a function to parse TLVs (Type-Length-Value) into a request list for a WiFi P2P (Peer-to-Peer) service. TLVs are a common method for encoding data in networking protocols, where each TLV consists of a type field, a length field, and a value field. You are given a class `WifiP2pServiceR...
codefeedback
You are tasked with creating a Python script that parses a given code snippet and extracts specific information from it. The code snippet represents a configuration file for a C++ project, and your script needs to extract the following details: 1. Description: The description of the project. 2. URL: The URL of the pro...
codefeedback
You are tasked with implementing a simple dependency injection system for a game engine. The provided code snippet is a simplified representation of a dependency injection setup using the Unity game engine and the Zenject framework. The `PlayerWorldView` class is responsible for displaying the player's world view and d...
codefeedback
You are tasked with implementing a class for managing posting members in a group. The class, `PostingMember`, is responsible for checking whether a user can post in a given group based on certain conditions. The code snippet provided is a unit test for the `PostingMember` class. Your task is to implement the `PostingMe...
codefeedback
You are tasked with implementing a class that manages a list of test cases for a testing framework. The class should provide methods to add test cases, run all test cases, and report the results. Each test case is represented by a closure that performs a specific test and returns a boolean indicating success or failure...
codefeedback
You are tasked with implementing a function that calculates the momentum of an optimizer used in a machine learning framework. The momentum of an optimizer is a crucial parameter that influences the convergence and stability of the training process. The momentum value is calculated based on the optimizer's configuratio...
codefeedback
You are tasked with implementing a data structure to efficiently store and retrieve currency information. The data structure should support adding currency names and their corresponding plural forms, as well as any associated abbreviations. Additionally, the structure should allow for efficient retrieval of currency in...
codefeedback
You are tasked with creating a Python function that processes a list of parameters, performs a series of calculations, and then parses the results. The function will interact with external modules and handle file operations. Your task is to implement the function `process_and_parse` according to the following specifica...
codefeedback
You are tasked with creating a Python package that simulates a simple banking system. The package should include modules for managing accounts, transactions, and customer information. Your task is to implement the necessary classes and functions for the banking package. Your package should have the following structure...
codefeedback
You are tasked with implementing a type trait to determine whether a given type is an arithmetic type or not. An arithmetic type is defined as a fundamental type that represents numbers and supports arithmetic operations such as addition, subtraction, multiplication, and division. Examples of arithmetic types include i...
codefeedback
You are given a Python function that takes two parameters: `toneValue` and `p`. The function is designed to perform certain operations based on the values of `toneValue` and `p`, and it returns a tuple of two values. The function contains error checks and raises exceptions if certain conditions are not met. Your task i...
codefeedback
You are tasked with creating a program that simulates a simple machine learning model training process. The model will be trained using a basic gradient descent algorithm to minimize a cost function. Your task is to implement the gradient descent algorithm and use it to train a linear regression model on a small datase...
codefeedback
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The program should allow a user to input their choice (rock, paper, or scissors), generate a random choice for the computer, determine the winner based on the choices, and display the result. Your program should follow these ru...
codefeedback
You are tasked with implementing a generic class that represents a simple asynchronous operation. The class should provide a method to start the operation and a property to retrieve the result once the operation is complete. You are given a code snippet that includes an empty class and a read-only property. Your task ...
codefeedback
You are tasked with implementing a class hierarchy for image transformations in a photo editing application. The application supports various image transformations, and you need to create a new transformation class called "ModulateTransform" that changes the brightness, saturation, and hue of an image. The "ModulateTr...
codefeedback
You are tasked with creating a Python program that simulates a data processing pipeline using asynchronous programming. The program should utilize asyncio to concurrently execute multiple data transformation tasks based on a given scan mode. The scan mode determines the type of data processing to be performed. Your ta...
codefeedback
You are tasked with creating a program that manages Visual Studio project files. Your program should implement a class that stores the names of two example Visual Studio project files and provides methods to manipulate and retrieve this information. Create a class `VisualStudioProjectManager` with the following specif...
codefeedback
You are tasked with creating a script to automate the code review process for a Java project using Checkstyle and Reviewdog. Checkstyle is a tool used to ensure that Java code adheres to a set of coding standards, and Reviewdog is a code review tool that can be integrated with version control systems. Your script shou...
codefeedback
You are tasked with implementing a matrix-vector multiplication algorithm using C++ and optimizing its performance using benchmarking. The given code snippet provides a starting point for the matrix-vector multiplication and the benchmarking setup. Your task is to complete the matrix-vector multiplication algorithm an...
codefeedback
You are tasked with creating a function that takes an image, encodes it to base64, and then uses a web view to execute JavaScript code to paste the image onto a web page. Your task is to implement the function `encodeAndPasteImage` in Swift, which takes an `imageData` of type `Data?` as input and returns a `String` rep...
codefeedback
You are tasked with creating a program that validates whether a given model name starts with a number. The model name is a string that can contain alphanumeric characters and underscores, but it must start with a letter or an underscore. Your program should take a model name as input and determine if it violates the ru...
codefeedback
You are tasked with implementing a function that processes configuration data and performs a series of operations on a group within the configuration. The function should remove the specified group from the configuration, write the updated configuration to a file, and then return a success message along with a handler ...
codefeedback
You are tasked with creating a Python program that interacts with a Twitter API to perform specific actions. The program takes command-line arguments and utilizes the `twoauth` library to access the Twitter API. The code snippet provided initializes the necessary credentials and then enters a loop to list direct messag...
codefeedback
You are tasked with implementing a Weight-Balanced Tree (WBT) data structure in C++. The WBT is a self-balancing binary search tree that maintains a balance condition based on the weights of its nodes. The provided code snippet includes a partial implementation of the WBT, with a `clone` method for node cloning and a `...
codefeedback
You are tasked with implementing a simple cache mechanism for storing and retrieving key-value pairs. The cache should have a maximum capacity and support two operations: `put` to insert a new key-value pair and `get` to retrieve the value associated with a given key. When the cache reaches its maximum capacity, it sho...
codefeedback
You are tasked with implementing a simple interface hierarchy in a programming language of your choice. The interface hierarchy consists of three interfaces: `IPbxEvent`, `IRole`, and `IRoom`. Each interface has specific methods that need to be implemented by classes that implement these interfaces. Your task is to cr...
codefeedback
You are tasked with implementing a Python class for performing linear transformations. The class should be able to apply translation to a given input vector using the provided transformation matrix. Your task is to complete the implementation of the `Translation` class by adding the necessary code to apply the translat...
codefeedback
You are tasked with creating a character creation system for a role-playing game. The system should allow players to select a race and then display the corresponding stat modifiers for that race. The stat modifiers are applied to the base stats of Strength (Str), Dexterity (Dex), Constitution (Con), Intelligence (Int),...
codefeedback
You are working on a machine learning project and need to create a custom data loader for your dataset. You have been provided with a code snippet that imports various modules related to data handling and transformation. Your task is to implement a custom data loader using the provided modules and classes. You are giv...
codefeedback
You are tasked with creating a program that compares two JSON files and identifies the differences between them. Your program should read two JSON files, compare their contents, and then output the differences in a human-readable format. The differences should include added, removed, and modified key-value pairs. Your...
codefeedback
You are tasked with implementing a simple search functionality for a web application. The given code snippet is a part of a Python Flask web application. The `app_env` object is used to configure the application environment, and the `assets` variable is added to the global environment. The `app` object represents the F...
codefeedback
You are tasked with implementing a function that determines the return type of a given member of a class. The function should take in a member of the class (either a field, property, or method) and return its return type. The member can be represented as an object of type `FieldInfo`, `PropertyInfo`, or `MethodInfo` fr...
codefeedback
You are tasked with implementing a custom error handling system for a content management application. The system should be able to handle different types of errors and display them in a user-friendly manner. To achieve this, you need to create a class that can format and print error messages in different colors based o...
codefeedback
You are tasked with implementing a Python class method that loads a UDPipe model based on the provided model directory and model name. The method should handle two different cases for the model name: either a specific filename within the model directory or a language string/prefix, in which case the largest UDPipe mode...
codefeedback
You are tasked with implementing a contract verification system for a blockchain application. The system will verify the correctness of a specific function call and raise an assertion error if the verification fails. You are given the following code snippet as a reference: ```python assert contract.foo(array, idx) ==...
codefeedback
You are working on a project that involves using Amazon SageMaker, a cloud machine learning platform. To interact with SageMaker, you need to set up a virtual environment and activate it before running any commands. The code snippet provided is a common way to activate the virtual environment for SageMaker using the `s...
codefeedback
You are tasked with implementing a Python class to model the spread of a disease within a population. The model should support stratification, which involves dividing the population into different groups based on certain characteristics, such as location or age, and tracking the disease spread within each group separat...
codefeedback
You are tasked with simulating the positions of billiard balls on a pool table. The table is a regular hexagon with side length `side_length`, and the balls are placed at specific positions relative to the table. The x and z positions of the balls are calculated using the given code snippet. The variables `ball_diamete...
codefeedback
You are tasked with implementing a class that manages variant values for a product. The class should provide methods to add, update, and retrieve variant values, as well as a method to check if a specific variant combination exists. You are given the following code snippet as a reference for the property that stores t...
codefeedback
You are tasked with implementing a generic data table builder in Java. The builder should be able to construct a data table that can hold any type of data and provide various operations for manipulating and accessing the data. You are given a partial code snippet for the `build` method of the data table builder: ```j...
codefeedback
You are tasked with implementing a JavaScript function that simulates the behavior of the provided code snippet. The code snippet demonstrates the invocation of a JavaScript function using a custom `JSCall` object and its associated methods. Your task is to create a function that takes a JavaScript function `func` as a...
codefeedback
You are tasked with creating a custom attribute for ASP.NET MVC that will log the execution time of controller actions. The attribute should be applied to controller actions and should log the start and end times of the action, along with the elapsed time in milliseconds. You will need to implement the attribute and ap...
codefeedback
You are tasked with creating a Python class that generates synthetic data for regression problems. The class, `SyntheticData`, should be able to produce training and testing datasets based on specified probability density functions (PDFs) and a random seed. The class should have the following attributes and functional...
codefeedback
You are tasked with implementing a reinforcement learning agent using the Deep Q-Network (DQN) algorithm to solve a banana collection task in a Unity environment. The goal is to train the agent to navigate and collect yellow bananas while avoiding blue bananas. The environment is provided through the UnityAgents librar...
codefeedback
You are tasked with creating a parallel processing function for data manipulation using Python's multiprocessing library. Your function will take a dataframe and a function to apply to the dataframe as input, and then parallelize the application of the function across multiple cores. The goal is to improve the performa...
codefeedback
You are tasked with implementing a class that manages date fields and their locales. Your task is to create a method that sets the locale for the date fields. The method should take a `Locale` object as a parameter and update the locale for the date fields accordingly. You need to ensure that the method is accessible o...
codefeedback
You are given a list of integers representing the frequency of events occurring at different time intervals. Your task is to implement a class `EventCounter` with the following methods: 1. `__init__(self, threshold: int)`: Initializes the EventCounter with a threshold value. 2. `add_event(self, timestamp: int, count: ...
codefeedback
You are tasked with creating a function that parses a given HTML file and extracts all the classes used in the "body" tag. The function should return a list of unique class names found in the "body" tag. Write a function called `extractBodyClasses` that takes a string representing the HTML content as input and returns...
codefeedback
You are tasked with creating a Python function that processes a list of file paths and handles any potential IOError exceptions that may occur during file operations. Your function should take a list of file paths as input and attempt to open and read each file. If an IOError occurs during the file operation, your func...
codefeedback
You are tasked with creating a Python function that calculates a specific mathematical formula. The formula involves factorials, exponentiation, and arithmetic operations. Your task is to implement the `formula` function according to the following specifications: The `formula` function takes five integer parameters: `...
codefeedback