instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a shared coroutine queue system in Swift. The shared coroutine queue system should support a fixed capacity and allow multiple coroutines to enqueue and dequeue items concurrently. The system should be implemented using the `FifoQueue` data structure, which is a first-in-first-out queue... | codefeedback |
You are tasked with creating a program that processes a batch of job submission records and extracts relevant information from each record. Each record is a string containing various directives and metadata related to a job submission on a high-performance computing (HPC) cluster. The directives include the number of G... | codefeedback |
You are tasked with implementing a Python function that processes a list of import statements and returns a dictionary containing the imported modules and their corresponding classes or functions. Each import statement follows the format `from <module> import (<class1>, <class2>, ...)`. If a module is imported multiple... | codefeedback |
You are tasked with implementing a custom collection view layout for a weather app that displays the weather information for different cities. The given code snippet sets up the collection view and registers custom cell and header classes. Your task is to create a custom collection view layout that displays the weather... | codefeedback |
You are given a Python code snippet that defines a class `map` which inherits from `BlockTransformation`. The class has a docstring that describes its functionality and an attribute `_map` of type `Optional[Dict[int, int]]`. Your task is to implement a method within the `map` class that performs the block transformatio... | codefeedback |
You are tasked with implementing a simplified version of a forum post management system. The system should allow users to post new threads and optionally save them for later viewing. Each thread has a unique identifier and can be marked for saving.
You are provided with the following code snippet as a starting point:
... | codefeedback |
You are tasked with creating a program to generate a Look Up Table (LUT) for Absolute Humidity (AH) at 100% Relative Humidity (RH) based on temperature values. The AH at 100% RH is calculated using a function `calc_ah(t, rh)` where `t` represents the temperature and `rh` represents the relative humidity. The LUT should... | codefeedback |
You are tasked with implementing a task scheduling system in Java using the Spring framework. The system should allow for the scheduling and execution of various tasks. The `taskManager` bean has been provided, which exposes methods for starting the scheduling process and queuing tasks. You need to create a new task cl... | codefeedback |
You are tasked with creating a Python program that simulates a simple game where the player controls a character that can move around the screen. The player can move the character using the arrow keys and can exit the game by pressing the 'Esc' key or clicking the close button on the window.
Your task is to implement ... | 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. The game should consist of the following rules:
- Rock beats scissors
- Scissors beats paper
- Paper beats rock
Your program should prompt the user to input t... | codefeedback |
You are tasked with creating a TypeScript class that represents an account in a financial system. The class should have specific properties and methods to handle account-related data and operations. Your task is to implement the missing parts of the class based on the given code snippet.
The class should have the foll... | codefeedback |
You are tasked with implementing a validation error handling system for a web application. The system should provide a way to retrieve error messages based on error names and format multiple error messages into a single block of text.
You are provided with a code snippet that contains a method `GetByName` which retrie... | codefeedback |
You are tasked with creating a Python function that interacts with GitHub and Telegram APIs to retrieve and send information about a developer's repositories. The function should take in GitHub and Telegram tokens, as well as the Telegram chat ID, and perform the following tasks:
1. Retrieve the list of repositories f... | codefeedback |
You are tasked with implementing a class for identifying pileup jets in a particle physics simulation. Pileup jets are jets of particles that originate from additional proton-proton interactions in the same bunch crossing as the hard-scatter interaction. The class `PileupJetIdentifier` is responsible for identifying an... | codefeedback |
You are given a list of hexadecimal numbers representing time durations in a specific format. Each hexadecimal number corresponds to a time duration in minutes. Your task is to convert these hexadecimal numbers to their decimal equivalent and then calculate the total time duration in hours and minutes.
Write a functio... | codefeedback |
You are tasked with implementing a function to scale a given floating-point number to a specific range. The function should take a floating-point number and a range, and return the scaled value within the specified range. The scaling should be performed using the following formula: scaled_value = (input_value - min_inp... | codefeedback |
You are tasked with implementing an overuse detector for monitoring bandwidth usage in a real-time communication system. The provided code snippet is a part of the existing overuse detector implementation and includes relevant member variables and a method.
Your task is to complete the implementation of the `OveruseDe... | codefeedback |
You are tasked with implementing a simplified version of an asynchronous function for setting the owner of a contract in a blockchain environment. The provided code snippet is a part of a larger system that interacts with smart contracts on a blockchain. The `SetOwnerRequestAsync` method takes a `SetOwnerFunction` obje... | codefeedback |
You are given a string representing a pattern of braces, brackets, and parentheses. Your task is to determine if the pattern is valid, meaning that every opening brace, bracket, or parenthesis has a corresponding closing one in the correct order.
For example, the string "({})[]" is valid, while "({[})" is not.
Write ... | codefeedback |
You are tasked with implementing a simple prompt system for a command-line interface. The prompt system should support requesting and responding to prompts of different kinds.
You are provided with a code snippet from a Rust module that imports and uses components related to the prompt system. The `PromptRequester` an... | codefeedback |
You are tasked with implementing a Python module for a language model challenge. The module should support the core functionality for the challenge and define a class `Model` along with various utilities. The provided code snippet is a part of the module and imports specific classes from the `model` submodule.
Your ta... | codefeedback |
You are tasked with implementing a class `AddressComparator` that contains a method `areOverlapping` to compare two network addresses. The method should return `true` if the two addresses overlap, i.e., if they represent overlapping IP ranges or if one address is contained within the other. The method should return `fa... | codefeedback |
You are tasked with implementing a custom view modifier in Swift that applies a style modification to a radial segments view. The provided code snippet is a part of the implementation of the `RadialSegmentsStyleWrapper` view modifier. Your task is to complete the implementation of the `RadialSegmentsStyleWrapper` and c... | codefeedback |
You are given a Python function that takes in a list of integers and returns the maximum sum of a contiguous subarray within the input list. Your task is to complete the function by implementing the algorithm to find the maximum sum of a contiguous subarray.
The function signature is:
```python
def max_subarray_sum(ar... | codefeedback |
You are tasked with implementing a custom property wrapper in Swift that enforces a maximum length constraint on the wrapped value. The property wrapper should truncate the value to the specified maximum length if it exceeds it. Your task is to complete the implementation of the `MaxLength` property wrapper and apply i... | codefeedback |
You are tasked with creating a parallel computing program to calculate the sum of a large array of numbers using MPI (Message Passing Interface). The program should be able to scale efficiently with an increasing number of processes.
Your task is to implement a parallel sum calculation program using MPI in C. The prog... | codefeedback |
You are tasked with creating a Python function that processes and analyzes COVID-19 data from different regions and states. The function should take a list of dictionaries as input, where each dictionary represents COVID-19 data for a specific region and state on a given date. The function needs to perform the followin... | codefeedback |
You are tasked with implementing a simple parameter loader for a machine learning framework. The parameter loader is responsible for initializing and managing a buffer of floating-point values used as parameters in a neural network.
Your task is to create a Swift class that conforms to the `ParameterLoader` protocol p... | codefeedback |
You are tasked with implementing a neural network training loop with different inference methods for a Bayesian neural network (BNN). The code snippet provided sets some initial configuration parameters for the training loop. Your task is to complete the training loop for each inference method and evaluate the performa... | codefeedback |
You are tasked with creating a command-line tool for running unit tests on a software project. The tool should support multiple subcommands and their respective functionalities. Your task is to implement the functionality for the "test" command, which has subcommands for "help", "nose", "pytest", and "tox".
The "test"... | codefeedback |
You are tasked with implementing a password hashing and verification system using the provided code snippet as a reference. Your goal is to create a class that provides methods for hashing passwords and verifying them against their hashes.
You need to implement a PHP class with the following methods:
```php
class Pass... | codefeedback |
You are tasked with implementing a hill climbing algorithm to optimize a given function. The hill climbing algorithm is a heuristic search algorithm used for mathematical optimization problems. In this problem, you are required to implement the hill climbing iteration, acceptance criteria, and consideration steps.
The... | codefeedback |
You are tasked with creating a program that simulates a simple scene configuration system for a user interface. The program should allow users to define and select different configurations for creating new scenes. Each configuration consists of a name and a session role.
Your task is to implement a class `UISceneConfi... | codefeedback |
You are tasked with implementing a custom iterator in C# that processes a sequence of values and performs a specific operation on each value. The iterator will be responsible for iterating through the values and applying the operation defined by the `DefinedValues` array.
Your task is to complete the implementation of... | codefeedback |
You are tasked with implementing a simplified version of a routing system for an HTTP server. The provided code snippet is a part of a Java-based HTTP server framework. The `route` method is used to define routes for the server through the provided `HttpServerRoutes` builder. The `HttpServerRoutes` builder allows the d... | codefeedback |
You are tasked with implementing a validation system for a JSON schema. The system should be able to handle various types of errors and provide detailed information about the validation failures.
Your task is to create a Rust function that processes validation errors and constructs a detailed error message based on th... | codefeedback |
You are tasked with implementing a Python function that calculates the total number of unique words in a given text file. The function should ignore case sensitivity and consider any non-alphanumeric characters as word delimiters. Additionally, the function should exclude any common English stop words (e.g., "the", "an... | codefeedback |
You are given a code snippet that contains a series of constraints being applied to various UI elements in a mobile application. Your task is to write a function that parses this code snippet and extracts the constraints being applied to each UI element.
Write a function `parseConstraints(code: String) -> [String: [St... | codefeedback |
You are tasked with implementing a simple transaction processing system. The system should be able to handle deposits, withdrawals, and provide the account balance after each transaction. The transactions are represented as a list of dictionaries, where each dictionary contains the transaction type ('deposit' or 'withd... | codefeedback |
You are tasked with implementing a function that processes a message header and returns an adjusted size value based on certain conditions. The function takes an integer `errno` and a buffer `header` as input. The code snippet provided is a part of the function and shows some operations performed on the return value `r... | codefeedback |
You are tasked with implementing a Tic-Tac-Toe game in Python. The game will be played between two players, X and O, on a 3x3 grid. The game should have a method to play a turn, which takes the position (1-9) where the player wants to place their mark. The method should return 0 if the move is valid and the game contin... | codefeedback |
You are tasked with implementing a custom class that inherits from the `ndarray` class in Python's NumPy library. The provided code snippet serves as a starting point for the implementation. Your task is to complete the custom class by adding specific functionality and ensuring that it behaves as expected when used in ... | codefeedback |
You are tasked with implementing a password validation system for a user class in Python. The user class has a method `set_password` that takes a password as input and sets it for the user. The password must adhere to the following rules:
1. It must be at least 8 characters long.
2. It must contain at least one upperca... | codefeedback |
You are tasked with creating a Python class for training and evaluating a neural network model to calculate propensity scores for a medical treatment dataset. Propensity scores are used to estimate the causal effect of a treatment by balancing the distribution of observed covariates between treated and control groups. ... | codefeedback |
You are tasked with implementing a function to compare two streams of data and determine if they are equal. The streams are represented as `std::stringstream` objects in C++. The function should return `true` if the streams are equal and `false` if they are not.
Your task is to implement the `compare_streams` function... | codefeedback |
You are tasked with creating a function that processes user updates and photo uploads in a user management system. The function `update` takes in various user details and a photo, and then makes an HTTP request to update the user information. If a photo is provided, it is also processed. Your task is to implement the l... | codefeedback |
You are tasked with creating a program that processes Excel spreadsheets and applies formatting to specific cell ranges. Your program should utilize the Laravel Excel package, which provides an event-driven architecture for manipulating Excel files. The given code snippet is a part of a Laravel Excel event listener tha... | codefeedback |
You are tasked with implementing a neural network using the Haiku library in JAX. The given code snippet is a part of a larger neural network definition and shows the usage of the `hk.Conv2D` layer, the `jax.nn.relu` activation function, and the `hk.Flatten` layer. Your task is to complete the neural network definition... | codefeedback |
You are tasked with creating a script to unpack keys from a JSON file and perform specific actions based on the extracted data. The JSON file contains information about keys, including the associated user and group. Your task is to write a Bash script that accomplishes the following:
1. Check if the JSON file is empty... | codefeedback |
You are tasked with implementing a steganography algorithm to hide a message within an image. Steganography is the practice of concealing a message within another non-secret file or message in a way that the existence of the hidden message is undetectable. In this case, you will be hiding a message within the RGB value... | codefeedback |
You are tasked with implementing a bingo game simulator in Rust. The game involves drawing numbers from a pool and marking them on a bingo card. The bingo card is represented as a 5x5 grid, with the center cell marked as "FREE". The numbers drawn are in the range of 1 to 75, and each column of the bingo card correspond... | codefeedback |
You are tasked with creating a web application that allows users to manage announcements. The code snippet provided is a part of the user interface for deleting an announcement. The snippet includes an HTML-like syntax with a custom tag `<x:heroicon-o-trash>` representing an icon for the "Delete announcement" action. A... | codefeedback |
You are tasked with creating a Python function that validates and processes a list of positive integers. The function should raise a custom exception if any non-positive integer is encountered in the list. Additionally, the function should return a new list containing the square of each valid positive integer.
Your ta... | codefeedback |
You are tasked with implementing a custom exception handling mechanism for a simple file processing program. The program is expected to read data from a file, perform some operations, and then write the results to another file. Your task is to handle potential exceptions that may occur during the file processing and pr... | codefeedback |
You are tasked with creating a Python program to visualize data using Matplotlib. The program should take input from the user to customize the plot appearance and display the data in a visually appealing manner.
Your program should include the following functionalities:
1. Accept user input for the type of plot to be ... | codefeedback |
You are tasked with implementing a function to simplify a 3D mesh representation using the Douglas-Peucker algorithm. The input to the function is a list of vertices and a list of faces, where each face is represented by the indices of its vertices. The function should simplify the mesh by reducing the number of vertic... | codefeedback |
You are tasked with creating a step counter application for iOS using Swift. The application should utilize the Pedometer sensor to track the user's steps and display the step count on the screen. The Pedometer sensor provides data about the number of steps taken by the user.
Your task is to implement a function that ... | codefeedback |
You are given a list of 2D points representing the coordinates of various locations on a map. Your task is to write a function that calculates the distance between each pair of points and returns a matrix of distances.
Create a function `calculate_distances(points)` that takes in a list of tuples `points`, where each ... | codefeedback |
You are tasked with implementing a tracking system for attributes in a Python program. The system should identify and track the usage of specific attributes within the program. The attributes to be tracked are denoted by comments in the code, using the format `$tracked=attr` or `$tracked tracked=attr`. The first format... | codefeedback |
You are tasked with implementing a generic tree traversal function in C++. The function `treeNode` takes in a branch node, a command for the traversal, and the start and end indices for the traversal. The `BranchNodeSO` is a template class representing a branch node in a tree, and `WalkCmd` is an enum representing diff... | codefeedback |
You are tasked with creating a command-line tool to automate the process of pushing a podspec file to a private CocoaPods repository. The tool should handle various options and provide verbose output while allowing warnings during the push process.
Your task is to implement a Python script that takes in the necessary ... | codefeedback |
You are tasked with implementing a class method for a grade calculator. The method `weight_average` takes a list of grades `v` and calculates the weighted average of the grades based on the credits associated with each grade. The class has attributes `owned_grades`, `owned_credits`, and `tot_credits` representing the g... | codefeedback |
You are tasked with implementing a function to calculate the value of a mathematical expression based on the given code snippet. The code snippet initializes some variables and calls a function to set the number of perturbations. Your task is to write a function that uses the initialized variables to compute the value ... | codefeedback |
You are tasked with implementing a Python function that converts the result of an SQL query into a JSON array. The function should take a list of parameters as input and return an array containing JSON strings.
The function signature and documentation are provided in the following code snippet:
```python
"""
| ##@函数目的... | codefeedback |
You are tasked with creating a Python function that reads a configuration file and extracts specific information from it. The configuration file follows the INI file format, which consists of sections, keys, and values. Each section is denoted by square brackets, and each key-value pair is separated by an equal sign.
... | codefeedback |
You are working on a 3D graphics engine and need to implement a class for managing mobile objects in a 3D space. The provided code snippet includes part of the implementation for the mobile object class. Your task is to complete the implementation of the `MobileObject` class by adding methods for rotation and scaling, ... | codefeedback |
You are given a sequence of integers `seq` and a substitute value `sub_value`. Your task is to write a function `substitute_sequence(seq, sub_value)` that generates a new sequence `out1` by substituting elements of `seq` with `sub_value` under the following conditions:
1. The length of the substituted sequence should b... | codefeedback |
You are tasked with creating a Python function to train a reinforcement learning agent using the Advantage Actor-Critic (A2C) algorithm for a Snake game environment. The A2C algorithm is a popular reinforcement learning technique that combines value-based and policy-based methods for training agents in environments wit... | codefeedback |
You are working on a system that involves manipulating and signing image files using a tool called BPAK and then booting the signed image using a tool called PB. Your task is to write a script that automates this process.
Given the provided code snippet as a reference, write a script in Bash that performs the followin... | codefeedback |
You are tasked with implementing a custom scope management system for a programming language. The system should handle entering and exiting different scopes and keeping track of the current scope.
You are given a code snippet from a visitor class that traverses a CSS abstract syntax tree (AST). The `enterMixinDefiniti... | codefeedback |
You are tasked with implementing an `EmailPredicate` class that validates email addresses based on the following criteria:
1. The email address must contain a local part and a domain part separated by an "@" symbol.
2. The local part can contain letters, digits, and the following special characters: ! # $ % & ' * + - /... | codefeedback |
You are tasked with creating a program to solve the graph coloring problem using a backtracking algorithm. The graph coloring problem involves assigning colors to vertices of a graph in such a way that no two adjacent vertices have the same color. The given code snippet is a sequence of commands that compiles and runs ... | codefeedback |
You are working on a data processing library in Rust and need to implement a method for converting a data series to a new series containing the minimum and maximum values from the original series. The input series can contain numeric or UTF-8 data types. You need to handle the conversion and potential errors that may a... | codefeedback |
You are tasked with implementing a markdown parser function in TypeScript. The function should take a markdown string and an optional set of parsing options, and return a Promise resolving to the parsed HTML string.
You are provided with the following interface for the markdown parser function:
```typescript
interface... | codefeedback |
You are given a code snippet that initializes an array `count` with zeros, and then iterates through a dictionary to extract key and value numbers from strings. Your task is to write a function that takes a dictionary and returns the total count of entries in the dictionary, along with the sum of all key and value numb... | codefeedback |
You are tasked with creating a Java program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. The accounts and their transactions should be stored in memory.
Your task is to implement the `BankingSystem` class, which should h... | codefeedback |
You are tasked with creating a program that extracts and processes URLs from a given input string. Your program should take a string as input and identify all the valid URLs within the input. A valid URL should start with "http://" or "https://" and may be followed by any combination of alphanumeric characters, dots, s... | codefeedback |
You are given a set of 3D points represented as (x, y, z) coordinates. Each point is represented as a triplet of integers. Your task is to write a program to calculate the distance between all pairs of points and find the pair of points with the maximum distance between them.
Write a function `max_distance_between_poi... | codefeedback |
You are tasked with implementing a Python function that generates a list of all possible combinations of a given list of items. The function should take a list of items as input and return a list of lists, where each inner list represents a unique combination of the input items.
The function signature should be:
```py... | codefeedback |
You are given a string containing HTML tags. Your task is to write a function that removes all HTML tags from the string and returns the resulting plain text.
Write a function:
```python
def remove_html_tags(html: str) -> str:
pass
```
The function should take a single parameter:
- `html` (1 <= len(html) <= 10^5)... | codefeedback |
You are tasked with implementing a simplified version of a stack-based job execution system. The system consists of a `StackJob` struct, a `LockLatch` struct, and a `JobRegistry` struct. The `StackJob` struct represents a job to be executed, the `LockLatch` struct is used for synchronization, and the `JobRegistry` stru... | codefeedback |
You are tasked with implementing a data structure that efficiently stores a batch of states and their corresponding hash values. The data structure should have a method to submit new states and update their hash values. Additionally, it should have a method to retrieve the current batch of states and their hash values.... | codefeedback |
You are tasked with implementing a function to retrieve the supported input method styles for an X11 input method in a C++ environment. The provided code snippet outlines the declaration of the function `get_supported_styles`, which takes an `sge::x11input::xim::method` object as a parameter and returns a `supported_st... | codefeedback |
You are tasked with creating a Python function to parse network speed test output and extract the ping time, download speed, and upload speed. The network speed test output is a string containing the ping time, download speed, and upload speed in various formats. The ping time is in milliseconds (ms), and the download ... | codefeedback |
You are tasked with implementing a Python function that calculates the factorial of a given non-negative integer using recursion. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 5 (denoted as 5!) is 5 * 4 * 3 * 2 * 1 = 120.
Your t... | codefeedback |
You are tasked with implementing a Python class that manages supervisor nodes in a distributed system. The provided code snippet is the beginning of a class definition for `SupervisorManager`, which is a subclass of `NodeManager`. The `SupervisorManager` class is responsible for managing supervisor nodes, which are use... | codefeedback |
You are tasked with implementing a function to retrieve data from a PostgreSQL database using Rust's async/await syntax. The provided code snippet is a part of an asynchronous Rust program that uses the `tokio-postgres` library to interact with a PostgreSQL database.
The `pool` variable represents a connection pool to... | codefeedback |
You are tasked with implementing a convex hull algorithm for a 2D point set. The convex hull of a set of points is the smallest convex polygon that contains all the points. One common algorithm for finding the convex hull of a set of points is the Graham scan algorithm.
Your task is to implement the `GrahamScan` class... | codefeedback |
You are tasked with implementing a thread-safe database connection holder class in Java. The class should manage a single database connection and provide methods for acquiring and releasing the connection safely. The class should also ensure that the connection is only created once and reused across multiple threads.
... | codefeedback |
You are tasked with creating a program that simulates a simple command-line utility for managing a list of tasks. The program should support adding tasks, marking tasks as completed, and listing all tasks. The tasks should be stored in memory and should not persist beyond the program's execution.
Your program should s... | codefeedback |
You are tasked with implementing a function that simulates a simple file transfer protocol. The protocol involves sending and receiving files between a client and a server. The server is already set up and running, and it exposes two methods: `QueryInterface` and `GiveFeedback`. The `QueryInterface` method is used to e... | codefeedback |
You are tasked with designing a user management system for a software application. The system should support three types of users: Gold users, Guest users, and Normal users. Each user type has specific attributes and behaviors associated with it.
The code snippet provided imports classes related to user pools and user... | codefeedback |
You are tasked with creating a Python function that performs a specific binary file manipulation. The function, `binary_hook`, takes two arguments: `binf` (the input binary file) and `outf` (the output binary file). The function reads the contents of the input binary file, appends it to a specific section of another bi... | codefeedback |
You are working on a quantum computing project and need to implement a function to manipulate quantum states. The function takes in three parameters: `p`, `n`, and `c`. The parameters `p` and `n` are positive integers representing the prime number and the dimension of the finite field, respectively. The parameter `c` i... | codefeedback |
You are given an array of integers representing the heights of a series of buildings. Your task is to write a function to calculate the amount of rainwater that can be trapped between the buildings after a rainstorm. The water is trapped within the gaps between the buildings, and it is assumed that the width of each bu... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of the `run_get_node` function used in the given code snippet. The `run_get_node` function is responsible for executing a `CreateEvaluateWorkChain` workflow by chaining two basic processes and returning the result and node. Your task is to imple... | codefeedback |
You are tasked with implementing a function that constructs a window and a graphics context for a simple 2D game using the `winit` and `glutin` libraries in Rust. The provided code snippet initializes the window builder and context builder, setting specific OpenGL version and profile requirements.
Your task is to comp... | codefeedback |
You are tasked with creating a custom deserializer for a specific data type in Rust. The data type in question is a URI (Uniform Resource Identifier), which is a string that identifies a resource. The deserializer needs to take a string representation of a URI and convert it into a valid `Uri` type. The `Uri` type is n... | codefeedback |
You are tasked with creating a TypeScript interface for an authentication service in a web application. The interface should define the structure of the authentication services, including properties for labels, headers, descriptions, and profiles. Your task is to define the interface based on the given code snippet and... | codefeedback |
You are working on a text editor application that supports the undo feature. The code snippet provided is a part of the implementation for handling transactions in the editor. The `tr.setMeta('addToHistory', false)` call is used to indicate that the transaction should not be added to the history, and `this.dispatchTran... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.