instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a function to calculate the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take two integer parameters, `start` and `end`, representing the inclusive range within... | codefeedback |
You are tasked with implementing a function that processes work orders in a manufacturing system. The function should take a dictionary of values as input and update the production schedule with the planned finish date for the work order.
You are given the following code snippet as a reference:
```python
if values['d... | codefeedback |
You are tasked with implementing a Python class for representing 3D vectors and edges in a geometric context. The class `Vector3` represents a 3D vector with x, y, and z components, and the class `Edge` represents an edge connecting two 3D points. Your task is to implement the missing methods for the `Vector3` and `Edg... | codefeedback |
You are given a code snippet that is part of a script used to process data from a quantum mechanics simulation. The script is designed to extract specific data from a file called EIGENVAL and manipulate it to create new files. Your task is to write a program that simulates the data processing steps described in the cod... | codefeedback |
You are tasked with implementing a custom data structure in C# to manage a collection of items with the following requirements:
1. The data structure should be able to store items of any data type.
2. It should support adding items to the collection, removing items from the collection, and checking if a specific item i... | codefeedback |
You are tasked with optimizing a query for retrieving transportation service information based on geographical proximity. The given code snippet is a part of a Python function that performs a database query to find transportation services and stops within a certain radius of a given location. The function takes into ac... | codefeedback |
You are tasked with implementing a Python function that calculates the total cost of a customer's purchase, factoring in both the base price of the items and any additional costs. The function should accept a variable number of keyword arguments, where each keyword represents an item and its associated price. Additiona... | codefeedback |
You are tasked with implementing a function that processes a sequence of integers and returns the longest increasing subsequence (LIS) present in the sequence. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. An i... | codefeedback |
You are tasked with implementing a multi-threaded program that simulates a simple semaphore mechanism. A semaphore is a synchronization construct that can be used to control access to a shared resource. In this problem, you are required to implement a class `CustomSemaphore` that provides the functionality of a semapho... | codefeedback |
You are tasked with implementing a function that simulates the movement of data between different types of registers in a low-level assembly language. The assembly language in question is used for a specific architecture and supports operations for moving data between floating-point registers, general registers, and re... | codefeedback |
You are working on a performance analysis tool for a machine learning model. The code snippet provided is a part of the tool that measures the average inference time and average summary time for the model. The `info` dictionary contains information about each inference, including the `invoke_time` for each inference. T... | codefeedback |
You are tasked with implementing a function to parse and extract information from a given Python code snippet. The code snippet contains a series of backtick-delimited strings and a conditional block. Your task is to extract the backtick-delimited strings and the conditional block, and then process the information to g... | codefeedback |
You are tasked with implementing a function to calculate the first and second derivatives of the joints in a two-joint arm system. The function `animatearm` is responsible for animating the movement of the two-joint arm using matplotlib. Your task is to create a Python function that computes the derivatives and then us... | codefeedback |
You are tasked with creating a custom React component that renders a horizontal list of items using styled-components. The component should accept an array of items as a prop and render each item as a list element in a horizontal layout.
Your task is to complete the `HorizontalList` component by using the `styled-comp... | codefeedback |
You are tasked with creating a Rust function that processes a given source code and generates a byte vector based on certain options and a header flag. The function should handle potential errors and return the result as a `Result<Vec<u8>, Error>`.
The function signature is as follows:
```rust
fn generate(source: &str... | codefeedback |
You are tasked with implementing a thread-safe data structure called `ConcurrentSet` in Swift. The `ConcurrentSet` should support adding and removing elements concurrently using Grand Central Dispatch (GCD) to ensure thread safety. The `ConcurrentSet` should have the following methods:
1. `add(_:)`: This method should... | codefeedback |
You are tasked with implementing a function that corrects the angles of a scope based on a given period. The function takes in three parameters: `angles0`, `angles1`, and `scope_id`. The `angles0` and `angles1` parameters are NumPy arrays representing the initial and final angles of the scope, and `scope_id` is an inte... | codefeedback |
You are tasked with implementing a decoding proxy for reading data from a source. The proxy should be able to decode the data as it is read and provide the decoded content to the consumer. Your task is to design and implement the `DecodingReadProxy` struct in Rust, which will act as a proxy for reading and decoding dat... | codefeedback |
You are tasked with debugging a section of code that sets up routes for an API using the Dingo API package in a Laravel application. The code snippet provided contains a portion of the route setup, but it seems to have a potential issue. Your task is to identify the problem and propose a solution to fix it.
Given the ... | codefeedback |
You are tasked with implementing a Python class that simulates a simple multi-agent environment for a scenario. The scenario is defined in a separate Python file and is loaded dynamically. Your goal is to create the environment using the provided code snippet as a guide.
Your task is to implement the `MultiAgentEnv` c... | codefeedback |
You are tasked with implementing a Swift data structure for managing images and their associated metadata. The structure, `ImageContainer`, is designed to hold an image along with optional metadata such as type, preview status, additional data, and user information. Additionally, the structure provides a method to modi... | codefeedback |
You are tasked with creating a Python package version checker. Your program should take in the name of a Python package and return its version and license information. You can assume that the package is installed in the current Python environment.
Write a function `package_info` that takes a string `package_name` as i... | codefeedback |
You are tasked with creating a program that simulates a simple fluid dynamics system. The fluid simulation will be represented by a grid of cells, and the fluid will flow between adjacent cells based on certain rules.
Your task is to implement a function `simulateFluid` that takes the following parameters:
- `grid`: a... | codefeedback |
You are tasked with creating a program that simulates a simple package manager for a fictional operating system called "MyOS." The package manager should be able to handle the installation of new packages and display a list of installed packages. Each package can have dependencies on other packages, and the package man... | codefeedback |
You are tasked with implementing a module manager class in Python. The module manager should support adding, retrieving, and removing modules by name. Each module has a name and a version. You need to implement the `ModuleManager` class with the following methods:
- `add_module(module_name, module_version)`: Adds a mod... | codefeedback |
You are tasked with creating a Python function that simulates a network device interaction using the `scrapli` library. The function will take in a list of interaction events and a list of strings that represent failed commands/interactions. The function will then use the `scrapli` library to send the interaction event... | codefeedback |
You are tasked with implementing a simplified version of a party invitation system. The system should handle the process of inviting guests to different parties and handle any errors that may occur during the invitation process.
You are given a code snippet that represents a part of the invitation system. The snippet ... | codefeedback |
You are tasked with implementing a simple Object-Relational Mapping (ORM) system in Swift. The provided code snippet is part of a database access layer that interacts with the underlying database using SQL queries. Your task is to extend this ORM system by implementing the `getOrm` function and the `deleteBuilder` and ... | codefeedback |
You are tasked with implementing a TypeScript interface and a function that utilizes this interface. The interface represents a message definition, and the function is responsible for constructing a message based on the provided parameters.
Interface:
```typescript
interface MessageDefinition {
value: string | Objec... | codefeedback |
You are tasked with implementing a custom context lookup mechanism for a web application framework. The `MockContext` class provides a method `lookup` that takes in a key and a variable number of lookup types (e.g., PATH, HEADER, COOKIE, FLASH, SESSION, QUERY, FORM, MULTIPART) and returns a corresponding `Value` object... | codefeedback |
You are tasked with implementing a simple registration system for classes in a C++ namespace using the given code snippet as a reference. The code snippet demonstrates the registration of a class `VertexGlyphFilter` within the `quick::Vtk` namespace using the `Qml::Register::Class` function. Your task is to create a si... | codefeedback |
You are tasked with implementing a program that processes C++ header files to extract specific information. In this problem, you are required to write a function that takes a string representing the content of a C++ header file and extracts the name of the header file from the `#endif` directive.
You need to implement... | codefeedback |
You are tasked with implementing a function that checks whether the given dictionary of boundary pairs is valid. A boundary pair consists of two boundary names separated by an equals sign. The function should return True if the dictionary is valid, and False otherwise.
The function should take a single argument:
- `pB... | codefeedback |
You are tasked with implementing a method to calculate the real item count in a hierarchical data structure. The structure consists of nodes, each potentially containing child nodes. The method should take into account the depth of the nodes and return the total count of all items in the hierarchy.
You are given the f... | codefeedback |
You are tasked with implementing a function to calculate the positions of control points for a Bezier curve based on given parameters. The Bezier curve is defined by four points: two anchor points (to1 and to2) and two control points (control1 and control2). The function should take the following inputs:
- `reverseFrac... | codefeedback |
You are tasked with creating a Rust macro that generates code for accessing memory-mapped registers in an embedded system. The macro should provide a convenient and safe way to access the MPU Type Register, which indicates the number of regions the Memory Protection Unit (MPU) supports. The MPU Type Register is located... | codefeedback |
You are tasked with creating a function that processes payment updates from a payment service provider and stores the payment details in a database. The function will receive a JSON string representing a payment update and will need to perform the following steps:
1. Deserialize the JSON string into a `PaymentUpdate` o... | codefeedback |
You are tasked with implementing a function that compares two DataFrames and checks if they are equal, with the option to ignore schema metadata such as comments. The function should handle cases where one or both DataFrames are None.
Write a Python function `compare_dataframes` that takes in four parameters:
1. `expe... | codefeedback |
You are tasked with implementing a simple notification library in Rust. The library should allow users to subscribe to various events and receive notifications when those events occur. Your task is to create a `NotificationLibrary` struct with the following methods:
1. `new()`: This method should create a new instance ... | codefeedback |
You are tasked with implementing a Python function that simulates a simple vending machine. The vending machine will have a set of available items, each with a specific price. The function should take the item name and the amount of money inserted by the user as input and return the appropriate response based on the fo... | codefeedback |
You are tasked with creating a Rust function that processes data from an API response and returns a specific result. The function `parse_response_body` is responsible for parsing the response body, and the `get_modules` function is intended to retrieve a list of modules from an IoT hub. Your task is to implement the `p... | codefeedback |
You are tasked with implementing a C++ concept checking utility for argument providers of expandables. An argument provider of expandables is a type that can provide a sequence of arguments, where the number of arguments can vary at runtime. Your goal is to define a concept that checks whether a given type satisfies th... | codefeedback |
You are tasked with implementing a method to delete a product from a database using PHP and Laravel. The method should handle the deletion of the product and return a success message upon successful deletion.
You are given the following code snippet as a starting point:
```php
public function update(EditProductReques... | codefeedback |
You are tasked with implementing a squeeze-and-excite block, a component commonly used in convolutional neural networks to enhance feature representation. The block consists of two main steps: squeeze and excitation. The squeeze step involves reducing the spatial dimensions of the input tensor to a single vector, while... | codefeedback |
You are tasked with creating a function that processes a list of file paths and returns the count of files with a specific file extension. The function should be able to handle different operating systems and file path formats.
You are given a code snippet that includes a test function for a Windows-specific feature.... | codefeedback |
You are tasked with implementing a simple dependency injection container in Swift. The container should be able to register and resolve dependencies using a protocol-oriented approach.
Your task is to create a `DependencyContainer` class that allows registering and resolving dependencies. The container should support ... | codefeedback |
You are tasked with implementing a function to copy a subset of biases from one array to another. The provided code snippet is a partial implementation of the function `copy_biases_linear`, which takes in two arrays `biases` and `biases_local_1`. The function is intended to copy a subset of biases from the `biases` arr... | codefeedback |
You are tasked with implementing a Python class that publishes messages to an MQTT broker using the Paho MQTT client library. The class should handle the connection to the broker and provide a method for publishing messages. Your task is to complete the implementation of the `PublishAction` class by adding the necessar... | codefeedback |
You are tasked with implementing a function that takes in an array of integers and returns the maximum sum of a contiguous subarray within the input array. The function should efficiently handle both positive and negative numbers.
You need to implement the following function:
```php
/**
* Find the maximum sum of a c... | codefeedback |
You are tasked with creating a custom Angular directive that will enhance the functionality of buttons in a web application. The directive should be able to handle different button states and styles based on the provided examples.
You are given a code snippet that demonstrates the expected behavior of the directive. T... | codefeedback |
You are working on a project to model the growth and mortality of a specific plant species in a given environment. The project involves analyzing various parameters that influence the plant's survival and growth. One such parameter is the flow velocity of water, which has a significant impact on the plant's mortality r... | codefeedback |
You are tasked with implementing a simple 2D game where a player can move in different directions based on user input. The game uses a camera to control the player's view and movement. The given code snippet is a part of the game's movement logic. The `inputFlags` variable is a bit field representing the user's input, ... | codefeedback |
You are working on a data processing pipeline for a system that collects and analyzes sensor data. The pipeline consists of several scripts that process and store the data. You need to write a script to automate the processing of the collected data.
The provided code snippet is part of a shell script that processes th... | codefeedback |
You are working on a bioinformatics project and need to implement a method for extracting the 5' to 3' sequence of a transcript. The provided code snippet is part of a larger Python program that defines a model for transcript data and includes a method `get_seq` within the model class. Your task is to implement the `ge... | codefeedback |
You are tasked with implementing a function that converts a JSON value to an unsigned 64-bit integer. The function should handle different cases and return an error code if the conversion is not possible.
You are given the following code snippet as a starting point:
```rust
Some(obj) => Ok(obj),
None ... | codefeedback |
You are tasked with implementing a permission-based filtering system for a file management application. The application has two relevant models: `Folder` and `AccessEntry`. The `Folder` model represents folders in the file system, and the `AccessEntry` model represents access permissions for users on folders. Each `Acc... | codefeedback |
You are tasked with creating a Python class that acts as an adapter plugin for a data processing framework. The adapter plugin will be responsible for connecting to a specific data source and retrieving data using the provided credentials. Your task is to implement the `AdapterPlugin` class and its associated component... | codefeedback |
You are tasked with creating a Python function to generate a GIF from a series of images. The function should take in a file name prefix and the output file name as parameters. Each image file should be named with the prefix followed by a sequential number (e.g., "image1.png", "image2.png", etc.). The function should t... | codefeedback |
You are tasked with implementing a Python function that calculates the numerical derivative of a given objective function using the central difference method and then visualizing the results using a logarithmic plot.
Write a function `numerical_derivative_and_plot(obj_func, baseline_objective, epss)` that takes in thr... | codefeedback |
You are tasked with creating a Python class that tracks function calls within specified modules. Your class should be able to record the modules and functions called, and provide a summary of the calls made.
Create a Python class `CallTrackerEngine` with the following specifications:
- The class should have an `__init... | codefeedback |
You are tasked with implementing a data processing algorithm that involves dividing a large dataset into smaller blocks and performing calculations on each block. The given code snippet is a part of the algorithm and contains some variables and print statements. Your task is to complete the implementation of the algori... | codefeedback |
You are working on a Python application that manages event data for a gaming guild. The provided code snippet is part of a class used to create and manipulate event objects. The class has a method to create an event object from a database row, as well as methods to set the actor and count attributes, and to insert the ... | codefeedback |
You are tasked with implementing a custom iterator for a fusion sequence in C++. Fusion is a library for working with heterogeneous sequences, providing a way to manipulate collections of different types in a uniform manner. Your goal is to create a custom iterator that can traverse a fusion sequence in a random-access... | codefeedback |
You are tasked with implementing a Python class that provides the functionality to fetch the contents of columns of several rows of a ContentResultSet with a single function call. The class should adhere to a specified interface and handle type checking.
Your task is to complete the implementation of the `XFetchProvid... | codefeedback |
You are tasked with creating a C++ class to monitor the CPU utilization of a Linux system. The class should utilize the provided `LinuxParser` class to retrieve the necessary system information. Your task is to implement the `Processor` class with a method `Utilization()` that calculates and returns the aggregate CPU u... | codefeedback |
You are tasked with creating a Python function that processes a list of student scores and returns the top N students based on their average scores. The function should also calculate the overall class average and identify any students who have scored below the class average.
You are given the following code snippet a... | codefeedback |
You are tasked with implementing a trading algorithm for a cryptocurrency exchange. The algorithm is designed to execute buy orders based on a specified price limit. Your task is to write a function that calculates the volume of the cryptocurrency to be bought based on the given price limit.
You are provided with a co... | codefeedback |
You are tasked with creating a Python function that processes a configuration dictionary and performs various operations based on the data provided. The configuration dictionary contains information about machines, runners, features, and users. Your task is to implement a function that takes this configuration dictiona... | codefeedback |
You are tasked with creating a Java program that processes a list of imported classes and extracts specific information from them. The program should identify and extract the names of the imported classes from the given code snippet and then display the unique imported class names in alphabetical order.
The given code... | codefeedback |
You are tasked with creating a program that calculates the average of a list of numbers. Your program should take a list of numbers as input and output the calculated average. You should ensure that the average is rounded to two decimal places and displayed with an appropriate message.
Write a Python function `calcula... | codefeedback |
You are tasked with creating a Python module that simulates a simple banking system. The module should include a class `BankAccount` with the following functionalities:
- Initialize a bank account with a given account number and initial balance.
- Deposit funds into the account.
- Withdraw funds from the account.
- Che... | codefeedback |
You are tasked with creating a program that generates test data for a fictional online shopping platform. The test data should include information about products, such as their names, prices, and categories. Additionally, the program should be able to generate data for multiple users, including their names, email addre... | codefeedback |
You are tasked with creating a test case for a mobile application using XCTest, Apple's testing framework for iOS applications. The application has a feature that allows users to log in with their credentials. Your goal is to write a test case that verifies the login functionality of the application.
The code snippet ... | codefeedback |
You are tasked with writing a script to automate the creation of a cluster and partition in a distributed computing environment. The script should use the provided list of agents and execute specific commands to set up the cluster and partition.
Given the following code snippet as inspiration:
```bash
AGENTS2="ag.14.... | codefeedback |
You are given a snippet of code that is part of a larger program. The variable `cleared` is being incremented by 1 within a loop. Your task is to write a function that takes an integer `n` as input and returns the value of `cleared` after `n` iterations of the loop.
Write a function `calculateClearedValue(n: int) -> i... | codefeedback |
You are given a snippet of code that reads from an input file to create a collection of particles. Each particle has a position (x, y) and a velocity (vx, vy). Your task is to write a program that processes the input file and calculates the final positions of the particles after a given number of steps.
The input file... | codefeedback |
You are tasked with implementing a function to parse and process file paths related to Python package distributions. The function should extract specific information from the file path and handle exceptions as specified.
You are given a code snippet that includes a function `substitute(target_relpath)` and a set `EXCE... | codefeedback |
You are working on a computer vision project and need to implement data augmentation using the Albumentations library in Python. Your task is to create a function that applies a series of image transformations to a given dataset using Albumentations and then converts the augmented images to PyTorch tensors.
You are pr... | codefeedback |
You are tasked with implementing a validation system for a key-value pair data structure. The system should enforce specific rules for the key and value fields. The rules are defined in an associative array where the key represents the field name and the value represents the validation rule.
Your task is to write a fu... | codefeedback |
You are tasked with implementing a change detection algorithm for a data stream. The Adaptive Windowing (ADWIN) algorithm is a popular method for detecting changes in data streams. The ADWIN algorithm dynamically adjusts the window size to adapt to changes in the data distribution. Your task is to implement the ADWIN a... | codefeedback |
You are tasked with implementing a simple factory pattern in C++ to create instances of different Lua objects. The Lua objects are defined by a base class `LuaObject` and two derived classes `LuaNumber` and `LuaString`. Your goal is to create a `LuaFactory` class that can produce instances of these Lua objects based on... | codefeedback |
You are tasked with implementing a WebSocket server that authenticates incoming connections using an authentication token and manages session tokens for each connected client. The server should use the `aioredis` library to interact with a Redis database for token validation and session management. Additionally, the se... | codefeedback |
You are tasked with simulating the behavior of a user interface (UI) event handler in a hypothetical application. The application has a set of UI events, each associated with a specific action to be performed when triggered. Your goal is to implement a program that can execute the corresponding action for a given UI ev... | codefeedback |
You are tasked with creating a Python function that reads a YAML configuration file, updates the logging configuration based on the contents of the file, and then starts a server. Your task is to complete the implementation of the `load_cfg` function, which should read the YAML configuration file and return its content... | codefeedback |
You are tasked with creating a script to automate the login process for a web application using the `curl` command-line tool. The script should extract the CSRF token and session ID from the HTTP response headers and store them in environment variables for subsequent requests. The script should also securely handle the... | codefeedback |
You are tasked with implementing a custom `to_string` function in C++ that converts various types of integers to their string representations. The provided code snippet shows the initial implementation of the `to_string` function for `int`, `unsigned int`, and `long` types. Your task is to extend this implementation to... | codefeedback |
You are tasked with implementing a custom UITableViewCell subclass to display the status of a task. The status is represented by an enum called `StatusColor`, which contains cases for different task statuses: `inProgress`, `success`, `aborted`, `error`, and `onHold`. Each status has a corresponding color associated wit... | codefeedback |
You are tasked with implementing a custom hook in a React application that fetches network data based on a specified chain. The hook should utilize the `useMemo` hook to efficiently retrieve the network data and return the result for further processing.
Your task is to create a custom hook called `useNetworkData` that... | codefeedback |
You are tasked with implementing a program to perform K-means clustering on a given dataset using the `sklearn` library in Python. K-means clustering is a popular unsupervised machine learning algorithm used for partitioning a dataset into a set of clusters. The algorithm aims to minimize the sum of squared distances b... | codefeedback |
You are tasked with creating a program that processes data from a JSON file and uses the Picasso library to load and display images in a user interface. The program should read a JSON file containing information about different images, including their URLs and titles. It should then use the Gson library to parse the JS... | codefeedback |
You are tasked with implementing a method to traverse a tree structure and collect all the "use boxes" associated with a given base box. Each box in the tree structure has a value and may have child boxes. The goal is to create a method that returns a list of all the use boxes related to the given base box.
You are gi... | codefeedback |
You are given a Swift code snippet that involves the creation and comparison of `Line` objects. The `Line` class represents a line segment in a 2D coordinate system and is defined by two `CGPoint` objects. The snippet also includes the testing of equality and inequality of these `Line` objects using the `XCTAssert` fun... | codefeedback |
You are tasked with creating a program that parses and extracts information from HTML code. Specifically, you need to extract the labels and their corresponding attributes from the given HTML snippet.
Write a function `extractLabels` that takes a string representing the HTML code as input and returns a dictionary wher... | codefeedback |
You are tasked with implementing a custom error handling mechanism for a Rust program. The program uses the `DecodePartial` trait to decode data structures, and the `DecodeError` type represents errors that can occur during decoding. The `DecodePartial` trait provides methods for inserting child nodes and properties in... | codefeedback |
You are tasked with implementing a pagination algorithm for a web application that displays a list of orders. The provided code snippet is a part of the pagination logic and contains some incomplete parts. Your task is to complete the pagination logic based on the given code and requirements.
The code snippet is part ... | codefeedback |
You are tasked with implementing a login system that interacts with an API service, a mailer, a tracking server, and Google authentication. The code snippet provided initializes various components required for the login system. Your task is to design and implement the `LoginSystem` class, along with the necessary mock ... | codefeedback |
You are given a code snippet that processes and writes out macro definitions for a set of variables. Your task is to write a Python function that takes the input data and generates the corresponding macro definitions as output.
The input data consists of three lists: `gl`, `wgl`, and `glX`. Each list contains sublists... | codefeedback |
You are working on a file management system for a code grading platform. The system uses environment variables to store various file paths and directories. The code snippet provided sets up several environment variables related to file management.
Your task is to write a function that takes a file name as input and re... | codefeedback |
You are tasked with implementing a queue data structure in TypeScript. The queue should have the following functionalities:
1. `enqueue(item: T): void` - Add an item to the end of the queue.
2. `dequeue(): T | undefined` - Remove and return the item at the front of the queue.
3. `peek(): T | undefined` - Return the ite... | codefeedback |
You are tasked with implementing a simple mutex using the HIP (Heterogeneous-Compute Interface for Portability) runtime library for GPU programming. The HIP runtime library provides a set of functions for managing memory, launching kernels, and synchronizing between the host and the GPU.
Your task is to implement a de... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.