instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a custom iterator for a specific data structure. The data structure is a custom collection called `CustomCollection` that stores integers. The iterator should iterate through the collection and perform a specific action on each element based on a given condition.
The `CustomCollection`... | codefeedback |
You are tasked with implementing a generic interface for type conversion in Java. The interface, named `Converter`, has a single method `convert` that takes an input of type `F` and returns an output of type `T`. Your goal is to create a class that implements this interface and provides a specific conversion functional... | codefeedback |
You are given a set of instructions to move in a 3D space. The instructions consist of three types: "forward", "up", and "down", each followed by a distance to move. The starting position is at the origin (0, 0, 0) in 3D space. The "forward" instruction moves the position along the horizontal axis, the "up" instruction... | codefeedback |
You are tasked with creating a class that represents a customizable theme for a user interface. The theme class should have properties for header color, body color, body weight, and header font family. Your goal is to implement a method that checks if the theme properties are valid according to certain criteria.
You a... | codefeedback |
You are tasked with implementing a Java class that extends the functionality of an archival writer for table data. The archival writer is responsible for exporting table data to an output stream using specified archival options. Your task is to complete the implementation of the `ArchivalWriter` class by providing the ... | codefeedback |
You are tasked with implementing a simplified version of Conway's Game of Life, a cellular automaton devised by the mathematician John Conway. The game is played on a grid of cells, each of which can be in one of two possible states: alive or dead. The game proceeds in discrete time steps, with the state of each cell i... | codefeedback |
You are given a list of integers representing the daily stock prices of a company. Your task is to write a function to calculate the maximum profit that can be obtained by buying and selling the stock at most once. If it is not possible to make any profit, return 0.
Create a function `maxProfit` that takes in a list o... | codefeedback |
You are tasked with creating a Python script to automate the process of deleting a Kafka topic and producing messages to a specified topic using the Kafka command-line tools. Your script should handle the execution of these commands and provide appropriate error handling.
Your script should perform the following tasks... | codefeedback |
You are tasked with creating a Python script to automate the process of waiting for specific services to become available and then generating load using a load generation script. The script should utilize the `wait-for-it` tool to wait for the availability of two services, MySQL and Debezium, with a timeout of 60 secon... | codefeedback |
You are tasked with implementing a function that interacts with Google BigQuery (GBQ) to load a file from a specified path into a GBQ table. The function should handle the connection to GBQ and the file loading process. You are provided with a code snippet that includes a function `give_file_gbq` and a partial code blo... | codefeedback |
You are tasked with implementing a connection pool for an HTTP client in Java. The goal is to create a class, `HttpClientUtils`, that manages a pool of HTTP connections for efficient reuse.
The `HttpClientUtils` class should have the following features:
1. A private static final Logger named `LOG` for logging purposes... | codefeedback |
You are tasked with implementing a function to calculate the size of a grid based on the number of dots and validating whether the size of the grid is valid for a given screen size. The grid consists of dots arranged in rows and columns, and the size of the grid is determined by the number of dots.
You need to impleme... | codefeedback |
You are tasked with implementing a simple tokenization system for a text processing application. The `Token` class has been provided as a starting point. Your task is to extend this class and create a tokenizer function that splits a given input text into individual tokens based on a specified delimiter.
You need to i... | codefeedback |
You are tasked with implementing a function to calculate the similarity between a query vector and a list of vectors using different distance metrics. The function should take the query vector, the list of vectors, and the type of distance metric as input and return a list of tuples, where each tuple contains the simil... | codefeedback |
You are given a 2D board representing a word search puzzle and a word to search for. The board consists of lowercase English letters and the word is a string of lowercase letters. Your task is to write a function that determines if the word can be found in the board. The word can be constructed from letters of sequenti... | codefeedback |
You are tasked with creating a Python function that parses a list of classifiers and returns a dictionary containing the classification categories and their corresponding values. Each classifier is represented as a string in the format "Category :: Value". The function should extract the category and value from each cl... | codefeedback |
You are tasked with implementing a function that processes a list of vertices representing a polygon and performs specific operations when the polygon is closed by the user. The function should add a patch to a figure and update a grid map based on the closed polygon.
You are given the following information:
- The fun... | codefeedback |
You are tasked with implementing a signal decomposition algorithm for solar data analysis. The provided code snippet imports the necessary modules and a specific signal decomposition function from the `solardatatools` library. Your goal is to create a Python function that utilizes the imported `tl1_l2d2p365` function t... | codefeedback |
You are tasked with creating a program that utilizes reflection to analyze and manipulate the properties of a given class. Reflection is a powerful feature in C# that allows you to inspect and manipulate assemblies, modules, types, and members at runtime. In this problem, you will create a class with properties and use... | codefeedback |
You are tasked with implementing a Python class that can parse a specific file format and extract metadata and strings from it. The file format is structured in a way that metadata is stored at the beginning of the file, followed by a section containing strings. Your task is to create a class with a method that can par... | codefeedback |
You are tasked with creating a web scraper to extract data from a given website. The website "https://www.saoroque.sp.gov.br/portal/diario-oficial" contains a list of links to the official gazette publications. Your goal is to write a Python program using the Scrapy library to extract the titles and URLs of these gazet... | codefeedback |
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve the player navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game. Each room will have specific attributes such as a description, possible actions... | codefeedback |
You are tasked with implementing a Python function that simulates a 1-dimensional convolution operation with padding. The function should take in a 1-dimensional input array, a 1-dimensional kernel array, and a padding type as input, and return the result of the convolution operation.
The function signature should be:... | codefeedback |
You are tasked with implementing a custom error handling system for a token validation module in a Swift application. The module should be able to handle various error cases related to token validation. Your task is to create a custom error type and implement the necessary error handling logic.
Define a custom error t... | codefeedback |
You are tasked with creating a Python function that extracts test case names from a given test file. The test file contains test cases defined using the `parameterized` module from the `absl.testing` library. Each test case is defined using the `parameterized.parameters` decorator. Your function should parse the test f... | codefeedback |
You are tasked with implementing a function to calculate the nth Fibonacci number. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The function should take an integer n as input and return the nth Fibonacci number.
For example, giv... | codefeedback |
You are tasked with implementing a parallel evolutionary algorithm for optimizing a given problem. The provided code snippet is a part of a Python class that manages the parallel processing of the evolutionary algorithm. Your task is to complete the implementation of the `run_evolve` method, which will execute the evol... | codefeedback |
You are tasked with implementing a Vector2 class in Python to represent 2D vectors and providing various functionalities for vector manipulation. The class should support operations such as vector addition, subtraction, magnitude calculation, angle calculation, and conversion to a tuple.
Your task is to implement the ... | codefeedback |
You are tasked with implementing a pluralization function for different languages. The function should take into account the specific pluralization rules of each language and correctly pluralize a given word based on a numeric value.
You are provided with a code snippet that demonstrates the usage of the pluralization... | codefeedback |
You are tasked with creating a Python script that automates the signing of artifacts for the OpenSearch project. The script should take input arguments from the command line and sign the specified artifacts using the provided signing key.
Your task is to implement the `sign_artifacts.py` script, which will be responsi... | codefeedback |
You are tasked with creating a Python function that simulates a simple web application testing scenario. The function should send HTTP requests to a web server and validate the responses based on the provided code snippet.
You are given a Python code snippet that contains two test functions using the `pytest` framewor... | codefeedback |
You are given two arrays, `src` and `dst`, both of length `n`. The arrays represent a sequence of operations to be performed on a data structure. Each element in the arrays can be one of the following three types of operations:
1. `0`: Represents a "copy" operation, where the value at the current index is copied to th... | codefeedback |
You are working on a deployment script for a Django web application. The given code snippet is part of the deployment process and sets up various directory paths and configuration files. Your task is to write a function that takes the given environment variables and generates the final commands to be executed for setti... | codefeedback |
You are tasked with implementing a generic buffer type in Rust that can be used with different block sizes and buffer kinds. The provided code snippet includes module declarations, type aliases, and imports related to the buffer implementation.
Your task is to create a generic Rust struct `Buffer<S>` that represents a... | codefeedback |
You are working on a project that involves building and packaging a software application for a Linux distribution. As part of the build process, you need to automate the steps to build the application, copy the built executable to a specific directory, and then create a Debian package (.deb) for distribution. The provi... | codefeedback |
You are tasked with implementing a custom error handling mechanism for a data processing application. The application needs to handle specific error conditions related to data length, such as invalid length, overflow, and underflow. To achieve this, you need to create custom error classes and ensure that they are appro... | codefeedback |
You are tasked with implementing a simplified blockchain data structure and a proof-of-work algorithm. A blockchain is a distributed ledger that stores a growing list of records, called blocks, which are linked and secured using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, ... | codefeedback |
You are given a code snippet that initializes some variables and arrays. Your task is to complete the code by implementing a specific algorithm to calculate the number of ways to arrange black and white tiles in a row of length M, such that the number of arrangements equals or exceeds the TARGET value.
The algorithm s... | codefeedback |
You are tasked with implementing a method to resize an image using a specific sampling factor. The method takes an input image and a sampling factor, and returns the resized image.
You are given the following code snippet as a starting point:
```java
int height = source.getHeight();
int scaledWidth = width / mSamplin... | codefeedback |
You are tasked with creating a SwiftUI view that displays a list of items and allows the user to select and deselect them. The selected items should be highlighted, and the user should be able to see the total count of selected items. You need to implement a custom SwiftUI view that fulfills these requirements.
Your c... | codefeedback |
You are working on a script to automate the setup of a development environment. As part of this setup, you need to ensure that a specific directory is created and added to the system's PATH environment variable in both the `.bashrc` and `.zshrc` configuration files. The code snippet provided is a part of the script you... | codefeedback |
You are tasked with implementing a method `_daysFromToday` within a class that calculates the date a certain number of days from the current date. The method should take an integer `days` as input and return the date that is `days` days from the current date. You can assume that the input `days` will always be a non-ne... | codefeedback |
You are working on a data analysis project for a scientific research team. The team has collected a large dataset of measurements from various experimental conditions and needs to perform data processing and analysis. One crucial aspect of the analysis involves mapping parameters and scales for different experimental c... | codefeedback |
You are tasked with implementing a function for decoding and unflattening parameters in an inter-process communication (IPC) system. The provided code snippet contains part of the implementation for this task. Your goal is to complete the implementation of the `serverUnflattenDecode` function based on the given code sn... | codefeedback |
You are tasked with implementing a simple memory management system for a hypothetical programming language. The system should support the allocation and deallocation of memory for both classes and structs. You are given a code snippet that demonstrates the creation of instances of classes and structs, as well as their ... | codefeedback |
You are tasked with creating a program that extracts the license information from a given text. The license information is enclosed within a specific format and needs to be extracted and displayed. The license information is enclosed within a block comment, which starts with a line containing only "#" followed by the l... | codefeedback |
You are tasked with creating a Python function that retrieves and processes file descriptions from a given directory. The function should take a directory path as input and return a dictionary containing file names as keys and their respective descriptions as values. The file descriptions are stored in separate text fi... | codefeedback |
You are tasked with implementing a class that manages annotations on a map. The class should handle adding and removing annotations based on changes in a collection. Your task is to write a method that adds new annotations to the map when the collection changes.
You are given the following code snippet as a reference:... | codefeedback |
You are tasked with creating a custom operator for Apache Airflow, a popular platform for programmatically authoring, scheduling, and monitoring workflows. Your custom operator, named `SpellRunOperator`, will be responsible for executing a spell-checking task as part of an Airflow DAG (Directed Acyclic Graph).
The `Sp... | codefeedback |
You are tasked with implementing a custom judge protocol for a programming competition platform. The judge protocol is responsible for evaluating the correctness of submitted solutions to programming problems. The provided code snippet defines a class `JudgeProtocol` that inherits from `BaseJsonObject`, which is assume... | codefeedback |
You are given a list of Atom objects representing the coordinates of atoms in a molecular structure. Each Atom object has a symbol (element), coordinates, and units. Your task is to write a function that takes this list of Atom objects and returns the distance between the two closest atoms in the structure.
An Atom ob... | codefeedback |
You are tasked with creating a Python function that processes a list of transactions and calculates the total amount of money spent. Each transaction is represented as a dictionary with keys "amount" and "currency". The function should also allow for an optional parameter to specify the format in which the total amount... | codefeedback |
You are given a snippet of code that is part of a program to process a string of characters in a specific language. The code snippet contains some variable assignments, conditional checks, and a loop. Your task is to understand the code and answer a question related to its functionality.
The code snippet is part of a ... | codefeedback |
You are tasked with creating a script to automate the build and deployment process for a Rust project using Docker. The script should handle building the project with specific target architecture and then creating a Docker image and pushing it to a container registry.
Your task is to write a shell script that accompli... | codefeedback |
You are tasked with implementing a simplified version of a U-Net architecture for image segmentation. The U-Net consists of an encoder-decoder structure with skip connections, commonly used in biomedical image segmentation tasks. Your goal is to complete the implementation of the U-NetDecoderBlock class, which is respo... | codefeedback |
You are tasked with creating a Python class to manage redaction of sensitive information from documents. The class should provide methods to redact specific content based on certain criteria. Your task is to implement the `RedactionPage` class with a method `check_start_date_is` that redacts any content on the page tha... | codefeedback |
You are tasked with implementing a function that displays a success message with an optional status, success image, style, action, and completion closure. The function should also allow specifying closures to be executed when the user presses the Menu button or the Play/Pause button while the success message is display... | codefeedback |
You are tasked with implementing a class that manages a collection of items and provides a method for bulk operations. Your task is to complete the implementation of the given class `CollectionManager` by adding the necessary methods.
You are provided with the following code snippet as a starting point:
```php
class ... | codefeedback |
You are working on a signal processing project and need to calculate the root mean square (RMS) values for three different axes (x, y, z) of a signal at various frequency bands. The code snippet provided initializes arrays for storing the RMS values for each axis and frequency band.
You are given the following informa... | codefeedback |
You are tasked with creating a Swift protocol that defines error handling for a networking library. The protocol, named `ErrorConverter`, includes an associated type `DomainError` and a static function `make` responsible for converting a specific library error type, `AphroditeError`, into the associated `DomainError`.
... | codefeedback |
You are tasked with implementing a custom property decorator in Python that enforces specific constraints on the assigned value. The property decorator should be able to handle data validation and default value assignment. Your task is to create a `UserProperty` decorator that can be used to define properties for a `Us... | codefeedback |
You are tasked with creating a script to convert a collection of audio files to WAV format using the `ffmpeg` command-line tool. The script should iterate through a specified search path, extract the file name from each audio file, and then use `ffmpeg` to convert the audio file to WAV format. The WAV files should be s... | codefeedback |
You are tasked with creating a custom Python class that manages skills for a role-playing game. The class should handle the initialization of skills, tokenizing skill names, and transforming skill data for reporting purposes.
Your task is to implement the `SkillManager` class, which should have the following functiona... | codefeedback |
You are tasked with implementing a function that writes data to a file and saves it to an Amazon S3 bucket using multipart upload. The function should take the file path, data to be written, and upload arguments as input and return the number of bytes written to the file.
The code snippet provided gives a glimpse of t... | codefeedback |
You are tasked with implementing a network request handling system in Swift. The provided code snippet is a part of a networking framework that supports various types of requests and response handling. Your task is to complete the implementation of the `request` method, which is responsible for making network requests ... | codefeedback |
You are tasked with implementing a function to determine whether a given country is completely surrounded by another country. A country is represented by a struct `Country` with the following fields:
- `territories`: a vector of unique positive integers representing the territories within the country.
- `border_color`:... | codefeedback |
You are tasked with implementing a function that extracts a specific class from a TypeScript module and returns it as a named export. The module contains a code snippet similar to the following:
```typescript
(<any>globalObject).BABYLON.GuiEditor = GUIEditor;
// eslint-disable-next-line @typescript-eslint/naming-conve... | codefeedback |
You are tasked with implementing a shell script that processes command-line arguments to set specific flags. The script should handle both short and long options, and it should support the accumulation of multiple flags into a single variable.
Your task is to complete the shell script by adding the necessary code to h... | codefeedback |
You are tasked with implementing a function that converts a given value to its HTML representation. The function should handle different types of input values and produce the corresponding HTML output.
Write a function called `to_html` that takes a single argument `value` and returns its HTML representation. The funct... | codefeedback |
You are tasked with creating a Java class that represents a video game. The game has different difficulty levels, which are represented by an enum called `Difficulty` with values `EASY`, `NORMAL`, and `HARD`. Your task is to create a `Game` class that has attributes for the game's title, genre, and difficulty level. Ad... | codefeedback |
You are tasked with implementing a probability density function (PDF) for the Student's t-distribution in a database interface. The Student's t-distribution is a probability distribution that arises in the estimation of the mean of a normally distributed population when the sample size is small and the population stand... | codefeedback |
You are tasked with implementing a custom HashMap in Rust that can store instances of a custom struct `HumanAddr`. The `HumanAddr` struct is defined as follows:
```rust
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, Hash)]
pub struct HumanAddr(pub String);
```
Your task is to imple... | codefeedback |
You are tasked with implementing a middleware component for a web application. The middleware is responsible for controlling the flow of requests and responses. The provided code snippet is a part of the middleware implementation, and it shows a commented-out section that needs to be completed.
Your task is to impleme... | codefeedback |
You are tasked with implementing a memory pool class in C++. A memory pool is a pre-allocated area of memory from which smaller chunks can be allocated and deallocated efficiently. Your task is to create a class `MemoryPool` that manages a pool of memory and provides methods for allocating and deallocating memory chunk... | codefeedback |
You are given a Python code snippet that includes a function to check if a given number is prime. Your task is to complete the `is_prime` function and then use it to solve a specific problem.
Complete the `is_prime` function to determine whether a given positive integer `x` is a prime number. A prime number is a natur... | codefeedback |
You are tasked with implementing a task scheduler for a mobile application. The scheduler should allow the application to schedule and execute tasks when the application transitions from the background to the active state. You need to design a class that manages the scheduling and execution of tasks when the applicatio... | codefeedback |
You are tasked with creating a custom settings class that securely maps attributes to values from a safe settings dictionary. The class should raise an AttributeError if an attribute is not found in the safe settings dictionary. Your task is to implement the missing `get_safe_settings()` function and complete the `Safe... | codefeedback |
You are tasked with implementing a Swift class that manages a custom table view cell for a cryptocurrency wallet app. The cell contains various UI elements and properties related to cryptocurrency tokens. Your goal is to complete the implementation of the `CustomWalletCell` class by adding functionality to handle user ... | codefeedback |
You are tasked with creating a script to automate the process of obtaining a signed SSH certificate from a Certificate Authority (CA) for secure access to a server. The script should handle the generation of a public key, sending the public key to the CA for signing, retrieving the signed certificate, and then using it... | codefeedback |
You are tasked with implementing a Python class that manages retrievers for visual data. The class should handle the importing of necessary modules and provide methods for adding and retrieving retriever objects.
Your task is to complete the implementation of the `Retrievers` class by adding the following methods:
1. ... | codefeedback |
You are tasked with implementing a resampling algorithm for audio data. The resampling process involves converting audio samples from one sampling rate to another while preserving the audio quality. You are given a code snippet that involves resampling audio data and saving the resampled audio to a file.
Your task is ... | codefeedback |
You are tasked with implementing a memoization technique to optimize the computation of Fibonacci numbers. Memoization involves storing the results of expensive function calls and returning the cached result when the same inputs occur again. Your goal is to create a Python function that calculates the nth Fibonacci num... | codefeedback |
You are given a list of order IDs, which can be either strings or integers. Your task is to write a function that takes this list as input and returns a new list containing only the unique order IDs, preserving their original order of appearance.
Write a function `get_unique_orders` that takes a list `order_id_list` a... | codefeedback |
You are tasked with implementing a Python class for a clustering algorithm. The class contains a method for setting up the algorithm, as well as methods for defining the input and output shapes and listing the required arguments. Your task is to complete the implementation of the class by writing the missing parts of t... | codefeedback |
You are tasked with implementing a utility function to parse and process callback configurations for a machine learning training framework. The function should handle the extraction of specific callback-related configuration parameters and instantiate corresponding callback objects based on the provided configuration.
... | codefeedback |
You are tasked with implementing a function to calculate the Levenshtein distance between two strings. The Levenshtein distance, also known as the edit distance, measures the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.
Your task is to... | codefeedback |
You are tasked with creating a script to automate the process of updating the SSH server configuration on a Linux system. The script should perform the following tasks:
1. Append the line "LoginGraceTime 60" to the file `/etc/ssh/sshd_config.new`.
2. Copy the contents of `/etc/ssh/sshd_config.new` to `/etc/ssh/sshd_co... | codefeedback |
You are working on a web application that uses Python and the Flask framework. The application has a module called `core` which contains various controllers and domain services. The controllers handle the HTTP requests and responses, while the domain services contain the business logic of the application. Your task is ... | codefeedback |
You are given a list of strings representing file paths. Each file path consists of a sequence of directories separated by slashes ("/"). Your task is to write a function that finds the longest common directory path among the file paths. If there is no common directory path, the function should return an empty string.
... | codefeedback |
You are working on a web application that uses dependency injection to manage its services. The code snippet provided is from the constructor of a class responsible for managing user sessions, redirection, blocks, assets, and session settings. The constructor takes in several interfaces and services as dependencies and... | codefeedback |
You are tasked with creating a Python program to analyze and visualize temperature data using the matplotlib library. The program should read temperature data from a CSV file, perform a linear regression analysis, and then plot the original data points along with the linear regression line.
Your task is to complete th... | codefeedback |
You are working on a project that involves managing a large collection of firearm data. Each firearm is represented by a string in the format "CUP_<manufacturer>_<model>_<caliber>_<barrel_length>_<attachment>". You need to write a function that can extract and organize this information from the given strings.
Write a ... | codefeedback |
You are tasked with implementing a TypeScript function that analyzes a list of class members and determines the static encapsulation type used within the class. The function signature is as follows:
```typescript
import ts from 'typescript';
export declare function parseStaticEncapsulation(staticMembers: ts.ClassEleme... | codefeedback |
You are tasked with implementing a lexer for a simple programming language. The lexer should be able to identify and tokenize different language constructs such as keywords, identifiers, and parentheses. Your task is to write a function that takes an input string and returns a list of tokens representing the lexical el... | codefeedback |
You are tasked with implementing a custom normalization function in Python to handle both vectors and matrices. The function should be able to calculate different types of norms based on the input parameters. You are not allowed to use any external libraries or built-in functions for norm calculation.
Write a Python f... | codefeedback |
You are tasked with creating a Python function to facilitate flashing binary files onto a test device. The function should take the following parameters:
- `mount_point`: The mount point of the test device.
- `base_dir`: The base directory where the binary file is located.
- `build_dir`: The directory where the binary ... | codefeedback |
You are working on a payment processing system that involves handling barcodes and URLs. Your task is to implement a function that sanitizes and validates the input data according to certain rules. The function should perform the following tasks:
1. If the `BARCODE` variable is truthy, it should be converted to 1; oth... | codefeedback |
You are working on a program to simulate an energy trading market. The program has access to various parameters related to energy trading, including the energy difference, energy market price, wanted energy, energy buy max price, energy buy starting price, energy buy price increment, and energy sell min price.
Your t... | codefeedback |
You are tasked with implementing a function that processes an XML document to extract font information and create an asset for a game engine. The given code snippet is part of a larger system and provides some context for the task. The function `mark_progress` is used to check if the font information has already been p... | codefeedback |
You are working on a project that involves implementing a cryptographic signature scheme using the Leighton-Micali One-Time Signature (LMOTS) scheme. The LMOTS scheme involves generating a signature by applying a hash function iteratively in a chain-like fashion. Your task is to write a function to generate a signature... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.