instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a class hierarchy for a toy store's inventory management system. The system should be able to handle different types of toys and their respective properties. Your task is to create a class `ToyHouse` that implements the interface `IToy` and includes functionality to set the price and co... | codefeedback |
You are tasked with implementing a custom ViewCollection class in Python that inherits from the ClientObjectCollection class. The ClientObjectCollection class is a part of the office365.sharepoint module and is used to manage collections of client objects in a SharePoint environment. Your custom ViewCollection class sh... | codefeedback |
You are working on a project that involves building a neural network using TensorFlow for image classification. As part of the network architecture, you need to implement a fully connected layer after reshaping the output of a max-pooling layer. The reshaping is done to convert the 3D tensor output of the max-pooling l... | codefeedback |
You are tasked with implementing a Python class that manages a table of contents (TOC) for a document. The TOC entries are represented as a tree structure, where each entry has a label, a page number, and a level. The class provides a method to draw the TOC entries on a canvas, with the option to include dots and page ... | 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, excluding the highest and lowest scores.
Write a function `calculateAverage(scores)` that takes in a list of integers `scores` and returns the average score, rounded to the nearest wh... | codefeedback |
You are tasked with creating a Python function that dynamically imports all modules from a specified directory and its subdirectories. Your function should traverse the directory structure, identify Python modules, and import them into the current namespace. Additionally, the function should return a dictionary mapping... | codefeedback |
You are tasked with implementing a custom Markdown parser for a new feature in a text editor. The feature involves supporting "popups" in Markdown, which are block-level elements that render as Info/Note/Warning blocks in the editor. The syntax for these popups is as follows:
- ~? for info popups
- ~! for note popups
-... | codefeedback |
You are tasked with creating a program that analyzes a given text file to extract and count the occurrences of unique words. Your program should ignore punctuation, capitalization, and consider words with apostrophes as a single word. Additionally, the program should exclude common stop words such as "the," "and," "of,... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Additionally, the program should handle errors gracefully and provide informative messages to the user.
Your task is to implement the er... | codefeedback |
You are tasked with implementing a role-based access control (RBAC) system for a web application. The RBAC system should restrict access to certain pages based on the roles assigned to users. The code snippet provided is a part of the role detail view in the RBAC system. The `render` function is used to render the role... | codefeedback |
You are tasked with implementing a function that simulates a circular buffer with read and write operations. The circular buffer is represented by an array of fixed size, and it supports the following operations:
1. `b_write_add_avail()`: This function is called to add data to the circular buffer. If there is no space ... | codefeedback |
You are tasked with creating a programming problem related to database migration in the context of a web application. The problem will focus on understanding and implementing database migration using a specific framework or language.
Title: Database Migration Challenge
You are working on a web application using a pop... | codefeedback |
You are tasked with implementing a priority queue using a linked list in C++. The priority queue should support the following operations:
1. `push`: Add an element to the priority queue with a specified priority.
2. `pop`: Remove the element with the highest priority from the priority queue.
3. `top`: Retrieve the elem... | codefeedback |
You are tasked with implementing a custom alphabet ordering system for biological sequences, such as DNA or protein sequences. The given code snippet provides some initial setup for the custom alphabet, including special characters for gaps and stops, as well as generic placeholders for ambiguous positions in the seque... | codefeedback |
You are tasked with creating a program that parses and processes CSS code to identify and remove all inline style declarations that override a specific theme's background color. The program should be able to handle multiple CSS rules and should output the modified CSS code without the overridden background color declar... | codefeedback |
You are tasked with creating a Python function that processes financial data from a CSV file and performs specific operations on the data. The function should read in the data from the CSV file, convert the 'volume' column to integers, and then perform additional operations based on the input parameters. The function s... | codefeedback |
You are tasked with implementing a Python function called `circle` that takes no parameters and draws a circle using ASCII characters. The circle should be centered within a 20x20 grid, with the circle itself being 10 characters in diameter. The grid should be represented as a 2D list of characters, with the circle rep... | codefeedback |
You are tasked with creating a Python function that processes purchase receipts and updates the HSN/SAC code for each item based on the batch number. The function should iterate through the items in the purchase receipt and, if a batch number is provided, retrieve the corresponding HSN/SAC code from the database and up... | codefeedback |
You are tasked with implementing a custom mapping function for a Swift class. The function should take a `Map` object as a parameter and perform the necessary mapping operations. The `Map` object represents a mapping structure that associates keys with values.
Your task is to complete the implementation of the `mappin... | codefeedback |
You are working on a project to automate the deployment of Kubernetes resources using Pulumi, a popular infrastructure as code tool. As part of this project, you need to create a Pulumi program that deploys an external DNS Helm chart into a specified Kubernetes namespace. The code snippet provided is a part of this pro... | codefeedback |
You are given a set of points in a 2D plane represented as tuples of (x, y) coordinates. Your task is to implement a function that finds the nearest point to a given target point and calculates the distance between them. The distance between two points is calculated using the Euclidean distance formula: distance = sqrt... | codefeedback |
You are given a game scenario where two players, Alice and Bob, take turns choosing a positive integer. The game starts with a given positive integer n. In each turn, a player can choose any positive integer m such that 1 <= m < n and n % m = 0. The chosen integer m is then subtracted from n. The player who is unable t... | codefeedback |
You are tasked with implementing a rate limiter for an API request handler. The goal is to limit the number of requests sent to the API within a specific time frame. You are given a code snippet from a Swift closure that is part of the API request handling logic. The `onSuccess` and `onError` closures are called when t... | codefeedback |
You are tasked with creating a Rust module for handling basic musical pitch operations. The module should provide functionality for converting pitch notations, such as note names (e.g., C, D, E) and octaves, into a numerical representation and vice versa. Additionally, the module should support operations for transposi... | codefeedback |
You are tasked with implementing a command history feature for a text editor. The feature should allow users to navigate through a sequence of commands and windows. Each command is represented by a string, and each window is represented by an integer. The command history should keep track of the previous commands and w... | codefeedback |
You are working on a navigation system for a spacecraft, and you need to calculate the velocity of the spacecraft based on its position and time intervals. The spacecraft's position is represented by coordinates (x, y) and the time intervals are represented by t1 and t2. You are given a code snippet that calculates the... | codefeedback |
You are working on a project that involves downloading pre-trained models for image recognition using Convolutional Neural Networks (CNNs). Your task is to create a Python script that automates the process of downloading these pre-trained models from the given URLs. You need to handle any potential errors that may occu... | codefeedback |
You are tasked with creating a Python class for an attitude and position controller for a quadcopter. The class should include methods for initializing the controller with specifications, setting initial states, and implementing a PID controller for attitude control.
Your task is to implement the `QuadcopterController... | codefeedback |
You are tasked with creating a custom hook for managing a peek transition effect in a React application. The provided code snippet is a starting point for the custom hook, but it lacks the implementation details. Your task is to complete the custom hook `usePeekTransition` by implementing the necessary logic to handle ... | codefeedback |
You are given a C++ code snippet that contains a preprocessor directive `#endif`. Your task is to write a program that can identify and count the occurrences of this directive in a given C++ source file.
Write a C++ program that takes a filename as input and outputs the number of occurrences of the `#endif` directive ... | codefeedback |
You are tasked with implementing a graph traversal algorithm to find the shortest path between two nodes in a grid-based environment. The grid represents a 2D maze with obstacles, and the algorithm should find the shortest path from a start position to an end position, considering only vertical and horizontal movements... | codefeedback |
You are tasked with implementing a Python class that represents a Gaussian Process (GP) model. The GP model is used for regression and is defined by a base kernel function and inducing points. The class should support caching of certain computed values to improve performance. Your task is to complete the implementation... | codefeedback |
You are tasked with implementing a class for encrypting and decrypting messages using a custom encryption algorithm. The class contains methods for encryption, decryption, and a private auxiliary function for unit testing purposes. Your task is to complete the implementation of the encryption and decryption methods bas... | codefeedback |
You are tasked with implementing a custom dialog box for a user interface using Python's `prompt_toolkit` library. The `ConfirmDialog` class is a subclass of `PopUpDialog` and is designed to display a dialog box with options to confirm or cancel an action. The dialog box should contain buttons for confirmation and canc... | codefeedback |
You are tasked with creating a Python class that represents a simple inventory management system for a warehouse. The class should utilize SQLAlchemy to define a table in a database for storing inventory items. Your task is to complete the implementation of the `InventoryItem` class by adding the necessary attributes a... | codefeedback |
You are tasked with creating a Python function that interacts with Google Cloud's AI Platform to create a feature. The function should take in the project ID, location, feature ID, and value type as parameters and use the AI Platform SDK to create the specified feature.
Your task is to complete the Python function `cr... | codefeedback |
You are given a snippet of C++ code that is part of a resource management system. The code is responsible for writing 16-bit resources to a resource bundle. Your task is to implement a function that calculates the total number of 16-bit resources written and the resulting resource value based on the given code snippet.... | codefeedback |
You are tasked with implementing a custom neural network layer in Python using the PyTorch library. Your goal is to create a class that includes a convolutional layer followed by a normalization layer and a rectified linear unit (ReLU) activation function. Additionally, you need to implement an up-sampling operation wi... | codefeedback |
You are tasked with implementing a message passing system using the `MessageChannel` class from the `worker_threads` module in Node.js. The `MessageChannel` class provides a way to create a communication channel between a `MessagePort` object and its associated `MessagePort` object. Your goal is to create a program tha... | codefeedback |
You are tasked with creating a Python decorator that enhances the functionality of a given routing method. The decorator should allow for the automatic wrapping of subjects within the decorated function. The `route` method takes a routing rule and optional keyword arguments, and the decorator should be able to modify t... | codefeedback |
You are tasked with creating a test suite for a shell script that manages network bridges in a container environment. The script includes functions to set up a private bridge and to test the creation of a private bridge. The test suite is written using the `shunit2` framework, which provides assertion functions for val... | codefeedback |
You are tasked with implementing a Python module for likelihood-free inference (LFI) using different methods provided by the `imnn` library. The `imnn` library is a package for likelihood-free inference and is used for approximating Bayesian computation and population Monte Carlo methods. Your task is to create a Pytho... | codefeedback |
You are tasked with creating a PHP class that manages a user dashboard. The class has a method `index` which is responsible for retrieving user information and transaction data. Your task is to complete the `index` method by implementing the logic to fetch the user's information and transaction data using the provided ... | codefeedback |
You are tasked with implementing a method to publish monetization usage data using the provided abstract class `MonetizationApiService`. The method `monetizationPublishUsagePost` should accept usage data and publish it, returning a response.
Your task is to create a concrete implementation of the `MonetizationApiServi... | codefeedback |
You are tasked with creating a Python class to represent a data acquisition system for a scientific instrument. The instrument has multiple components that measure different parameters, and the class needs to encapsulate these components and provide a way to access their readings.
Your task is to create a Python class... | codefeedback |
You are working on a device management system that interacts with an external API to retrieve device information. The provided code snippet is a method `getItem` from a service that retrieves device details by making an HTTP request to the external API. The method takes a `deviceUid` as a parameter and returns an Obser... | codefeedback |
You are tasked with implementing a simple event rule management system for scheduling and executing events based on time or rate. The system should support the creation of time-based rules using cron expressions and rate-based rules using rate expressions. You need to create classes and methods to manage these rules an... | codefeedback |
You are tasked with implementing a simplified version of a reactor pattern in C++. The reactor pattern is a design pattern for handling multiple service requests within a single process. In this problem, you will create a reactor task that manages event handling using the ACE (Adaptive Communication Environment) framew... | codefeedback |
You are tasked with implementing a function that takes two parameters, a string and an integer, and returns a modified string based on the following rules:
1. If the length of the input string is less than the provided integer, the function should return the input string concatenated with the integer as a string.
2. I... | codefeedback |
You are tasked with implementing a class that represents a flow of data. The class should have the ability to store data and provide methods for accessing and manipulating this data. Additionally, the class should support the concept of "older" and "newer" data elements, allowing for easy traversal through the flow.
Y... | codefeedback |
You are tasked with creating a program to solve Sudoku puzzles of varying difficulties. The WebSudokuSolver class provides a method, solve, which takes two parameters: the difficulty level (Easy, Medium, or Hard) and a time limit in seconds. The solve method attempts to solve a Sudoku puzzle of the specified difficulty... | codefeedback |
You are tasked with implementing a simple parser for a context-free grammar. The grammar consists of terminal and non-terminal symbols, where non-terminal symbols can be composed of other non-terminal or terminal symbols. Your task is to write a method that takes a string representing a non-terminal symbol and returns ... | codefeedback |
You are tasked with implementing a class metadata registration system for a programming framework. The given code snippet is a part of this system and demonstrates the registration of a class and its attributes.
Your task is to create a class metadata registration system that can handle class registration and attribut... | codefeedback |
You are working on a task management system for a video game engine. The system includes a class `TaskManager` that manages various types of tasks. Each task can be either synchronous or asynchronous. The `TaskManager` class has a method `enqueue` to add tasks to a queue for execution. The method signature is as follow... | codefeedback |
You are tasked with implementing a simple HTTP server using Python's `aiohttp` library. Your server should respond to a GET request to the `/get` endpoint with the text "foobar". Additionally, the server should be able to handle streaming responses.
Your task is to complete the implementation of the server by filling ... | codefeedback |
You are tasked with creating a program that emulates the functionality of the `sed` command in Unix-like operating systems. Specifically, you need to implement a simplified version of the `sed` command that performs a case-insensitive search and replace operation on a given input string.
Your program should take two i... | codefeedback |
You are given a set of coordinates in the form of latitude and longitude pairs. Your task is to write a program to calculate the distance between each pair of coordinates using the Haversine formula. The Haversine formula calculates the distance between two points on the surface of a sphere given their longitudes and l... | codefeedback |
You are tasked with creating a program that processes a list of filenames and generates an image based on the length of the filenames. The program should create a new image with a white background and a width that is 8 times the total length of all filenames combined. The height of the image should be 8 pixels. Each fi... | codefeedback |
You are tasked with implementing a command handler for a Discord bot using TypeScript. The provided code snippet is a part of a Discord bot's initialization process. The `start` method is responsible for setting up the bot client and logging in with the provided token. The bot is expected to load command files from a s... | codefeedback |
You are tasked with creating a PHP class that manages authentication for a payment service using the Przelewy24 payment gateway. The class should handle authentication with the Przelewy24 API and provide methods for setting the service type and environment. You need to implement the `Przelewy24\Authenticate\AuthInterfa... | codefeedback |
You are tasked with creating a command-line interface (CLI) application for managing a virtual inventory of items. The application should allow users to add, remove, and list items in the inventory, as well as display the current version of the application.
Your task is to implement the `inventory` CLI application usi... | codefeedback |
You are tasked with creating a program that processes a specific input format to organize data into sections. The input consists of lines of text, each representing a class definition with a hexadecimal range, class name, and a comment. Your task is to parse this input and organize the classes into sections based on th... | codefeedback |
You are tasked with implementing a class to manage Kafka producer configurations for a data streaming application. The class, named `KafkaProducerConfig`, should have the following properties and methods:
Properties:
- `producer`: A `KafkaConfiguration` object for the producer settings.
- `configuration_file`: A strin... | codefeedback |
You are tasked with implementing a function that calculates the total area of rectangles in a given list. Each rectangle is represented by its top-left and bottom-right coordinates. The area of a rectangle is calculated as the product of its width and height.
You need to implement the following function:
```swift
fun... | codefeedback |
You are tasked with creating a custom exception handling system for a user stack association feature in a web application. The code snippet provided is a TypeScript snippet that imports and exports a custom exception type and defines a union type for exceptions related to describing user stack associations.
Your task ... | codefeedback |
You are working as a DevOps engineer for a company that is deploying a new website using Hugo, a popular static site generator. As part of the deployment process, you need to write a script to automate the deployment steps. The script should perform the following tasks:
1. Run the Hugo command to generate the website ... | codefeedback |
You are working on a graph manipulation library that includes a `Graph` struct with various methods for handling forbidden paths. The code snippet provided is part of the implementation of the `add_forbidden_path` method, which adds a forbidden path to the graph. The method takes a `path` as input, which is a vector of... | codefeedback |
You are tasked with implementing a program to compare two texts and highlight the differences between them. The differences should be presented in a human-readable format, indicating added, removed, and unchanged lines. To achieve this, you will need to utilize the `difflib` library in Python.
Your task is to write a ... | codefeedback |
You are tasked with creating a Python function that takes a prompt message as input and prompts the user to input a "yes" or "no" response. The function should handle the possibility of a user interrupting the input process with a keyboard interrupt (Ctrl+C) and return an appropriate value in such cases. The function s... | codefeedback |
You are given a list of distinct positive integers representing different coin denominations and a target amount of money. Your task is to write a function to compute the number of combinations that make up that amount using the coins. You may assume that you have an infinite number of each kind of coin.
Write a Pytho... | codefeedback |
You are tasked with implementing a Python class that manages credentials for a dual attestation module. The class should inherit from two parent classes, `Struct` and `MoveResource`, and should have a module name of "DualAttestation" and a struct name of "Credential". The class should also have specific fields defined ... | codefeedback |
You are tasked with creating a Python function that checks the validity of a software license by comparing it with a settings file. The function should read the contents of the license file and settings file, then use a salt to hash and compare the two sets of data. If the hashed values match, the function should retur... | codefeedback |
You are tasked with implementing a program to calculate the area of a polygon in a 2D world. The polygon is represented by a list of vertices and a color. The vertices are represented as 2D vectors, and the color is represented as an RGB value. You are provided with a `WorldPolygon` class, which is a record containing ... | codefeedback |
You are tasked with creating a Python class that manages the restoration of backups to volumes using the OpenStack Cinder API. Your class should include methods for initiating the restoration process, monitoring the status of the restoration, and handling the completion of the restoration.
Your class should have the f... | codefeedback |
You are tasked with creating a program to parse and process HTML navigation data from a given source. The program should be able to extract and display specific information from the HTML structure.
You are provided with a Rust code snippet that includes a commented-out function `parse_nav` and an import statement `cbe... | codefeedback |
You are tasked with implementing a function that processes a list of integers and returns the sum of all the even numbers in the list. However, there is a catch - you are only allowed to use a specific set of characters to write the function. The characters you can use are: `(`, `)`, `{`, `}`, `[`, `]`, `<`, `>`, `+`, ... | codefeedback |
You are working on a version control system and need to implement a feature that identifies the most active contributors to a given repository. The repository is represented by a collection of commits, each containing the name of the contributor who made the commit. Your task is to write a function that takes in the co... | codefeedback |
You are tasked with implementing a function that performs element-wise addition on two arrays using Metal, a low-level, high-performance framework for parallel computation. The function should take two arrays of integers and an axis as input, and return a new array resulting from the element-wise addition along the spe... | codefeedback |
You are tasked with implementing a command-line tool for validating and processing cryptographic hashes. The tool should support multiple modes and options for hash validation and manipulation. Your goal is to implement a specific feature for validating a given hash using the ChaCha20 algorithm.
Your task is to implem... | codefeedback |
You are tasked with implementing a function that processes an array of prefectures and returns a new array with the prefectures sorted in alphabetical order. The function should also remove any duplicate prefectures from the input array before sorting.
You are given the following code snippet as a starting point:
```... | codefeedback |
You are tasked with implementing a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should be able to handle negative balances by allowing overdrafts up to a certain limit.
Your task is ... | codefeedback |
You are tasked with implementing a custom attribute-based validation system for a document class in a C# application. The document class represents data to be indexed in a search engine, and it contains various properties that need to be validated before being indexed.
Your task is to create a custom attribute, `Valid... | codefeedback |
You are tasked with creating a Python function that processes WordNet synsets and retrieves information about them from an external source. WordNet is a lexical database of English words grouped into sets of synonyms, called synsets. Each synset is identified by a unique offset and belongs to a specific category.
Your... | codefeedback |
You are tasked with optimizing the memory usage of a distributed computing process. The given code snippet is part of a Python script that utilizes Dask, a parallel computing library, to read and process large CSV files. The script sets up a Dask client with specific configurations and then reads a CSV file into a Dask... | codefeedback |
You are tasked with implementing a custom data structure called `RegisterArray` in Rust, which represents an array of registers. Each register is accessed using a single character as an index. The `RegisterArray` should support both read and write operations on the registers.
Your task is to implement the `Index` and ... | codefeedback |
You are tasked with developing a script to parse and extract specific environment variable settings from a given shell script. The script should be able to identify and extract the value assigned to the `MINIMAL_K8S_E2E` environment variable.
Write a Python function `extract_env_variable_value(script: str, variable_na... | codefeedback |
You are tasked with implementing a Python class that manages a list of tasks. The class should allow adding tasks, marking tasks as completed, and listing all tasks. Additionally, the class should provide a method to print out information about the tasks.
Your task is to complete the implementation of the `TaskManager... | codefeedback |
You are tasked with creating a Rust program that utilizes the `rhabdophis` library to perform lexical analysis and parsing on a given input file. The `rhabdophis` library provides utilities for lexical analysis, parsing, and runtime execution of code.
Your program should perform the following steps:
1. Read the conten... | codefeedback |
You are tasked with implementing a file management system for a document processing application. The system should handle the creation and management of document files, including writing contents into the files. You are provided with a code snippet that includes relevant variable declarations and an error message const... | codefeedback |
You are tasked with creating a date formatting function that can handle time zone conversions. The function should take a date, time zone, and formatting options as input and return the formatted date as a string. The formatting options include the day of the week, represented as a number from 0 (Sunday) to 6 (Saturday... | codefeedback |
You are tasked with implementing a feature for a web application that manages Gloomhaven campaigns. The application has a component that handles the selection and deletion of campaigns. The provided code snippet is a part of this component and includes the declaration of event emitters, a query list for element referen... | 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, excluding the highest and lowest scores.
Write a function `calculate_average_score(scores)` that takes in a list of integers `scores` and returns the average score, rounded to the nea... | codefeedback |
You are tasked with creating a Python function that processes time series data using pandas. The function should take in a DataFrame containing time series data and perform a specific time-based operation on it. The time series data is indexed by timestamps and contains a column named 'value' representing the values at... | codefeedback |
You are tasked with implementing a Python decorator that adds aliases to a function. The decorator should allow the function to be called using any of its original name or the specified aliases. Your task is to create a decorator `@task` that takes a tuple of aliases as an argument and applies them to the decorated fun... | codefeedback |
You are working on a file management system that involves checking for conflicts when creating a new resource. The system uses a specific naming convention for resources, and you need to implement a conflict resolution algorithm. The code snippet provided is a part of the conflict resolution logic.
The `resource_name... | codefeedback |
You are tasked with implementing a bounding volume hierarchy (BVH) construction algorithm for a ray tracer. BVH is a tree data structure used to organize objects in a scene for efficient ray intersection tests. Each node in the BVH represents an axis-aligned bounding box (AABB) that encloses a group of objects or sub-n... | codefeedback |
You are tasked with implementing a configurable test framework in Python. The framework should allow users to define and run test cases with customizable configurations. Each test case should be able to specify its own setup, teardown, and test logic, and should be configurable with parameters.
Your task is to create ... | codefeedback |
You are working on a software testing framework that includes a feature for automatically generating patch files to fix failing test cases. The code snippet provided is part of a script that is responsible for generating a patch file to fix failing test cases. The script uses environment variables and file paths to acc... | codefeedback |
You are tasked with implementing a message pipe configurator for a messaging system. The configurator is responsible for building and returning a configured message pipe. The message pipe is used to process and route messages within the messaging system.
You are given the following interface for the message pipe confi... | codefeedback |
You are tasked with creating a custom form view in a Django web application. Your task is to extend the functionality of the provided code snippet by adding a new method that handles form submission and processes the data.
Extend the `SampleView` class by adding a method named `form_valid` that will be triggered when... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.