instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a Python class for managing inventory items in a warehouse. The class should support adding new items, updating existing items, and retrieving information about items in the inventory. Each item in the inventory has a unique identifier, a name, a quantity, and a price.
Your task is to ... | codefeedback |
You are tasked with implementing a file explorer program that can navigate through a directory structure and display its contents. The program should support listing files and subdirectories within a given directory, as well as providing the ability to navigate into subdirectories and return to the parent directory.
Y... | codefeedback |
You are tasked with implementing a Swift extension for arrays that provides a safe way to access elements by index. The extension should include a method called `safe` that takes an index as a parameter and returns the element at that index if it exists, or `nil` if the index is out of bounds.
Your task is to complete... | codefeedback |
You are tasked with creating a web page that dynamically loads external JavaScript and CSS files based on user input. Your task is to implement a function that takes in a list of file URLs and appends corresponding `<script>` or `<link>` tags to the HTML `<head>` section. The function should also ensure that duplicate ... | codefeedback |
You are working on a graphics rendering engine and need to implement a method for creating render objects. The `create_render_object` function takes in various parameters and returns a `Box` containing a render object. Your task is to complete the implementation of this method by creating a new render object using the ... | codefeedback |
You are given a Python code snippet that appears to be part of a larger program. The code snippet includes a series of print statements that display information about solutions and their associated costs and vertex covers (VC) in a graph. Your task is to create a programming problem based on this code snippet.
Write a... | codefeedback |
You are tasked with implementing a JSON view parser in Java. The parser should be able to parse a given JSON string and extract specific values based on a provided view. The view is a string that represents a path to the desired value within the JSON structure. The JSON string will be a valid JSON object containing key... | codefeedback |
You are tasked with creating a program to simulate an Intcode computer. The Intcode computer processes a sequence of integers and performs specific operations based on the opcode and parameter modes. The opcode is the rightmost two digits of the first value in an instruction, and the parameter modes are single digits, ... | codefeedback |
You are tasked with implementing a Python class for a confusion matrix, which is a specific table layout that allows visualization of the performance of an algorithm. The confusion matrix class should be able to handle multi-class classification problems and provide methods for calculating various performance metrics.
... | codefeedback |
You are tasked with creating a program that processes a list of encountered macros and generates a source file containing the macro definitions. The macros are represented as a tuple containing the macro itself, its arguments, and raw arguments. Your task is to implement a function that takes this list of encountered m... | codefeedback |
You are given a set of SIMD (Single Instruction, Multiple Data) intrinsic functions from the Intel Intrinsics Guide. These intrinsics are used for performing operations on 256-bit vectors using Intel's Advanced Vector Extensions (AVX) instruction set.
Your task is to implement a function that takes two 256-bit integer... | codefeedback |
You are tasked with implementing a RESTful API for a location-based service. The provided code snippet is a partial implementation of a Location class that extends a REST_Controller. Your task is to complete the implementation of the Location class by adding methods to handle various HTTP requests for location-related ... | codefeedback |
You are tasked with implementing a generic trait for working with binary data in Rust. The trait, named `Word`, is intended to provide methods for loading and storing binary data from a buffer. The `load` method is responsible for reading binary data from a buffer and converting it into the appropriate data type, while... | codefeedback |
You are tasked with creating a program to manage the production readiness checklist for containerized applications. The checklist consists of various items, each with a name and a corresponding readiness status. Your program should allow users to add new checklist items, update the readiness status of existing items, a... | codefeedback |
You are tasked with implementing a command-line interface for running package tests. The given code snippet is a simplified representation of a Python class `TestCommand` that inherits from `BaseCommand`. The `TestCommand` class is intended to be used as a command-line interface for running tests for a package. It has ... | codefeedback |
You are tasked with creating a configuration file parser for a PHP application. The configuration file contains an array of storage drivers, each with specific settings. Your goal is to write a function that parses this configuration and returns an array of storage driver configurations.
The configuration file format ... | codefeedback |
You are tasked with creating a script to manage dotfiles, which are configuration files for various programs and tools. Dotfiles are typically stored in a version-controlled directory and symlinked to the user's home directory. The provided code snippet is the beginning of a shell script for managing dotfiles. The scri... | codefeedback |
You are tasked with creating a script to automate the process of generating a temporary authentication token for a relay gateway. The script should execute a specific command to create the token and then extract the token value from the command's output for later use. Your task is to write a Bash script that accomplish... | codefeedback |
You are tasked with creating a Python program that processes command-line arguments using the `argparse` module. Your program should accept two optional arguments: `--input` and `--output`. The `--input` argument should specify the input file path, and the `--output` argument should specify the output file path. If the... | codefeedback |
You are tasked with creating a program that reads a text file, removes any duplicate lines, and writes the unique lines back to the file. You should implement a function `remove_duplicates` that takes a file path as input and modifies the file in place.
The function should read the content of the file, remove any dupl... | codefeedback |
You are given a C++ code snippet that includes the beginning of a function called `sum_digits`. The function takes a parameter of type `BigInteger` and is expected to calculate the sum of the digits of the given `BigInteger` value. Your task is to complete the implementation of the `sum_digits` function and ensure that... | codefeedback |
You are tasked with creating a Rust function that listens to incoming TCP connections and processes the received messages. Your function should utilize the Tokio asynchronous runtime to handle the TCP connections and messages.
Write a function `listen_and_process_tcp` that takes the following parameters:
- `address: &... | codefeedback |
You are tasked with creating a Bash script that automates the process of setting ownership for a directory based on certain conditions. The script should take in two arguments: the directory path and the owner's username. The script should perform the following steps:
1. Check if the directory exists. If it does not ex... | codefeedback |
You are tasked with creating a validation function for optional address parameters in a Node.js application. The function should check if a specific parameter exists in the request object and, if so, call another validation function to handle the address parameter. If the parameter does not exist, the function should a... | codefeedback |
You are tasked with creating a program to render 3D shapes using OpenGL. Your goal is to implement a function that generates a textured torus on the GPU and then renders it using a specified pipeline.
You are given the following code snippet as a starting point:
```python
glEnable(GL_DEPTH_TEST)
# Creating s... | codefeedback |
You are tasked with creating a Python class for visualizing time series data using matplotlib. The class should be able to plot time series data and provide interactive features for exploring the data. Your task is to implement the `TimeSeriesViewer` class with the following requirements:
1. The class should inherit f... | codefeedback |
You are tasked with creating a custom annotation in Java that can be used to annotate classes and specify a numeric data type. The annotation should allow the user to define the type of numeric data that the annotated class will work with. Your task is to implement the custom annotation `LinguisticPartition` and demons... | codefeedback |
You are tasked with creating a program to validate credit card numbers based on the first digit and the Luhn algorithm. The Luhn algorithm is used to validate a variety of identification numbers, such as credit card numbers. The algorithm is as follows:
1. Starting from the rightmost digit, double every second digit. ... | codefeedback |
You are tasked with creating a validation function for a medical form that collects information about patients. The form includes various fields, each with specific validation requirements. Your task is to implement a function that takes in the form data and validates it based on the given rules.
The form fields and t... | codefeedback |
You are tasked with creating a Python function that retrieves files from a Telegram chat and calculates the total size of all the files combined. You are given a code snippet that iterates through the files in a chat and makes a request to the Telegram API to retrieve each file's information. Your task is to complete t... | codefeedback |
You are tasked with creating a Python function that analyzes the memory usage of a system and returns the total free memory in kilobytes. The function should also retrieve a list of currently logged-in users on the system.
You are provided with a partial code snippet that includes a method for calculating free memory ... | codefeedback |
You are given a string `s` of length `n`. Your task is to write a function or method to find the length of the shortest substring that can be repeated to form the original string. If no such substring exists, return 0.
For example, given the string "abcabcabc", the shortest repeating substring is "abc", and its length... | codefeedback |
You are tasked with implementing a custom iterator class in Python that iterates over a sequence of Fibonacci numbers. The iterator should return the next Fibonacci number in the sequence each time it is called. Additionally, the iterator should have a maximum iteration limit to prevent infinite iteration.
Your task i... | codefeedback |
You are tasked with creating a Python function that validates a given dictionary against a set of predefined validation rules. The function should check if the dictionary adheres to the specified rules and return a boolean value indicating whether the validation was successful or not.
The validation rules are defined ... | codefeedback |
You are tasked with creating a Python class that represents a product in an inventory management system. The class should have attributes for the unit price and units of the product. Additionally, you need to implement a method that calculates the total price based on the quantity of units purchased.
Create a Python c... | codefeedback |
You are tasked with creating a program to match users with nearby locations based on their geographical coordinates and search radius. Given a list of users with their email addresses and zip codes, along with a list of locations and their coordinates, the program should identify which users are near which locations wi... | codefeedback |
You are tasked with creating a Python program that simulates a simple task queue system using the `rq` library. The program should allow users to enqueue tasks, process them, and retrieve the results. Each task represents a simple computation, and the results should be stored for later retrieval.
Your program should h... | codefeedback |
You are tasked with creating a function that reads a CSV file containing job information and validates its format. The CSV file contains the following columns: ID, LAT, LNG, DEMAND, DURATION, TW_START, and TW_END. Each row represents a job with its corresponding attributes. The function should check for any format erro... | codefeedback |
You are tasked with implementing a class hierarchy for a 2D game development framework. The framework includes a base class `GameObject` and a subclass `Prefab` that represents predefined settings for game objects. Your goal is to implement the `Prefab` class and its method `getPrefabSettings` to return the default set... | codefeedback |
You are tasked with implementing a multi-threaded locking mechanism for a shared resource. The provided code snippet outlines the interface for the locking mechanism, which includes two functions `tryLockRead()` and `tryLockWrite()` for attempting to acquire read and write locks, and a function `lockStatus()` for check... | codefeedback |
You are tasked with implementing a Python class that processes data requests for an Advanced Planning and Scheduling (APS) system. The APS system uses a custom protocol for communication, and the provided code snippet is a partial definition of a data request class.
Your task is to complete the implementation of the `... | codefeedback |
You are tasked with implementing a custom PHP class that manipulates single-line strings. The class, `SingleLineString`, should provide methods for performing various operations on single-line strings, such as concatenation, trimming, and checking for specific substrings.
Your task is to implement the following method... | codefeedback |
You are tasked with implementing a Rust module system for managing environments, statuses, templates, and workspaces. The provided code snippet outlines the module structure and the public exports for each module. Your goal is to create the necessary structs and traits to support the functionality of the module system.... | codefeedback |
You are tasked with implementing a function to calculate the total number of occurrences of a given word in a collection of text files. The function should take in the directory path where the text files are located and the target word to search for. The function should recursively search through all text files in the ... | codefeedback |
You are tasked with creating a program that simulates a simple compiler pass system. A compiler pass is a specific stage in the compilation process where the compiler performs a particular analysis or transformation on the code. In this problem, you will implement a simplified version of a compiler pass system using ob... | codefeedback |
You are tasked with creating a program to parse HTML content and extract specific information from it. In this problem, you will focus on extracting the URL and the displayed text from an anchor tag in an HTML snippet.
Given an HTML snippet as a string, you need to write a function that extracts the URL and the displa... | codefeedback |
You are tasked with implementing a tab completion feature for a text editor. Tab completion is a common feature in many programming environments that suggests and completes partially typed words or commands when the user presses the "Tab" key. Your task is to create a function that takes in the current input, the curso... | codefeedback |
You are tasked with implementing a Python class to represent the days of the week and a function to calculate the nth day from a given day. The code snippet provided contains a partial implementation of the Day class and the nthDayFrom function. Your task is to complete the implementation of the Day class and the nthDa... | codefeedback |
You are tasked with implementing a lock management system using Python's asyncio library. Your goal is to create a class that can acquire and release locks to ensure exclusive access to a shared resource. The provided code snippet outlines the beginning of a `LockOps` class, which is a subclass of `CoordinatorOp`. Your... | codefeedback |
You are working on a project that involves processing and analyzing textual data. As part of this project, you need to implement a custom text vectorization function that maps textual data to numerical vectors. The vectorization process involves creating a mapping between item IDs and subject IDs, and then using a vect... | codefeedback |
You are tasked with implementing a singleton pattern for a class called `CodeObjectManager`. The provided code snippet outlines a part of the implementation for this class. The `CodeObjectManager` class is responsible for managing code objects and providing access to them.
The class has the following methods:
1. `Inst... | codefeedback |
You are tasked with implementing a function that emulates the behavior of the `groupby` and `size` functions in Python. The `groupby` function is used to group data based on specified columns, and the `size` function is used to count the occurrences of each group. Your task is to create a function that takes a DataFram... | codefeedback |
You are tasked with implementing a graph data structure in Python to represent a network of interconnected nodes. Each node in the graph has a unique identifier and may be connected to other nodes through edges. The graph is represented using an adjacency list.
Your task is to implement a Python class `Graph` with the... | codefeedback |
You are given a scenario where ladybugs are placed on a line. Each ladybug is initially represented by a number, where 0 indicates an empty position and 1 indicates the presence of a ladybug. The ladybugs are currently arranged in an array called `ladybugs`. Your task is to implement a function that rearranges the lady... | codefeedback |
You are tasked with implementing a command-line tool for analyzing electronic band structures in a material simulation. The tool will parse user-provided arguments to customize the analysis. Your task is to implement the logic for parsing the command-line arguments and performing the specified actions based on the prov... | codefeedback |
You are working on a web application that uses the Django framework for its backend. The application has a URL configuration file where different URL patterns are mapped to corresponding views. The code snippet provided is a part of the URL configuration file.
Your task is to create a function that takes a URL pattern... | codefeedback |
You are tasked with implementing a Swift protocol for managing transactions of consumable products in an e-commerce application. The protocol should include two properties: `transactionIdentifier` and `quantity`. The `transactionIdentifier` property should be a string representing the unique identifier for the transact... | codefeedback |
You are tasked with implementing a simple stack data structure in Swift. A stack is a last-in, first-out (LIFO) data structure that supports two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack. Your task is to create a Swift class called `Stack... | codefeedback |
You are given a code snippet that manipulates a 3D array `function_array` using NumPy operations. The array represents a mathematical function and is indexed by `n` and `m`. The code snippet performs operations to update the values of `function_array` based on certain mathematical calculations involving `n`, `m`, and `... | codefeedback |
You are tasked with creating a program that simulates a simple online shopping system. The program should allow users to add items to their cart, view the items in their cart, and calculate the total cost of the items in the cart. The program should also handle the connection to the database where the items are stored.... | codefeedback |
You are tasked with implementing a Python interface for managing and measuring data streams using gRPC (Google Remote Procedure Call) in a hypothetical system for evaluating network performance. The provided code snippet outlines the abstract methods and type hints for the interface, but it lacks the actual implementat... | codefeedback |
You are tasked with creating a Python function that processes a list of organizations and their associated users. The function should perform the following tasks:
1. Filter out organizations that are associated with a specific registrar.
2. For each remaining organization, count the number of users associated with it.
... | codefeedback |
You are tasked with implementing a text classification model using TensorFlow and Keras. The goal is to create a program that preprocesses a dataset of text documents, trains a neural network model, and evaluates its performance.
You are provided with a partial implementation of a Catalog class that will be used to ma... | codefeedback |
You are tasked with creating a simple game using the Pygame library in Python. The game involves a player-controlled character that moves across the screen, and the player must avoid obstacles to score points. The player's score increases as they successfully navigate through the obstacles. To make the game challenging... | codefeedback |
You are tasked with implementing a theme manager for a desktop application. The theme manager is responsible for setting the color scheme and icon for various UI elements based on whether the current theme is light or dark. You are given a partial code snippet from the theme manager implementation, which includes the i... | codefeedback |
You are tasked with creating a function to process a tile map for a 2D game. The tile map is represented by layers, and each layer contains tiles with unique global IDs (GIDs). Your goal is to implement a function that retrieves the tiles with a specific global ID from a given layer and then performs a validation check... | codefeedback |
You are tasked with implementing a simple rendering system for a user interface library. The library uses a declarative syntax to define the UI structure and components. Your goal is to create a function that can parse the given declarative syntax and render the UI accordingly.
You are provided with a code snippet tha... | codefeedback |
You are tasked with implementing a delegate pattern in Swift to handle user selection in a multi-user selection view. The code snippet provided is a method within a Swift class that is responsible for notifying the delegate when the user submits their selection. The `didSubmit` method is called when the user submits th... | codefeedback |
You are tasked with creating a Python script that monitors the system's performance and stores the data in a database. The script should utilize multiprocessing to concurrently collect system information and store it in a database. The system information to be collected includes CPU usage, memory usage, disk usage, and... | codefeedback |
You are given a partially completed Swift code snippet that defines a generic function. Your task is to complete the function and write a test case to verify its functionality.
Complete the function `s` which takes a generic type `D` that conforms to protocol `A` and returns a tuple containing two elements. The first ... | codefeedback |
You are tasked with implementing a Python class that counts the occurrences of a given pattern in a biomodel. The biomodel is represented using the SBML (Systems Biology Markup Language) format, and the pattern is a specific combination of biomodel elements.
Your task is to complete the implementation of the `Biomodel... | codefeedback |
You are given a code snippet that appears to be part of a program to find the maximum value of a specific function. Your task is to complete the program by implementing the missing parts and then using it to find the maximum value of the function over a given range of values for variable 'a'.
The function to be maximi... | codefeedback |
You are tasked with creating a PHP class method that handles the deletion of records from a database table. The given code snippet shows a method named `excluir` within a class. This method takes an `$id` parameter and uses it to delete a record from the `categorias` table in the database. Your task is to complete the ... | codefeedback |
You are tasked with creating a Rust macro that generates a wrapper struct for a given input struct. The wrapper struct should implement a specific trait for the input struct. Your task is to complete the macro implementation to achieve this functionality.
You are provided with the following code snippet as a starting ... | codefeedback |
You are tasked with implementing an image processing function that performs upsampling on a given image using TensorFlow. The function should take an input image and increase its dimensions by duplicating the pixel values to create a larger image.
You are provided with a code snippet that contains a static method `upS... | codefeedback |
You are tasked with implementing a dynamic array data structure in TypeScript. The dynamic array should be able to grow in size as elements are added to it. You are provided with a `growable_array_buffer.ts` module that contains the necessary functionality for managing the underlying buffer of the dynamic array. Your t... | codefeedback |
You are given an array of integers representing the weights of ropes and an integer `n`. The goal is to find the maximum possible weight that can be achieved by connecting the ropes in a specific way. The weight of each rope is multiplied by `n`, where `n` starts from 1 and increments by 1 for each subsequent rope. Aft... | codefeedback |
You are tasked with implementing a Python class for a multilabel classifier. The class should include a method for training the classifier and a method for making predictions. Additionally, you need to implement a class for the multilabels head, which will be used as part of the classifier.
Your task is to complete th... | codefeedback |
You are tasked with implementing a class that manages a bulk processing system for a database. The class should handle the configuration of the database connection and the bulk processing of data.
You are provided with a code snippet that contains some configuration settings and constants related to the database conne... | codefeedback |
You are tasked with implementing a contact merging algorithm to consolidate duplicate contacts in a contact list. Each contact is represented as a list of strings, where each string represents a piece of contact information (e.g., name, phone number, email). The algorithm should merge contacts that share at least one p... | codefeedback |
You are given a binary tree and a function that performs a level-order traversal of the tree and returns a list of the traversed nodes. The code snippet provided is a part of the level-order traversal function. The function uses a queue to traverse the tree level by level and appends the traversed nodes to a list calle... | codefeedback |
You are working on a script to automate the configuration of a system's hosts file. The hosts file is a plain text file used by operating systems to map IP addresses to hostnames. Your script needs to add entries to the hosts file in a specific format. The code snippet provided is a part of the script and is responsibl... | codefeedback |
You are tasked with implementing a C++ template meta-programming problem. Your goal is to create a meta-function called `tuple_template_forward_t` that takes a template template parameter and a tuple type as its arguments and returns a new tuple type with the same element types as the input tuple type, but wrapped in t... | codefeedback |
You are tasked with creating a command-line utility that simulates a simple file system navigation and execution of Java programs. The utility should support changing directories and executing Java programs within the specified directory.
Your task is to implement a program that takes a series of commands as input and... | codefeedback |
You are tasked with implementing a Java class that manages the configuration for saving authentication results in a web application. The class should handle the storage of authentication results and provide methods for retrieving and manipulating the saved data.
Your task is to create a class named `AuthenticationResu... | codefeedback |
You are tasked with implementing the insertion sort algorithm for sorting a list of integers in non-decreasing order. Insertion sort works by iteratively building a sorted portion of the list, one element at a time, by shifting larger elements to the right. Your task is to complete the implementation of the `insertion_... | codefeedback |
You are tasked with implementing a Python function that calculates the gradient of a given function with respect to its input parameters using the finite difference method. The finite difference method is a numerical technique for estimating the derivative of a function at a particular point by evaluating the function ... | codefeedback |
You are tasked with implementing a StateManager class that manages multiple StateMachine instances. Each StateMachine represents a state machine with a specific name and a set of possible states. The StateManager should allow adding StateMachine instances and provide methods to transition the states of the machines.
Y... | codefeedback |
You are given an array of positive integers. Your task is to write a function `ArrayAdditionI` that will determine whether any combination of the numbers in the array can be added together to produce the largest number in the array. The function should return `true` if such a combination exists, and `false` otherwise.
... | codefeedback |
You are tasked with implementing a custom macro in Rust that mimics the behavior of the `hset!` macro shown in the code snippet. The `hset!` macro is designed to create a `HashSet` with literal values that are automatically converted into the appropriate type. Your task is to create a similar macro called `my_hset!` th... | codefeedback |
You are tasked with implementing a function that processes styles and functions to generate CSS for a React component. The function takes in styles, an array of functions, and a theme object. The styles can be an array of strings, a function, or a string. The functions in the array can take the props and theme as argum... | codefeedback |
You are tasked with creating a command-line utility that simulates a simple fishing game. The game will take a list of fish species and their corresponding probabilities as input, and then simulate the act of fishing for a certain number of times. The output should display the number of times each fish species was caug... | codefeedback |
You are tasked with creating a custom hook in a Yew-based web application. Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly. In this problem, you will be implementing a custom hook called `use_is_mounted` that returns a boolean value indicating whether the component is curr... | codefeedback |
You are given a task to write a function to determine whether a given integer is a power of three.
Write a Python function called `is_power_of_three` that takes an integer `n` as input and returns `True` if `n` is a power of three, and `False` otherwise.
For example, if the input is `27`, the function should return `... | codefeedback |
You are tasked with implementing a class for a table editor in Python. The class contains three methods: `cancelEdits`, `canEditColumn_atRow_`, and `deleteSelectedRows`. The `cancelEdits` method is responsible for canceling any ongoing edits in the table. The `canEditColumn_atRow_` method takes a column and row as inpu... | codefeedback |
You are tasked with creating a function that extracts and counts the occurrences of specific HTML tags within a given HTML string. The HTML string will contain various tags, and the function should return a dictionary where the keys are the tag names and the values are the counts of each tag in the string.
For example... | codefeedback |
You are tasked with implementing a function to calculate the word count of each news article in a dataset using parallel processing. The dataset is initially loaded from disk, and then a word count column is added to each article. The dataset is processed in batches using multiple processes to improve efficiency.
Your... | codefeedback |
You are tasked with creating a Python function that generates a configuration file for a machine learning model. The function should take in several input parameters and construct a configuration file with the appropriate paths and settings. The configuration file will be used to store paths for model output, model dir... | codefeedback |
You are tasked with implementing a custom error renderer for a 3D graphics engine. The provided code snippet is the beginning of the header file for the `GLErrorRenderer` class, which is a subclass of `DefaultRenderer`. Your task is to complete the implementation of the `GLErrorRenderer` class by adding member function... | codefeedback |
You are tasked with implementing a health check system for a distributed system. The system consists of multiple daemons running on different machines, and it is essential to periodically check the health of these daemons to ensure the overall system's reliability. Each daemon sends a heartbeat signal at regular interv... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.