instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a command-line tool for managing package recipes using the Conan package manager. The tool should support various options for building and uploading packages. Your task is to create a Python script that utilizes the `argparse` module to parse command-line arguments and perform the neces... | codefeedback |
You are tasked with creating a Rust module for handling MIDI data. Your module should provide functionality for parsing and processing MIDI messages. MIDI messages are structured as a series of bytes, with each message type having a specific format. Your task is to implement a Rust module that can parse and process MID... | codefeedback |
You are tasked with simulating the behavior of a simplified system that manages the configuration and manipulation of devices using a microcontroller. The system consists of a series of commands executed via a remote shell connection to a microcontroller, as well as local shell commands. Your goal is to implement a fun... | codefeedback |
You are tasked with creating a Python program that simulates a simple car racing game using the `pygame` library. The game will involve a player-controlled car navigating through a track while avoiding obstacles. The player's score will be based on the distance traveled without hitting any obstacles.
Your task is to i... | codefeedback |
You are tasked with implementing a custom authorization attribute in an ASP.NET Core application. The attribute should restrict access to a specific role and a set of privileged IP addresses. You are provided with a code snippet from a base controller that sets up the role-based authorization. Your task is to extend th... | codefeedback |
You are tasked with creating a Python class that manages URL redirections for a web application. The class, `RedirectManager`, should have the following functionalities:
1. Method `save_entry(url: str, redirect_to: str)`: This method should save a new entry for URL redirection. It takes two parameters: `url` (the orig... | codefeedback |
You are tasked with implementing a simplified version of a dependency injection container. In this problem, you will create a class `DependencyInjectionContainer` that can manage observer methods and contexts.
Your task is to implement the following methods in the `DependencyInjectionContainer` class:
1. `void addObs... | codefeedback |
You are tasked with creating a multithreaded program that simulates a simple ticketing system for a movie theater. The program should use Rust's standard library for synchronization and threading.
Your program should have the following requirements:
1. The movie theater has a limited number of seats, which should be r... | codefeedback |
You are tasked with creating a Python function to validate and process a set of parameters for adding a node to a UK8S cluster. The function should take in a dictionary of parameters and perform the following validations and processing steps:
- Ensure that the required parameters "ClusterId", "Password", and "UHostId"... | codefeedback |
You are tasked with creating a program that utilizes the `ApiHelper` class to retrieve and process JSON data from a given URL. The `ApiHelper` class contains a method `GetJsonString` that takes a URL as input and returns the JSON data as a string. Your task is to create a program that uses this method to fetch JSON dat... | codefeedback |
You are working on a quantum computing project and need to implement a class for handling fermionic operators. Your task is to create a Python class that extends the `FermionSumOperators` class from the `netket` library. The class, named `AbInitio`, should be initialized with a Hilbert space `hi`, a one-body matrix `on... | codefeedback |
You are tasked with creating a program that simulates the inclusion of files in a web development project. In this scenario, the code snippet provided is from a web development project using a templating system. The `@include` directive is used to include the content of another file at the specified location. The inclu... | codefeedback |
You are tasked with creating a middleware function for a Node.js web application using Express.js. The middleware function should check if a user is authenticated before allowing access to certain routes. You are provided with a code snippet that sets up a router and applies the `isAuthenticated` middleware to the root... | codefeedback |
You are tasked with implementing a custom dropdown component in a React application. The dropdown component should utilize a context to manage its state and provide functionality for other components to interact with it. The provided code snippet defines the context for the dropdown component.
Your task is to create a... | codefeedback |
You are tasked with creating a program that simulates a simple drawing application. The application should allow users to draw basic shapes such as rectangles, circles, and lines on a canvas. Additionally, the program should provide the functionality to select, move, and delete the drawn shapes.
To achieve this, you n... | codefeedback |
You are tasked with implementing a simple token matching system for a lexer. The provided code snippet contains two methods of a `TokenMatcher` struct: `is_match` and `find`. The `is_match` method checks if any of the rules in the `TokenMatcher` match the given text, while the `find` method returns the first matching r... | codefeedback |
You are tasked with creating a Python function that processes command-line arguments and generates a configuration for a data redirection tool. The function should take the command-line arguments, parse them using a utility function, and then construct a configuration dictionary based on the parsed arguments. The confi... | codefeedback |
You are tasked with implementing a function to transform a given input of type `BTreeMap<i32, Vec<char>>` into a `BTreeMap<char, i32>`. The input map contains integer keys and corresponding lists of characters as values. Your goal is to create a new map where the characters become keys and the counts of each character ... | codefeedback |
You are tasked with creating a Python function that processes and sends training session details to a chat bot. The function should take in the training session details, format them into a message, send the message to the chat bot, and return a value. However, if an exception occurs during the process, the function sho... | codefeedback |
You are tasked with creating a Python class that represents a backend module for quantum computing. The backend module should be able to perform quantum operations and provide information about its capabilities. Your task is to implement the abstract base class for the backend module, ensuring that the required backend... | codefeedback |
You are tasked with implementing a Graph Isomorphism Network (GIN) in Python. GIN is a type of neural network designed to operate on graph-structured data. The given code snippet provides a partial implementation of a GIN model using PyTorch. Your task is to complete the implementation of the GIN model by defining the ... | codefeedback |
You are tasked with implementing a program to process and display a series of points on a 2D plane. Each point is represented by a set of parameters, and your program needs to format and print these points according to a specific template.
The template for each point is as follows:
```
'1 4 0 1 0 0 50 -1 20 0.000 1 0.... | codefeedback |
You are given a directed graph `g` and a set of nodes `vrs`. The code snippet provided is intended to remove the nodes in the set `vrs` from the graph `g_allowed` and `g`. However, the snippet is incomplete and lacks the necessary context to understand the problem fully. Your task is to complete the code snippet by wri... | codefeedback |
You are tasked with implementing a Rust program to fetch system information using the `susfetch` library. The `SusFetch` struct represents system information, and the `default` method is used to initialize it by fetching various system details. Your task is to complete the implementation of the `SusFetch` struct and it... | codefeedback |
You are tasked with implementing a function that processes a dictionary and outputs a formatted string based on the given delimiter. The function should take in three parameters: a dictionary `var`, a string `delimiter`, and a string `trans_delimiter`. The dictionary `var` contains key-value pairs, where the keys are s... | codefeedback |
You are tasked with implementing a Python class method that converts an Abstract Syntax Tree (AST) node into an assignment statement. The AST represents the structure of a Python program and is commonly used for code analysis and transformation.
Your task is to complete the `from_ast` method within a Python class. The... | codefeedback |
You are tasked with implementing a custom pass for an intermediate representation (IR) in a compiler infrastructure. The IR is represented using the FEXCore library, which provides functionalities for managing the IR and emitting instructions.
Your task is to create a pass that performs a specific transformation on th... | codefeedback |
You are tasked with creating a custom Babel plugin that performs a specific transformation on JavaScript code. The plugin should identify and transform specific patterns within the code. Your goal is to implement the transformation logic for the plugin.
You are provided with a code snippet that sets up the testing env... | codefeedback |
You are tasked with implementing a Huffman coding algorithm to compress and decompress text data. Huffman coding is a widely used algorithm for lossless data compression. In this problem, you will create a program that reads a text file, constructs a Huffman tree based on the frequency of characters in the file, and th... | codefeedback |
You are tasked with implementing a Java class that models a modular minecart system. The provided code snippet is a simplified version of the `ModuleStandard` class, which extends a base class and overrides a method to calculate energy consumption. Your task is to complete the implementation of the `ModuleStandard` cla... | codefeedback |
You are tasked with creating a command-line utility that processes input files and generates output files based on specific commands and options. Your program should be able to handle various command-line arguments and perform the required operations on the input files to produce the desired output.
Your task is to im... | codefeedback |
You are tasked with creating a Python class that can parse and manipulate Jenkins credentials stored in XML format. Your task is to implement a method within the class that can extract the username and password from the given XML snippet and return them as a dictionary.
You are provided with a code snippet that define... | codefeedback |
You are tasked with implementing a function that automatically sets the height of UITableViewCells in a UITableView. The function should take into account the content within the cells and adjust the height dynamically. You are given a code snippet from a UIViewController's `viewDidLoad` method, which indicates that the... | codefeedback |
You are tasked with implementing a simplified version of a templating engine's node class in TypeScript. The provided code snippet is a part of a TypeScript project for a templating engine, and it includes a class definition for `InlineIf` that extends the `NunjucksNode` class.
Your task is to complete the implementat... | codefeedback |
You are tasked with creating a Python function that retrieves and processes data from a website. The function should take an ID as input and use it to make a GET request to a specific URL. The response from the website will be in HTML format, and the function should parse this HTML to extract relevant information.
You... | codefeedback |
You are tasked with implementing a Python class that processes image data from a ROS (Robot Operating System) environment. The provided code snippet initializes a ROS node and sets up a publisher and subscriber for specific topics. Your task is to complete the implementation of the `StarterNode` class by adding the `im... | codefeedback |
You are tasked with implementing a Python function that calculates the optimal transport cost matrix for a given set of source and target data points. The optimal transport problem is a mathematical optimization problem that deals with finding the most efficient way to transport a distribution of mass from one set of p... | codefeedback |
You are tasked with implementing a class for creating and manipulating Bezier curves in a 2D space. The class should provide methods for setting control points, evaluating the curve at a given parameter value, and updating the curve's visual representation.
Your task is to implement the `BezierCurve` class with the fo... | codefeedback |
You are tasked with implementing a Python class that extends a base class and adds functionality for handling file upload results. The base class `BaseModel` is provided by the `asposehtmlcloud` library. Your task is to create a new class `FilesUploadResult` that inherits from `BaseModel` and adds specific attributes a... | codefeedback |
You are tasked with implementing a simulated annealing (SA) optimization algorithm to maximize a given objective function. Simulated annealing is a probabilistic optimization technique used to find the global optimum in a large search space. The algorithm starts with an initial solution and iteratively explores the sol... | codefeedback |
You are tasked with implementing a function to calculate the width of a given string or attributed string when rendered with a specific font size. The function should take into account the possibility of the input being either a regular string or a rich text attributed string.
You are given the following function sign... | codefeedback |
You are tasked with implementing a function to manage a list of alarms in a mobile application. The provided code snippet includes a function `localRead` and a static method `fromLocal` within a class or struct named `Alarms`. The `localRead` function is responsible for parsing a JSON string retrieved from local storag... | codefeedback |
You are given a 2D matrix of integers representing the elevation map of a region. Each cell in the matrix represents the height of the land at that position. Your task is to write a function to determine if a cell is a local minimum, meaning it is lower in elevation than its neighboring cells.
You need to implement th... | codefeedback |
You are tasked with implementing a class hierarchy for a cloud service management system. The system includes classes for users, virtual machines, and cloud providers. Your task is to create the necessary classes and methods to represent these entities and their relationships.
You are provided with a code snippet that... | codefeedback |
You are tasked with creating a Python function that simulates a simple authorization system for accessing training tests in an educational application. The function should check if the user is authorized to access the training tests and then allow or deny access accordingly.
You are given the following code snippet as... | codefeedback |
You are given an array of integers representing the scores of a game. The game is played by two players, and they take turns to make moves. In each move, a player can choose to remove any one element from either end of the array. The player's score increases by the value of the removed element. The game continues until... | codefeedback |
You are tasked with creating a Python program that processes a directory of files and organizes them based on their last modified date. Your program should move files from the source directory to destination directories based on the year and month of their last modified date. For example, if a file was last modified in... | codefeedback |
You are tasked with creating a Python class to manage a history of counts and timestamps. Your class should have the following functionalities:
1. Initialize the history with an initial count and timestamp.
2. Update the history with a new count and timestamp.
3. Retrieve the latest count and timestamp from the histor... | codefeedback |
You are tasked with implementing a class hierarchy for a data loader system. The system is designed to read various types of data from different sources. Your task is to create a class `ScalarReader` that inherits from the abstract class `IReader` and implements the functionality to read a single float, int, str, or ot... | codefeedback |
You are given a string `a` of length `n`. Your task is to write a function or method to find the length of the shortest non-empty prefix of `a` that repeats to form the entire string `a`. If no such prefix exists, return -1.
Write a function:
```cpp
int shortestRepeatingPrefix(string a);
```
**Input**
The input consis... | codefeedback |
You are tasked with creating a Python script that manages the organization of files into folders based on their file extensions. Your script should take a directory path as input and then create subfolders for each unique file extension found within that directory. For example, if the input directory contains files wit... | codefeedback |
You are tasked with creating a Python program that processes a given text file and performs specific operations on the content. The program should read a text file, extract certain information, and then display the processed data in a user-friendly format.
Your task is to implement a Python program that accomplishes t... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of each unique word. The program should ignore punctuation and treat uppercase and lowercase letters as equivalent. Additionally, the program should exclude common English stop words such as "the," "and," "of," etc., from th... | codefeedback |
You are tasked with implementing a function that calculates the total area covered by a set of rectangles on a 2D plane. Each rectangle is represented by its top-left corner coordinates (x, y) and its dimensions (width, height). The function should take an array of rectangles as input and return the total area covered ... | codefeedback |
You are tasked with creating a Python program that retrieves data from a secure API endpoint using the `urllib` library. Your program should handle the HTTPS connection and include necessary headers for authentication. Additionally, the retrieved data should be processed and displayed in a specific format.
Your progra... | codefeedback |
You are given a Python code snippet that processes an image to create a heat map. The code uses nested loops to iterate over the pixels of the image and applies a distance-based calculation to update the heat map. Your task is to implement a function that encapsulates this image processing logic.
Write a function `gen... | codefeedback |
You are tasked with creating a Python script to automate the process of fixing directory permissions on a Unix-based system. The script should traverse through a given directory and its subdirectories, setting specific permissions for directories and files, and changing the group ownership of all files and directories ... | codefeedback |
You are tasked with creating a command-line tool that processes a Cypher query for a Neo4j database. The tool should accept various options and arguments to customize the query execution. Your task is to implement the logic to parse the command-line options and arguments, validate them, and process the Cypher query acc... | codefeedback |
You are tasked with creating a web application for an online store that sells various products. The application has two main sections: frontend for regular users and an admin section for managing products. The provided code snippet is a part of the backend logic for the frontend section. It retrieves product data from ... | codefeedback |
You are given a Rust struct representing a binary tree node. Your task is to implement a function that checks whether two binary trees are identical or not. Two binary trees are considered identical if they have the same structure and the same node values at each position.
The given Rust struct for the binary tree nod... | codefeedback |
You are tasked with implementing a SeriesCounter struct in Rust that represents a counter for a series of values. The SeriesCounter can be in one of three states: a specific value, an ongoing series denoted by "?", or an error state denoted by "<error>". Additionally, you need to implement the Display trait for the Ser... | codefeedback |
You are tasked with implementing a quest tracking system for a role-playing game. The system should handle quest objectives, progress tracking, and message notifications for the player. You are given a code snippet that represents part of the quest tracking logic. Your task is to complete the implementation of the ques... | codefeedback |
You are tasked with creating a function that simulates the behavior of a Jetstream Manager in a messaging system. The Jetstream Manager is responsible for managing streams, which are sequences of messages. Your task is to implement a function that interacts with the Jetstream Manager to perform various operations on st... | codefeedback |
You are tasked with implementing a Java program to model and manipulate nucleotides. A nucleotide is a molecule that serves as the basic building block of DNA and RNA. The provided code snippet is a partial implementation of a class `TypeIntegerNucleotide` that extends the abstract class `Nucleotide`. The `TypeIntegerN... | codefeedback |
You are tasked with implementing a function that processes a data structure representing an inline keyboard markup for a messaging platform. The provided code snippet is a part of the function and contains a section where the `callback_data` attribute is set to "splus". Your task is to complete the function by writing ... | codefeedback |
You are tasked with implementing a Python function to expand contractions in a given text. Contractions are shortened versions of words or syllables, often created by replacing certain letters with an apostrophe. For example, "can't" is a contraction of "cannot". Your function should take a string of text as input and ... | codefeedback |
You are tasked with creating a function to fetch and display data from a database table using the CodeIgniter framework. The given code snippet is a part of a CodeIgniter model class named `Md_ganti`. The `fetch_prodi` function is responsible for retrieving and returning data from the database table `ganti` joined with... | codefeedback |
You are working on a machine learning project and have been tasked with evaluating the performance of a trained model using various metrics. The model has been trained using training and validation data, and you need to calculate and display the metrics for both datasets. Additionally, you are required to log these met... | codefeedback |
You are tasked with implementing a generic function in Rust that takes a mutable reference to a struct's inner field and an argument, and returns a value. Your task is to define the function signature and implement the function using the given code snippet as a reference.
Your task is to:
1. Define the function signat... | codefeedback |
You are tasked with implementing a simple neural network using TensorFlow to classify handwritten digits from the MNIST dataset. The network should consist of an input layer, a hidden layer, and an output layer. You need to define the network's structure, implement the forward propagation to produce the output, define ... | codefeedback |
You are tasked with creating a shell script that generates a temporary working directory and sets up a trap to ensure the directory is removed when the script exits. Your script should also handle the case where the temporary directory creation fails.
Write a shell script that accomplishes the following:
1. Creates a ... | codefeedback |
You are tasked with implementing a template factory that can create templates for different programming languages. The `CreateTemplate` method takes in three parameters: `language` (a string representing the programming language), `template` (a string representing the template content), and `model` (an object represent... | codefeedback |
You are working as a DevOps engineer for a web application hosted on an Ubuntu server. Your task is to create a script that will start the web application as a background process and redirect its standard output and standard error to a log file. The web application is packaged as a JAR file and is located at `~/project... | codefeedback |
You are tasked with creating a Python class that acts as a generic SQL connector, capable of connecting to different types of SQL databases. The class should be able to establish a connection, execute SQL queries, and retrieve results. To achieve this, you need to implement the `SqlConnector` class with methods for con... | codefeedback |
You are tasked with implementing a web application feature that involves handling category deletion. The code snippet provided is a part of a PHP Laravel controller method responsible for deleting a category from the admin panel. The method uses the `redirect` function to redirect the user to the category management pa... | codefeedback |
You are tasked with implementing a function to decompress a memory buffer using the zlib library. The provided code snippet contains a function prototype and some initialization code for the zlib library. Your task is to complete the implementation of the `deflate_memory` function, which takes a source buffer and its l... | codefeedback |
You are tasked with creating a Python function that takes a list of integers as input and returns the maximum sum of a contiguous subarray within the input list. The function should efficiently handle both positive and negative integers.
You are provided with the following code snippet as a starting point:
```python
... | codefeedback |
You are tasked with implementing a parser for a simplified INI file format. INI files are configuration files that contain sections, each of which can hold key-value pairs. The code snippet provided is a part of a parser for an INI file format. The parser encounters different types of tokens while scanning the file, su... | codefeedback |
You are given a code snippet that attempts to estimate the value of π using a Monte Carlo method. The code snippet is incomplete and contains errors. Your task is to complete the code and fix the errors to correctly estimate the value of π.
The Monte Carlo method for estimating π involves randomly selecting points wit... | codefeedback |
You are tasked with creating a function that parses a given HTML string and extracts all the URLs present in the anchor (`<a>`) tags. The function should return an array of unique URLs found in the HTML string.
You are provided with a code snippet that represents a part of an HTML template. The HTML string may contain... | codefeedback |
You are given a Python code snippet that appears to be part of a program for traversing a 2D grid of characters. The code snippet contains a series of conditional statements that determine the movement direction based on the characters in the grid. Your task is to create a program that simulates the traversal of a 2D g... | codefeedback |
You are given a string `s` and a character `c`. Your task is to write a function `shortestToChar` that returns an array of integers representing the shortest distance from each character in the string to the nearest occurrence of the given character `c`.
The function signature is:
```cpp
std::vector<int> shortestToCha... | codefeedback |
You are tasked with creating a Python function that processes Jupyter notebook cells and converts specific cell types into Markdown format. The function should handle two different scenarios: one for converting a code cell with a specified heading level into Markdown, and another for converting a raw cell into Markdown... | codefeedback |
You are tasked with creating a Python program that simulates a simple color dictionary. The dictionary will store color names as keys and their corresponding RGB values as tuples. Your program should provide functionality to add new colors, update existing colors, retrieve RGB values for given color names, and remove c... | codefeedback |
You are tasked with creating a Python unit test for a scenario involving Azure App Service and Kubernetes. Your goal is to write a test case that ensures the correct behavior of a specific scenario within the AppserviceKubernetesScenarioTest class. The test should validate the functionality of the scenario under certai... | codefeedback |
You are given a list of integers representing the daily stock prices of a certain company. Your task is to determine the number of "increasing" days, where the stock price is higher than the previous day's price.
Write a function `count_increasing_days` that takes a list of integers `stock_prices` as input and returns... | codefeedback |
You are given a matrix `M` representing the friend relationships between students in a class. If `M[i][j] = 1`, then student `i` and student `j` are friends. The matrix is symmetric, meaning if `M[i][j] = 1`, then `M[j][i] = 1`.
Your task is to implement a function `findCircleNum` to find the total number of friend ci... | codefeedback |
You are tasked with developing a Python script for data ingestion from a Firestore database into a data processing pipeline. The script will utilize the provided credentials and configuration parameters to efficiently retrieve and process data from the Firestore database.
Given the following code snippet:
```python
CR... | codefeedback |
You are tasked with creating a Python program to manage a train center. The program should utilize threading to handle concurrent tasks and should also read configuration settings from a file. The configuration file is expected to contain settings for the admin module.
Your task is to implement the `start_train_center... | codefeedback |
You are given a list of strings representing file names. Each file name consists of a name and an extension separated by a dot. Your task is to write a function that groups the file names by their extensions and returns a dictionary where the keys are the extensions and the values are lists of file names with that exte... | codefeedback |
You are tasked with implementing a configuration class for a REST API in C#. The configuration class should have a protected property called `Configuration` of type `Sandbox2hireRestApiConfiguration`, with a private setter. Your task is to complete the implementation of the `Sandbox2hireRestApiConfiguration` class and ... | codefeedback |
You are tasked with creating a script to automate the preparation of parallel corpora for natural language processing tasks. The script should handle the setup of the environment, networking, and execution of specific commands.
Your script should take the following parameters:
- `LANG`: The language setting for the en... | codefeedback |
You are tasked with creating a Python program that processes contact information from a file and generates an output contact file. The program should utilize command-line arguments for input and output file specifications.
Your program should accept the following command-line arguments:
- `--input FILE`: Specifies the... | codefeedback |
You are given a positive integer `n`. Your task is to write a function that takes `n` as input and returns the minimum number of operations required to make `n` equal to 1. The allowed operations are as follows:
1. If `n` is odd, you can subtract 1 from it.
2. If `n` is even, you can divide it by 2.
For example, if `n... | codefeedback |
You are tasked with implementing a custom Result type in Java that can represent either a success with a value or a failure with an error message. Additionally, you need to create a method to convert this Result type into a VoidResult type, which represents a result without a value. The VoidResult type should allow for... | codefeedback |
You are tasked with implementing a Python function that calculates the discrete Fourier transform (DFT) of a given input signal using the formula:
\[ X[k] = \sum_{n=0}^{N-1} x[n] \cdot e^{-i 2 \pi \frac{kn}{N}} \]
Where:
- \( X[k] \) is the k-th frequency component of the DFT
- \( x[n] \) is the input signal
- \( N \... | codefeedback |
You are tasked with creating a Python program that tokenizes a given input string based on a set of rules. The program should take a string as input and return a list of tokens based on the following rules:
1. Tokens are separated by spaces.
2. Tokens can be alphanumeric strings, but they cannot start with a digit.
3. ... | codefeedback |
You are given a snippet of code that represents a mathematical expression involving matrices. Your task is to write a function that can evaluate this expression and return the result. The matrices are represented as two-dimensional arrays, and the operations involved are multiplication and subtraction.
The given code ... | codefeedback |
You are given a string representing the status of a system. The status string consists of lowercase letters and may contain spaces. Your task is to write a function to determine the number of occurrences of each letter in the status string, ignoring spaces, and return the result as a dictionary where the keys are the l... | codefeedback |
You are tasked with creating a program that can parse and extract licensing information from a given source code file. The licensing information is typically found within comments at the beginning of the file. The format of the comments may vary, but they generally contain details such as the copyright holder, the year... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.