instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a simple application framework for managing screens. The framework should allow for the creation of multiple screens and the ability to switch between them. Each screen should have a unique identifier and be able to display its content.
You are provided with a basic `Screen` class that... | codefeedback |
You are tasked with creating a Python class for a simple neural network model and implementing a training loop using PyTorch. Your task is to complete the implementation of the `train` method in the given `NeuralNetwork` class. The `train` method takes a dataset of input-output pairs and trains the neural network using... | codefeedback |
You are tasked with creating a Python script that parses a given module source file and extracts information about the extensions to be built. The script should identify the extension modules and their respective details from the provided module source file.
Write a Python function `extract_extensions_info(module_src)... | codefeedback |
You are tasked with implementing a class that reads XML data from an input stream and provides methods for parsing and extracting information from the XML content. Your task is to create a Java class named `XmlParser` that includes the following functionalities:
1. A constructor that takes an `InputStream` as a parame... | codefeedback |
You are tasked with creating a Python function that calculates guess parameters for a given model based on input data. The model is related to medical imaging and requires the estimation of certain parameters. You are provided with a code snippet that tests the output of the function for a specific set of input data an... | codefeedback |
You are tasked with implementing a simplified version of a task execution system in Rust. The system is designed to execute tasks asynchronously and handle their status updates. Your goal is to implement the `TaskExecutor` struct and its associated methods to manage the execution of tasks and handle their status update... | codefeedback |
You are tasked with implementing a class hierarchy for a simple database query system. The system consists of a `Query` class and several subclasses representing different types of query operations. Each subclass represents a specific type of query operation, such as filtering, sorting, or field selection.
The provide... | codefeedback |
You are tasked with creating a function that extracts all the HTML classes from a given HTML code snippet and returns them as a list. The HTML code snippet will be provided as a string. Each HTML class is defined within the `class` attribute of an HTML tag and is separated by a space. The function should return a list ... | codefeedback |
You are tasked with implementing a method to convert a sequence of ASCII bytes into a string. The method should take a byte array as input and return the corresponding string. Note that no bounds checking is performed on the incoming bytes, and the upper bit is silently discarded during the conversion.
You need to imp... | codefeedback |
You are tasked with creating a program that processes user profile pictures. The program should be able to perform basic image manipulation operations such as resizing, cropping, and applying filters. For this problem, you need to implement a function that takes an image and a list of operations as input and returns th... | codefeedback |
You are tasked with implementing a Python class that manages authentication tokens for different social media platforms. The class should handle the retrieval and invalidation of tokens for various providers. Your task is to complete the implementation of the `TokenManager` class by adding the necessary methods to retr... | codefeedback |
You are tasked with implementing a Point class in C++ that can represent points in both Cartesian and polar coordinate systems. The class should have the following functionalities:
1. Constructors to initialize a point in both Cartesian and polar coordinates.
2. Methods to convert a point from Cartesian to polar coordi... | codefeedback |
You are tasked with creating a Python script that simulates the functionality of the `update-rc.d` command in Linux. The `update-rc.d` command is used to install or remove System-V style init script links. The script should be able to add or remove a service from the system's startup sequence.
Your Python script shoul... | codefeedback |
You are tasked with creating a Python script to automate the configuration of iptables for enabling Network Address Translation (NAT) on a Linux system. NAT allows multiple devices within a local network to share a single public IP address when accessing the internet. The script should take input parameters for the net... | codefeedback |
You are tasked with creating a Python class that manages a collection of sequence records. Each sequence record has a name and a position. Additionally, some sequence records may have a "rankParent" attribute indicating their parent's rank. Your task is to implement a method in the class that returns a dictionary conta... | codefeedback |
You are tasked with implementing a function that removes a node (represented by a `Fiber` object) from a tree structure. The `Fiber` object represents a node in a tree and contains references to its parent, previous sibling, and the container node in the DOM.
You are given the following TypeScript code snippet as a st... | codefeedback |
You are tasked with creating a Django REST framework viewset for managing notes in a note-taking application. The `NoteViewSet` class should handle various CRUD (Create, Read, Update, Delete) operations for notes.
Your task is to implement the `NoteViewSet` class with the following requirements:
- The viewset should b... | codefeedback |
You are tasked with implementing a URL routing system for a web application. The application has four different endpoints: icons, charts, tables, and login. Your goal is to create a URL routing system that directs incoming requests to the appropriate handler functions based on the requested endpoint.
You are given a P... | codefeedback |
You are tasked with implementing a key derivation function in PHP for password-based cryptography. The key derivation function to be implemented is PBEKDF2, which is defined in the namespace `Sop\PKCS5\PBEKD`. This function is used to derive cryptographic keys from passwords and is based on the PBKDF2 algorithm specifi... | codefeedback |
You are tasked with creating a registration form for a web application using Angular. The form should include fields for the user to input their name, email, and password. Additionally, the form should have validation to ensure that all fields are filled out and that the email follows a valid format. You are required t... | codefeedback |
You are tasked with implementing a Python program that utilizes the `dedupe` library to perform record linkage on a dataset. The `dedupe` library provides functions for data deduplication and entity resolution, which are commonly used in data cleaning and integration tasks.
Your task is to create a program that takes ... | codefeedback |
You are given a binary tree represented by a pointer to its root node. Your task is to write a function to return the level order traversal of the tree in the form of a 2D array. The level order traversal of a tree is a breadth-first traversal where nodes at each level are visited from left to right.
The function sign... | codefeedback |
You are tasked with implementing a Python function that simulates a simple banking system. The system should support basic operations such as creating accounts, depositing funds, withdrawing funds, and transferring funds between accounts. Each account should have a unique account number and should store the account hol... | codefeedback |
You are tasked with implementing a custom iterator in Rust. The iterator should take an input value `curr` of type `u32` and a shift value `sh` of type `u32`. The iterator should yield the individual bytes of the input value, shifted by the shift value, as `u8` values. The iterator should also keep track of the number ... | codefeedback |
You are tasked with creating a Python function that parses and processes URL routes based on a given configuration. The configuration consists of route names and their corresponding URL patterns. Each URL pattern may contain placeholders for dynamic values, such as IDs. Your function should be able to match a given URL... | codefeedback |
You are tasked with implementing a function that processes a collection of advertisement objects and transforms them into a specific format. Each advertisement object contains a call to action, an image name, and a link. The goal is to create a new collection of transformed advertisement objects, where the call to acti... | codefeedback |
You are tasked with implementing a function to find the last occurrence of a substring within a given string. Your task is to complete the Python function `find_last(a, b)` where `a` is the input string and `b` is the substring to be found. The function should return the index of the last occurrence of the substring `b... | codefeedback |
You are tasked with implementing a Rust program that involves working with type aliases and defining new types. Your goal is to create a program that simulates a simple file format parser by using the provided type aliases and defining new types based on them.
Your task is to define a new type called `FileHeader` that... | codefeedback |
You are tasked with creating a program to parse and extract key-value pairs from a JSON object and store them in a data structure for further processing. The JSON object contains information about a software application, including its build number, build type, version, debuggable status, build version, operating system... | codefeedback |
You are tasked with implementing a Python function that converts a mnemonic phrase into a private key using the BIP39 standard. The BIP39 standard specifies a method for creating a 12 to 24-word mnemonic phrase that can be used to generate deterministic wallets. The mnemonic phrase is used to derive a seed, from which ... | codefeedback |
You are tasked with creating a Python function that generates a SQL query to create a table based on the given column specifications. The function should take a list of dictionaries, where each dictionary represents a column and its properties. The properties include the column name, data type, primary key status, uniq... | codefeedback |
You are tasked with creating a Python function that dynamically generates command-line arguments for a distributed training script using the `argparse` module. Your function should add a group of arguments related to Distributed Data Parallel (DDP) training to the given `argparse.ArgumentParser` object.
The function s... | codefeedback |
You are tasked with creating a Python function that processes Jupyter notebooks to generate thumbnail images for code cells. The function should take a Jupyter notebook and a dictionary of resources as input, and return the processed notebook and updated resources. The thumbnail images should be generated for code cell... | codefeedback |
You are tasked with implementing a custom `LinkedList` class in Python. The `LinkedList` class should have the following methods:
- `__init__(self)`: Initializes an empty linked list.
- `append(self, data)`: Appends a new node containing the given `data` to the end of the linked list.
- `__str__(self)`: Returns a strin... | codefeedback |
You are tasked with implementing a function that processes a given configuration object and generates a formatted HTML component based on the provided properties. The configuration object contains properties for the variant, size, and color of the component. Your task is to create a function that takes this configurati... | codefeedback |
You are tasked with creating a Python class that manages file transfers and tracks any errors that occur during the process. The class, `FileTransferManager`, has a method `track_errors` that updates an error dictionary with information about the source and destination paths and their corresponding file permissions in ... | codefeedback |
You are tasked with implementing a function that classifies the type of a given local variable name in a C# program. The classification is based on the position of the variable name within the source code. The classification function takes the position of the variable name as input and returns the type of the variable.... | codefeedback |
You are given a singly linked list and a positive integer `k`. Write a function to reverse the nodes of the linked list `k` at a time and return the modified list. If the number of nodes is not a multiple of `k`, then left-out nodes, in the end, should remain as it is.
For example, given the linked list `1 -> 2 -> 3 -... | codefeedback |
You are tasked with implementing a function that performs a multi-key retrieval operation from a data store. The function should handle both successful and failed key lookups and return the results accordingly.
You are given a code snippet that partially implements the functionality. The snippet shows a part of a func... | codefeedback |
You are tasked with implementing a function that takes a pointer to a destination array and a 128-bit vector as input and stores the components of the vector into the destination array. The function is expected to handle both intrinsic and non-intrinsic implementations.
You are given the following code snippet as a st... | codefeedback |
You are tasked with implementing a class to parse a binary file containing a sequence of bits with a specific endianness. The file format is as follows:
- The file contains a sequence of bits, where each bit is represented by a single byte.
- The endianness of the sequence is specified by the file format.
Your task is... | codefeedback |
You are given a snippet of code that manipulates a set of indices for a 3D mesh. The code snippet is part of a function that generates indices for rendering a 3D mesh using a specific pattern. The function takes two parameters: `Meridians` and `k`. The `Meridians` parameter represents the number of longitudinal lines o... | codefeedback |
You are given a set of constraints in the form of mathematical expressions involving decision variables. Your task is to write a program to determine the feasibility of these constraints and find a feasible solution if one exists.
The constraints are represented in the following format:
```
m.c83 = Constraint(expr= ... | codefeedback |
You are tasked with implementing a function to analyze a set of binary lines and calculate a metric based on their frequency distribution. The function `task1` takes two parameters: a reference to a vector `lines` containing unsigned integers representing binary lines, and an unsigned integer `bitcount` representing th... | codefeedback |
You are tasked with creating a custom error type in Rust for a version control system. The error type should handle various error cases related to JSON parsing, file cleanliness, input/output operations, and Git operations. Your goal is to implement the custom error type and handle different error scenarios using this ... | codefeedback |
You are tasked with implementing a Python class that manages a database of hosts and their corresponding keys. The class should provide methods for adding hosts, retrieving keys, and joining relations between hosts. You are provided with a code snippet for the `keys` method, which returns a tuple representation of keys... | codefeedback |
You are tasked with creating a program that simulates a simple game using a 5x5 grid. The game involves a player navigating through the grid to reach a goal while avoiding obstacles. The player's position and the goal position are represented by specific characters on the grid. The obstacles are represented by differen... | codefeedback |
You are tasked with creating a Python class that validates and processes URLs using Django's forms module. Your task is to implement a custom form class that accepts a URL input from a user and provides a placeholder for the input field. The form should validate the URL and return it in a specific format.
Create a Pyt... | codefeedback |
You are tasked with implementing a learning rate adjustment function for a deep learning optimizer. The function should adjust the learning rate based on the specified mode and parameters. The learning rate adjustment function should support two modes: "step" and "warmup_step".
The "step" mode adjusts the learning rat... | codefeedback |
You are tasked with implementing a simple traffic light control system using Python and Flask. The provided code snippet initializes a `TrafficLights` object and sets up Flask routes for controlling the red traffic light. Your task is to extend this system to include routes for the yellow and green traffic lights, and ... | codefeedback |
You are tasked with implementing a simple 2D rendering engine in Rust using the WebGl2 API. The provided code snippet outlines a trait `Renderable` that defines methods for initializing and rendering objects. Your goal is to create a concrete implementation of this trait for a basic shape, such as a square, and then us... | codefeedback |
You are tasked with creating a web application that displays localized content based on the user's language preference. The application uses the Razor view engine in ASP.NET MVC to render the content. The provided code snippet is from a view file in the application, and it sets the title, subtitle, and description for ... | codefeedback |
You are tasked with creating a Python program to analyze data related to signs of the zodiac. The program should calculate the number of days each zodiac sign has been in effect between a given start date and the current date.
The zodiac signs are represented by the following IDs: 1 for Aries, 2 for Taurus, 3 for Gemi... | codefeedback |
You are tasked with creating a program to parse and analyze a series of review data from a web application. The reviews are represented in HTML-like syntax, and each review contains a user's rating, company information, review title, and description. Your task is to extract and process the review data to generate a sum... | codefeedback |
You are tasked with creating a program to manage TV show ratings. The program should allow users to add, update, and view ratings for different TV shows. Additionally, it should provide the functionality to iterate through all the ratings and modify them.
Your task is to implement a `TvRatings` struct with the followi... | codefeedback |
You are tasked with implementing a reusable entity identifier manager in Swift. The manager should provide a way to generate unique entity identifiers and mark them as unused for future reuse.
You are provided with a code snippet that outlines the interface for the entity identifier manager:
```swift
/// - Parameter ... | codefeedback |
You are tasked with creating a program that counts the occurrences of specific words in a given text file. The program should read the text file and then output the frequency of each word in the file. For this problem, you should consider a word to be any sequence of characters separated by whitespace.
Your program sh... | codefeedback |
You are working on a scientific computing project and need to implement a numerical differentiation method to compute Jacobian matrices for a system of equations. The code snippet provided is a part of a larger program that aims to calculate the Jacobians using the complex-step differentiation (CSD) method. The `make_n... | codefeedback |
You are tasked with implementing a PoisoningAttackAdversarialEmbedding class for a machine learning framework. The PoisoningAttackAdversarialEmbedding class is responsible for generating adversarial examples to poison a classifier model. The code snippet provided is a unit test for the PoisoningAttackAdversarialEmbeddi... | codefeedback |
You are working on a Django project that includes a REST API for managing user data. The code snippet provided is from a test suite for the API. The `fixtures` list contains the name of a JSON file that serves as test data for the API tests. The `setUp` method is used to set up the test environment by obtaining an auth... | codefeedback |
You are tasked with creating a video search application that interacts with an external API to retrieve a collection of videos based on a user's query. The API client and access token are provided, and you need to implement the `find_videos` function to make the API call and retrieve the videos. Additionally, you need ... | codefeedback |
You are tasked with implementing a test automation script for a web application using Python and Selenium. The provided code snippet is part of a larger test automation framework and contains element locators and a method for navigating to the dashboard page. Your goal is to complete the implementation by writing a tes... | codefeedback |
You are tasked with creating a Python program to automate the process of logging into a university's educational system and retrieving a user's messages. The program should utilize the `zfnew` library, which provides the `Login` and `GetInfo` classes for handling the login process and retrieving user information.
Your... | codefeedback |
You are tasked with implementing a program to calculate the area of a regular polygon. A regular polygon is a polygon with all sides of equal length and all angles of equal measure. The formula to calculate the area of a regular polygon is given by:
\[ Area = \frac{n \times s^2}{4 \times \tan(\frac{\pi}{n})} \]
Where:... | codefeedback |
You are tasked with implementing a progress bar class in Python for tracking the vaccination progress in different regions. The progress bar should visually represent the percentage of the population that has received the first dose of the COVID-19 vaccine. The progress bar class should allow customization of its posit... | codefeedback |
You are tasked with implementing a text parsing algorithm that extracts information from an XML file and processes the content into distinct sections. The XML file contains an article with a title and textual content. The text parsing algorithm should separate the content into an introduction section, unnamed sections,... | codefeedback |
You are tasked with creating a URL shortening service similar to Bitly or TinyURL. Your goal is to write a function that takes a long URL as input and returns a shortened version of it. The shortened URL should be unique and should redirect to the original long URL when accessed.
You are provided with the following co... | codefeedback |
You are tasked with implementing a word autocomplete system using a parallel trie data structure. The parallel trie is a concurrent data structure that allows for efficient concurrent reads and writes. The trie is pre-populated with a list of words, and your task is to implement a function that takes a prefix string as... | codefeedback |
You are tasked with creating a program that simulates a thermometer display for a given temperature range. The program should take the current temperature as input and display a visual representation of the temperature using a thermometer-like design. The thermometer should be displayed as a colored bar within a define... | codefeedback |
You are tasked with implementing a custom string class in C++ that supports various string manipulation operations. Your custom string class should provide functionality for concatenating strings, finding the length of the string, accessing individual characters by index, and comparing strings for equality.
Your custo... | codefeedback |
You are tasked with implementing a pagination class in Python. The class should handle the generation of URLs for the next and previous pages based on the current page number and the availability of next and previous pages.
You are given a code snippet that partially implements the pagination class. Your task is to co... | codefeedback |
You are tasked with creating a password validation function that checks whether a given password meets certain criteria. The password is stored in a specific format, which includes the actual password, its minimum and maximum length, the hashing algorithm used, and the hashed value. Your task is to implement a function... | codefeedback |
You are tasked with implementing a class to manage and manipulate 3D dimensions of objects. The class should allow for setting and retrieving the dimensions in terms of height (H), width (V), and depth (D). Additionally, the class should provide a method to serialize the dimensions into an XML format.
You are given a ... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm using the Twin Delayed Deep Deterministic Policy Gradient (TD3) approach. TD3 is an off-policy algorithm for continuous action spaces, which aims to learn a deterministic policy that maximizes the expected cumulative reward. In this problem, you will f... | codefeedback |
You are tasked with implementing a Python class that processes a dictionary and generates an XML output based on the keys and values in the dictionary. The keys in the dictionary correspond to specific XML components, and the values represent the content of those components. Your task is to create a class that can hand... | codefeedback |
You are tasked with implementing a generic class for managing screens in a software application. The class should be able to handle different types of screens and provide functionality for managing windows associated with these screens.
Create a generic class `SomeGenericScreen<T1, T2>` that extends the `AppScreen` cl... | codefeedback |
You are tasked with implementing a Swift extension for the PhotoAsset class that provides a method to generate a URL for the photo asset. The PhotoAsset class represents a photo in an application, and the URL should be constructed based on the asset's identifier and the specified size.
You are given the following code... | codefeedback |
You are tasked with implementing a logging system that supports different log levels and log messages. The system should be able to handle a large number of log entries efficiently. Your task is to design and implement a logging class in C++ that meets these requirements.
Your logging class should have the following f... | codefeedback |
You are tasked with creating a TypeScript class that manages the window height and provides a method to check if the window height has changed beyond a certain threshold.
You need to implement a class `WindowHeightManager` with the following specifications:
- It should have a private property `_initWinHeight` of type ... | codefeedback |
You are given a code snippet that is part of a function to perform integer division without using the division or modulo operators. Your task is to complete the function by implementing the missing parts.
The function takes two integers, `dividend` and `divisor`, and is expected to return the result of the division. T... | codefeedback |
You are tasked with implementing a class that manages a hierarchical data structure. The class should provide methods to set and retrieve the full name of an item in the hierarchy. The full name of an item is a concatenation of the names of all its ancestors, including itself, separated by a specified delimiter.
You a... | codefeedback |
You are tasked with implementing a simplified order book system for a trading platform. The order book maintains a list of buy and sell orders for a particular financial instrument, with each order containing an identifier, quantity, price, and type (buy or sell).
Your task is to implement the `OrderBook` class and th... | codefeedback |
You are tasked with implementing a queue using two stacks. A queue is a data structure that follows the First-In-First-Out (FIFO) principle, where elements are inserted at the back and removed from the front. A stack is a Last-In-First-Out (LIFO) data structure. The challenge is to implement a queue using two stacks an... | codefeedback |
You are tasked with creating a program that processes HTML content to extract specific information. The program should retrieve a URL from a queue, make an HTTP request to the URL, and then extract and process certain data from the HTML content. Specifically, the program should remove unnecessary characters from the HT... | codefeedback |
You are tasked with implementing a simplified version of the OpenGL function `nglDrawElementsInstancedARB` in Java. This function draws multiple instances of a set of elements. Your task is to create a Java method that mimics the behavior of this OpenGL function.
You are given the following signature for the method:
`... | codefeedback |
You are tasked with implementing a Python class that reads a data file and constructs a list object containing hashes representing records in the file. Your task is to complete the implementation of the `Datafile` class by adding the necessary methods to achieve this functionality.
The `Datafile` class should inherit ... | codefeedback |
You are given a function `calculate_impact_factors(s: str, impact_factor: dict) -> List[int]` that takes a string `s` and a dictionary `impact_factor` as input. The function is intended to calculate the impact factors of the characters in the string `s` based on the provided dictionary and return a list of the calculat... | codefeedback |
You are tasked with implementing a custom data structure to store personal information. The structure should allow for the storage of standard personal details such as first name, middle name, last name, and suffix, as well as additional properties that are not predefined. You need to create a class that can handle the... | codefeedback |
You are tasked with creating a custom content pipeline extension for a game development framework using MonoGame. The content pipeline extension will be responsible for importing and processing Aseprite files, a popular sprite creation tool, into the game project.
Your task is to implement a custom importer and proces... | codefeedback |
You are tasked with implementing a command verification system for a chatbot application. The system should validate commands based on a set of rules and permissions. Each command is represented as a list of strings, and the verification process involves checking the command against a configuration and user permissions... | codefeedback |
You are tasked with creating a program that reads a given source code file and counts the occurrences of specific keywords within the comments section of the code. For the purpose of this problem, comments are defined as any text enclosed within `//` or `/* */` in the source code. The keywords to be counted are provide... | codefeedback |
You are given a graph represented as an adjacency matrix `is_connected` and a starting node `start_node`. Your task is to implement a depth-first search (DFS) algorithm to traverse the graph and return the order in which the nodes are visited.
The graph is represented as a 2D boolean array `is_connected` of size n x n... | codefeedback |
You are tasked with creating a Python function that processes an XML file and writes its data into a CSV file. The function `request_to_csv` takes three parameters: `xml_file_name` (string) representing the name of the input XML file, `csv_file_name` (string) representing the name of the output CSV file, and `report` (... | codefeedback |
You are tasked with implementing a generic trait and a macro in Rust for managing side effects in a platform-agnostic manner. The provided code snippet contains a trait definition and a macro invocation related to this task.
Your goal is to create a trait `UseEffect` and a macro that allows the implementation of side ... | codefeedback |
You are working on a program to analyze clusters of data. The program uses a data structure called `ClusterCounts` to store the counts of different cluster sizes and a data structure called `PValues` to store the p-values associated with the clusters. The code snippet provided initializes the `PValues` object and decla... | codefeedback |
You are tasked with implementing a custom stacked learner for regression tasks. The stacked learner is a subclass of `StackedLearner` and is designed specifically for regression problems. It utilizes a default regression-specific aggregator called `RidgeRegressionLearner`. The stacked learner takes a list of base learn... | codefeedback |
You are tasked with implementing a custom `except` function in JavaScript. The `except` function should take two parameters: `ys` and `comparer`, and return a new array containing elements from the first parameter `xs` that are not present in the `ys` array, based on the comparison logic defined by the `comparer` funct... | codefeedback |
You are tasked with implementing a function to process update requests for a file containing chunks of data. The function will take in the updated information, including an identifier, and update the file's contents accordingly. Additionally, the function will parse the updated file contents and store the chunks for fu... | codefeedback |
You are tasked with designing a coordinator pattern for managing different modules in a mobile application. The coordinator pattern is a design pattern used in iOS development to separate navigation and flow control logic from view controllers. In this problem, you will need to create a coordinator for managing a stopw... | codefeedback |
You are tasked with implementing a function to handle errors in a video stitching application. The given code snippet is part of the error handling mechanism in the application. The `potSurf` object represents a potential surface, and the `ok()` method is used to check if the potential surface is valid. If it is not va... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.