instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a generic data structure called `TypedVector` in Rust. The `TypedVector` should be able to store elements of any type and provide methods for adding elements, getting the length of the vector, and accessing elements by index.
Your task is to complete the implementation of the `TypedVec... | codefeedback |
You are working for a software company that develops a virtual switch (vswitch) module for networking purposes. The company uses Python for packaging and distributing its vswitch module. The code snippet provided is a simplified version of the setup script used to package and install the vswitch module. The `setup` fun... | codefeedback |
You are tasked with implementing a multi-threaded file processing system. The given code snippet is a part of a Python program that uses the `queue.Queue` class to process and write data from multiple threads to an output file. The `q` object is an instance of `queue.Queue` and is used to store partitions of data to be... | codefeedback |
You are tasked with implementing a union data structure in C++ to represent a set of different types. The union should allow for the inspection of the name of the active member without checking the value of the discriminator. The discriminator is a variable that indicates which member of the union is currently active. ... | codefeedback |
You are tasked with implementing a method to convert a given object to a string with each line indented by 4 spaces, except for the first line. The method signature is as follows:
```java
public String convertObjectToString(Object obj) {
// Your implementation here
}
```
The method should take an `Object` as inpu... | codefeedback |
You are tasked with implementing a data writing and flushing algorithm for a file system. The algorithm takes into account the delay between writes, the number of writes between flushes and chunk size, and the total number of elements to write. The goal is to efficiently write data to a file while minimizing the number... | codefeedback |
You are tasked with implementing a data processing module for a computer vision application. The module is responsible for processing training and validation data pairs using various transformations and parameters. Your goal is to create a class or function that performs the necessary data processing based on the given... | codefeedback |
You are tasked with creating a Python function that generates a filename for a TV show scene file based on a given pattern and scene file metadata. The function should take into account the show name, season number, episode number, and whether to include leading zeroes for the season and episode numbers.
You are provi... | codefeedback |
You are tasked with implementing a logging system for a software application. The system should log data from various functions and classes within the application. The provided code snippet is a simplified representation of a logging function for a specific class.
You are given a `func3Class` class with a member funct... | codefeedback |
You are given a list of 2D points represented as tuples of (x, y) coordinates. Your task is to write a function that calculates the angle (in degrees) between each point and a main reference point. The angle should be measured in the counter-clockwise direction from the positive x-axis to the line connecting the main r... | codefeedback |
You are tasked with implementing a migration script for a Judo club's member database. The club has decided to upgrade its database schema, and your task is to write a migration script to handle this upgrade. The existing code snippet provides the starting point for the migration script.
Your task is to complete the `... | codefeedback |
You are tasked with creating a Django web application that includes user authentication and media file serving. Your goal is to set up the necessary URL configurations and views to enable user login, logout, and media file serving.
Given the provided code snippet, you need to complete the following tasks:
1. Define th... | codefeedback |
You are tasked with creating a Python decorator that measures the execution time of a given function. Your decorator should be able to wrap any function and print the time taken for its execution. The decorator should be implemented using the provided code snippet as a starting point.
Your task is to implement the `ti... | codefeedback |
You are tasked with creating a program that simulates a parallel job execution system. The program should take a list of jobs and execute them in parallel, with a specified maximum number of concurrent jobs. The input will consist of a list of job files, each containing a set of commands to be executed. The program sho... | codefeedback |
You are tasked with optimizing the initialization process for a Python class by efficiently transferring the contents of a dictionary into the class attributes. Your goal is to implement a method that achieves this transfer in the fastest way possible.
You are given a Python class `FastInit` with the following initia... | codefeedback |
You are tasked with understanding and analyzing Swift Intermediate Language (SIL) code. SIL is an intermediate representation used by the Swift compiler during optimization and code generation. Your goal is to interpret and understand the SIL code snippet provided and explain its functionality.
Given SIL code snippet:... | codefeedback |
You are tasked with implementing a function to sort a list of features by priority based on their importance computation. The function should handle scenarios where feature importance computation comes from a mix of current and previous fit models, and some features are unevaluated.
You are given a code snippet that c... | codefeedback |
You are tasked with creating a script that validates the protocol used in a URL. The script should check if the protocol is either "http" or "https" and display an appropriate message based on the validation result.
Write a Bash script that takes a URL as input and performs the following steps:
1. Extract the protocol... | codefeedback |
You are tasked with implementing a custom attribute-based sorting mechanism for a collection of objects in C#. The given code snippet provides an enumeration of sorting options, each associated with a query parameter value. Your task is to create a custom attribute and a sorting method that can sort a collection of obj... | codefeedback |
You are tasked with implementing a function to initialize the weights of a neural network model and load pretrained weights if specified. The function should follow the given code snippet's logic and handle different cases for loading pretrained weights.
You are given the following code snippet as a reference:
```pyth... | codefeedback |
You are tasked with creating a Python function that calculates the average of the best-performing scheme based on a given set of results. The function should take a dictionary `results` as input, where the keys are scheme names and the values are dictionaries containing the scheme's results. Each scheme's results dicti... | codefeedback |
You are tasked with implementing a function to serialize a given `Log` struct into the Recursive Length Prefix (RLP) encoding format. The `Log` struct represents a log entry in Ethereum's blockchain and contains the address of the contract, log data, and topics.
The `Log` struct is defined as follows:
```rust
use bigi... | codefeedback |
You are tasked with implementing a custom view class in Swift that includes a title label. The provided code snippet is a part of the class implementation and shows the private method `initTitleLabel()` being used to initialize and configure the title label within the custom view. Your task is to complete the implement... | codefeedback |
You are given a directed graph represented as a list of vertices and their corresponding outgoing edges. Each vertex is represented by a list of outgoing edges. Your task is to implement a function that modifies the graph based on certain conditions.
You need to implement a function `modify_graph(graph: List[List[int]... | codefeedback |
You are tasked with creating a Rust library for managing various types of Uninterruptible Power Supplies (UPS). The library should provide a unified interface for interacting with different UPS devices through their respective communication protocols. To achieve this, you need to implement the necessary modules and str... | codefeedback |
You are tasked with implementing a custom iterator in Rust for a scheduling algorithm. The `ComputeSchedule` struct represents the schedule, and it contains a vector of `ComputeUnit` items and an index to keep track of the current position in the schedule. The `ComputeUnit` type is not explicitly defined in the given c... | codefeedback |
You are tasked with implementing a Python function that simulates the behavior of an asynchronous form validation process. The function should take in two parameters: `hass`, an object representing the Home Assistant system, and `interface_data`, a dictionary containing data for the interface. The function should use a... | codefeedback |
You are tasked with implementing a function to find the area of the largest rectangle formed by a histogram. Given an array of non-negative integers representing the histogram's bar height where the width of each bar is 1, the function should calculate the area of the largest rectangle that can be formed within the his... | codefeedback |
You are tasked with implementing a function to fetch and process news articles from a given source. The function should use the `requests` library to retrieve XML data from a specified URL, parse the XML using the `ElementTree` module, and then extract relevant information from the XML tree.
You are provided with a co... | codefeedback |
You are tasked with implementing a Python function that calculates the total light intensity at a specific point in a 3D space. The function will take into account the contributions from multiple light sources positioned at different offsets along the x-axis. Each light source is modeled as a positional light with a sp... | codefeedback |
You are tasked with implementing a configuration parser that can read and process configuration files in a specific format. The configuration files contain key-value pairs, where each key is a string and each value can be a string, integer, or boolean. The configuration file format is as follows:
```
# This is a commen... | codefeedback |
You are given a 2D board represented as a 2D array of integers, where each cell contains a non-negative integer value. The board represents a game where a player can move from cell to cell. The player can only move to adjacent cells (up, down, left, or right) and cannot visit the same cell twice in a single path. The g... | codefeedback |
You are tasked with creating a C# wrapper for a native library that provides image processing functionalities. The native library exposes a function `filament_Image_KtxBundle_GetSphericalHarmonics` through the `libfilament-dotnet` dynamic link library (DLL). Your goal is to create a C# method that can invoke this nativ... | codefeedback |
You are tasked with writing a script to automate the configuration process for installing a software package called "R." The script needs to handle different configurations based on the value of the environment variable `MACOSX_DEPLOYMENT_TARGET` and another variable `RFLAG`.
The script should execute the following st... | codefeedback |
You are tasked with implementing a custom string class in Objective-C that supports the creation of strings from various sources. Your task is to create a method `createString` that takes a source and encoding type and returns a new string object. The source can be a C string or another NSString object, and the encodin... | codefeedback |
You are tasked with creating a Python decorator that logs the execution time of a test method in a test suite. You will need to implement the decorator and apply it to a sample test method. The decorator should log the start and end time of the test method execution, along with the total time taken. You should also ens... | codefeedback |
You are given a code snippet representing a decision tree structure. Each block of code represents a decision node in the tree, and the conditions within each block determine the path to take based on the input object `obj` and its corresponding indices. The conditions are based on comparisons between elements of the `... | codefeedback |
You are tasked with implementing a simplified version of a protocol runner in Rust. The protocol runner is responsible for managing the state transitions of a blockchain protocol. The code snippet provided is a part of the match arm for handling a specific message in the protocol runner.
Your task is to implement the ... | codefeedback |
You are tasked with creating a program that extracts and processes information from HTML code to generate a summary of social media links and locations. The HTML code snippet provided represents a portion of a webpage's footer.
Your task is to write a function that takes the HTML code as input and returns a dictionary... | codefeedback |
You are tasked with creating a Python function that processes a given string to extract specific substrings based on predefined patterns using regular expressions.
You need to implement a function `extract_substrings` that takes in a string `input_string` and a list of patterns `pattern_list`. The function should use ... | codefeedback |
You are working on a game development project that involves a grid-based game board with various panels. Each panel can be moved in four directions: up, down, left, and right. The game provides a function `panelMove` that takes a string representing the movement commands for a panel. The commands are represented by the... | codefeedback |
You are tasked with implementing a Python function that performs a matrix projection operation. A matrix projection involves transforming a given matrix using a projection matrix. The projection matrix is a square matrix that, when multiplied with the input matrix, projects the input matrix onto a subspace defined by t... | codefeedback |
You are tasked with creating a simple web-based game where a user must click on a moving object to score points. The game will involve a plane (represented by an image) moving across the screen, and the user must click on the plane to score points. If the user misses the plane, an "X" mark will appear at the location o... | codefeedback |
You are working on a messaging bot application that processes different types of messages. The bot is designed to handle various types of data, such as passport data and poll data, and perform specific actions based on the message type. The bot uses the `telepot` library to handle incoming messages and extract relevant... | codefeedback |
You are tasked with implementing a secure token management system for an API data manager class in Swift. The `APIDataManager` class is responsible for handling API requests, and it needs to securely store and manage an app token. Your task is to create a secure mechanism to set and get the app token, ensuring that it ... | codefeedback |
You are tasked with creating a Python function that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player can move up, down, left, or right within the grid. The grid is represented as a 2D list, where each cell cont... | codefeedback |
You are tasked with creating a Python script that retrieves data from a given URL, parses it as XML, and writes the parsed data to a YAML file. Your script should take a URL as a command-line argument and perform the following steps:
1. Import necessary libraries: `requests`, `sys`, `datetime`, and `BeautifulSoup` fro... | codefeedback |
You are tasked with creating a program that utilizes the QGrain library to analyze and visualize grain size distribution data. The QGrain library provides functionality for processing and interpreting grain size distribution data, which is commonly used in geology, soil science, and material science.
Your program shou... | codefeedback |
You are tasked with creating a program to control a robotic arm using the OpenJigWare library. The robotic arm has multiple joints and can perform various movements. The OpenJigWare library provides functions to control the robotic arm's movements, such as rotating joints and gripping objects. Your task is to implement... | codefeedback |
You are tasked with implementing a custom HTTP adapter for a Python application. The adapter will be responsible for handling HTTP requests and responses in a specialized manner. Your goal is to create a class that can be used as an adapter for the `requests` library's `Session` object. The adapter should intercept and... | codefeedback |
You are tasked with creating a web scraping tool using Python and Selenium. Your goal is to scrape data from a website within a specified range of IDs. The website requires user authentication, and the scraping process should be initiated only after the user is logged in.
You are provided with a Django view function `... | codefeedback |
You are tasked with implementing a Python function that processes a list of values and returns a modified list based on the following requirements:
1. If the input list contains strings that represent boolean values ("yes", "true", "1", "no", "false", "0"), convert these strings to their corresponding boolean values.
... | codefeedback |
You are tasked with implementing a custom data serialization and deserialization mechanism for a web browser application using C++. The application uses the WebKit framework, and the serialization process involves encoding and decoding data references and string arguments.
Your task is to create a class that provides ... | codefeedback |
You are tasked with implementing a custom aggregation function for a graph neural network model. The model uses metapath convolution and PyTorch's GATConv for message passing. Your goal is to create a new aggregation function and integrate it into the model.
You are given a Python class `MetapathConv` that represents ... | codefeedback |
You are tasked with creating a Python function that processes a list of dependencies and generates a dependency graph. The dependency graph should represent the relationships between different dependencies, where each dependency is a node and the edges represent the dependencies between them. The input list contains tu... | codefeedback |
You are tasked with designing a Python class that manages job schemas for a job processing system. The job schemas are used to define the structure of different types of jobs that can be submitted to the system. Each job schema is represented as a Python class with specific attributes and methods.
Your task is to crea... | codefeedback |
You are tasked with creating a program that analyzes a given HTML file to identify and extract any JavaScript code enclosed within `<script>` tags. Your program should be able to handle multiple occurrences of `<script>` tags and extract the JavaScript code within them.
Write a function `extractJavaScript` that takes ... | codefeedback |
You are tasked with implementing a queue using two stacks. You are given the following code snippet as a starting point:
```csharp
public class QueueWithStacks
{
private Stack<int> _stack = new Stack<int>();
private Stack<int> _tmpStack = new Stack<int>();
public void Enqueue(int value)
{
_sta... | codefeedback |
You are tasked with creating a Python program that interacts with a MySQL database using the `mysql.connector` module. Your program should connect to the database, retrieve data from a specific table, perform a calculation on the retrieved data, and then update another table with the calculated result.
Your program sh... | codefeedback |
You are tasked with implementing a function to calculate the conversion error when converting an integer to a floating-point number. The function should take an integer representing the number of bits used to represent the integer and return the conversion error as a floating-point number.
You are given the following ... | codefeedback |
You are tasked with implementing a custom smart pointer in Rust. Smart pointers are data structures that act like pointers but also have additional metadata and capabilities. In this case, you need to implement the `DerefMut` trait for a custom smart pointer type.
The `DerefMut` trait in Rust is used to overload the d... | codefeedback |
You are tasked with implementing a function that parses restaurant data from a website using Python and the Beautiful Soup library. The function should extract specific information from the HTML of a restaurant page and return it in a structured format.
You are given the following code snippet as a starting point:
``... | codefeedback |
You are tasked with implementing a logging system in Swift. The provided code snippet is a part of a logging framework and defines a static method `warning` within a class. The `warning` method takes a message as input and logs it with a prefix "[WARNING]" using another method `log` with the log level `LogLevel.Warning... | codefeedback |
You are tasked with implementing a callback timer class in C++ that allows users to register callback functions and execute them after a specified time interval. The timer should support starting, stopping, and resetting, and it should be able to handle multiple concurrent timers.
Your task is to design and implement ... | codefeedback |
You are tasked with creating a Python script that simulates a simple server-client interaction. The server script (`ta3ta2.server`) and the client test script (`ta3ta2.test_server`) are provided. Your goal is to write a Python script that automates the process of starting the server, waiting for it to initialize, and t... | codefeedback |
You are tasked with creating a Python function that processes medical imaging data and organizes it into appropriate directories based on certain conditions. The function should take in a folder path containing DICOM series data and a case ID, and then convert the DICOM series to NIfTI format. Depending on the folder s... | codefeedback |
You are tasked with creating a Python function that sends emails using the SendGrid API. Your function should take in the recipient's email address, the email subject, the email template, and any additional keyword arguments for the template. The function should use the SendGrid API to send the email asynchronously.
C... | codefeedback |
You are tasked with creating a word grid game using HTML, CSS, and JavaScript. The game will present the player with a grid of letters and the player's objective is to find as many words as possible by connecting adjacent letters in the grid. The game will have a timer and a score counter to track the player's performa... | codefeedback |
You are tasked with implementing a data structure to store key-value pairs and a function to retrieve the value associated with a given key. The data structure should support adding new key-value pairs, updating existing values, and retrieving values by their keys. Additionally, you need to write a function to perform ... | codefeedback |
You are tasked with implementing a simulation program that generates maps based on certain parameters. The code snippet provided is a part of this simulation program and involves generating simulated maps using a random draw function. The simulation can be configured to use either a logarithmic scale for the parameter ... | codefeedback |
You are tasked with implementing a function to validate user input for a registration form. The function should ensure that the provided user data meets certain criteria before allowing the user to be added to the system. The user data includes the user's name, email, and password. Your task is to create a function tha... | codefeedback |
You are tasked with creating a Python class that implements a file filtering mechanism. The class should be able to filter files based on certain criteria, such as file extension, size, or creation date. Your task is to design and implement the `FileFilter` class with the following requirements:
- The `FileFilter` cla... | codefeedback |
You are tasked with implementing a simple web application authentication system using PHP. The provided code snippet is a simplified representation of the authentication logic. Your goal is to expand upon this code to create a complete authentication system.
Your task is to create a PHP class that manages user authent... | codefeedback |
You are tasked with implementing a Python class that represents a simple tree structure. The tree will consist of nodes, each of which can have an arbitrary number of child nodes. Your task is to implement the `Root` class, which will serve as the root node of the tree.
The `Root` class should have the following prope... | codefeedback |
You are tasked with implementing a function that determines whether a given symbol has any nested types. A symbol in this context refers to a construct in a programming language, such as a class, interface, or struct. The function should take the symbol as input and return a boolean value indicating whether the symbol ... | codefeedback |
You are tasked with implementing a custom property wrapper in Swift that enforces a specific behavior for a property. Your property wrapper should ensure that the property it wraps always has a non-nil value when accessed, and it should provide a default value if the property is accessed before being explicitly set.
Y... | codefeedback |
You are tasked with creating a program to decrypt a message encrypted using a specific algorithm. The encrypted message is in the form of a string, and the decryption process involves reversing the encryption algorithm. The encryption algorithm works by shifting each letter in the message by a certain number of positio... | codefeedback |
You are given a Python code snippet that includes a call to a function `main()`. Your task is to implement the `main()` function to generate two distinct numbers and print them as the solutions.
The `main()` function should generate the numbers according to the following rules:
1. The first number should be the smalle... | codefeedback |
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score of the game, excluding the highest and lowest scores.
Write a function `calculateAverageScore(scores)` that takes in a list of integers `scores` and returns the average score, rounded ... | codefeedback |
You are tasked with creating a program to manage and organize image files based on specific criteria. The program should take a directory path as input and perform the following operations on the image files within the directory:
1. If an image file with the suffix "_Z-axis.png" exists, it should be removed.
2. If an ... | codefeedback |
You are tasked with implementing a circular queue data structure in Python. A circular queue is a data structure that follows the FIFO (First In, First Out) principle and has a fixed size. When the queue is full and a new element is enqueued, the oldest element in the queue is dequeued to make space for the new element... | codefeedback |
You are tasked with implementing a function `crop_classes(train_geo)` that takes a list of geographical coordinates representing train stations and returns a dictionary containing the count of train stations in each class of service. Each geographical coordinate is represented as a tuple of latitude and longitude. The ... | codefeedback |
You are tasked with implementing a function to calculate the cumulative probability within a given range for a normal distribution. The function `cumulative2` takes four parameters: `mean` (the mean of the normal distribution), `std` (the standard deviation of the normal distribution), `lower_range` (the lower bound of... | codefeedback |
You are tasked with creating a Python class that simulates a simple state machine. The state machine should have the ability to transition between different states based on input events. Your task is to implement the `StateMachine` class with the following specifications:
- The `StateMachine` class should have the fol... | codefeedback |
You are tasked with implementing a Rust function that processes a given `typ` and returns the corresponding `fe::TypeDesc` based on the pattern matching of the input. The `typ` is of type `FixedSize` and the function should handle the pattern matching for different cases of `FixedSize` and `Base` enums.
Write a functi... | codefeedback |
You are tasked with implementing a custom documentation system for a software library. The system should support the concept of "documentation extensions," which allow developers to annotate their code with additional metadata for documentation generation.
Each documentation extension is represented by a class with th... | codefeedback |
You are tasked with implementing a search functionality for a ratings system in a PHP application. The `search` method is responsible for retrieving ratings associated with a specific model and its related user information. The method takes a modelMorph object and an optional array of parameters as input. The `setParam... | codefeedback |
You are tasked with creating a program to manage the levels of service at a healthcare establishment. The establishment has a database with tables to store information about the levels of service and characterizations of the establishment. The snippet provided is a part of the SQL code used to create the table for the ... | codefeedback |
You are tasked with implementing a Python class that handles input and output operations for a specific data format. The class, named `DataHandler`, has several attributes and methods that need to be implemented. The provided code snippet is a part of the `DataHandler` class and shows the initialization and a method de... | codefeedback |
You are tasked with creating a secure encryption oracle for a client's application. The encryption oracle takes a string as input and returns the encrypted version of the input. The encryption algorithm uses a custom XOR-based encryption method. However, the current implementation is vulnerable to a specific type of at... | codefeedback |
You are tasked with implementing a simplified version of a FIFO (First In, First Out) queue using Python. The FIFO queue should support the following operations:
1. `enqueue(item)`: Add an item to the end of the queue.
2. `dequeue()`: Remove and return the item at the front of the queue.
3. `is_empty()`: Return True if... | codefeedback |
You are working for a data science company that specializes in building machine learning models for various applications. Your task is to create a Python function that loads a pre-trained machine learning model and returns it. The model is saved using the joblib library, and it is expected to be a RandomForestClassifie... | codefeedback |
You are tasked with implementing a Python class that can generate human-readable descriptions of cron expressions. A cron expression is a string representing a schedule, typically used to set the time at which a job should run. The expression consists of five space-separated fields: minute, hour, day of the month, mont... | codefeedback |
You are tasked with implementing a method to process and display member authorities in an Android application. The application uses AndroidAnnotations and RxJava for asynchronous operations.
You are given a class `SetEnterpriseAuthorityActivity` that extends `BackActivity` and is annotated with `@EActivity(R.layout.ac... | codefeedback |
You are tasked with implementing a class for handling the impact of an instant kill ability in a game. The class should support serialization and deserialization of its data. The provided code snippet shows part of the implementation for the `InstantKillImpact` class, including methods for serialization and deserializa... | codefeedback |
You are tasked with implementing a parallel processing algorithm for a genetic analysis tool. The provided code snippet is a part of a Python class that manages the parallel processing of genetic data using the Expasy database. The `run` method is responsible for dividing the genetic data into multiple processes and in... | codefeedback |
You are tasked with implementing a Swift protocol for a cryptocurrency token swap feature. The protocol should provide a method for generating a URL to initiate the token swap and should also support registering additional token action services.
Your task is to create a Swift protocol called `TokenSwapURLProviderType`... | codefeedback |
You are tasked with implementing a simplified version of the `ssprintf` function in C. The `ssprintf` function is similar to the standard `sprintf` function, but it dynamically allocates memory for the resulting string. Your task is to create a function `my_ssprintf` that takes a format string and a variable number of ... | codefeedback |
You are tasked with creating a Python program to scrape statistics from a website using Selenium. The program should utilize a web browser to navigate to a webpage, find a list of stations, and then scrape statistics for each station using a function called `find_station`. The program should display the progress of the... | codefeedback |
You are tasked with implementing a Java class that represents a search query for a data search application. The search query should support filtering by multiple criteria and sorting the results based on specific fields. The class should also provide methods for adding filter criteria and sorting options.
Your task is... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.