instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a C++ header file for a 2D vector math library. The header file should contain functions for various vector operations, and it should include support for profiling using a custom profiler library when a preprocessor macro is defined. Your task is to complete the implementation of the h...
codefeedback
You are tasked with implementing a Python class that represents a geometric region and provides methods for comparing regions based on their cardinal relations. The cardinal relations include "above", "below", "left_of", "right_of", "overlapping", and "non_overlapping". The class should also support refining overlappin...
codefeedback
You are tasked with implementing a pagination system for a web application. The given code snippet is part of a PHP script that interacts with a MongoDB database to retrieve paginated data. The `Page` class is used to calculate the pagination limit based on the total count of records in a specified table and a given pa...
codefeedback
You are tasked with implementing a function to manipulate the Windows Registry using the Windows API. The function should set a new value for a specified registry key. Write a C++ function `setRegistryValue` that takes the following parameters: - `HKEY hKey`: A handle to an open registry key. - `const char* subKey`: T...
codefeedback
You are tasked with implementing a function to manage inventory locales in a software system. The inventory manager has methods to retrieve sets of active locales, inactive locales, and their aliases. Your task is to create a class that implements these methods and ensures their correctness. You are given a code snipp...
codefeedback
You are tasked with implementing a custom slider control in Swift for an iOS app. The slider control should allow the user to select a value within a specified range. The slider should be displayed in a table view, with each cell containing a separate slider. The user should be able to interact with each slider indepen...
codefeedback
You are tasked with creating a Python script that automates the process of organizing and packaging configuration files into a distributable format using the `setuptools` library. Your script should traverse a specified directory, identify all configuration files within it, and package them into a distributable format ...
codefeedback
You are working on a script to organize and manipulate files related to MRI brain scans. The code snippet provided is part of a larger script that deals with file manipulation and organization. The script uses the `os` module to work with file paths and directories. Your task is to write a function that takes in the `...
codefeedback
You are given a 2D grid representing a black-and-white image. Each cell in the grid is either black ('#') or white ('.'). Your task is to find the largest connected component of black cells in the grid and return the size of this component. A connected component of black cells is a group of adjacent black cells (horiz...
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 account balance. Additionally, the class should keep track of the account holder's name and account balance. Your task is to complete the imple...
codefeedback
You are tasked with creating a Python function that processes the output of the `ip address` command on a Linux system to build a dictionary mapping IP addresses to interface names. The function should then take an IP address as input and return the corresponding interface name from the dictionary. The `ip address` co...
codefeedback
You are working on a project that involves training a neural network using TensorFlow. As part of the training process, you need to implement a function to restore the weights of the model from a previously saved checkpoint. The function should take a TensorFlow session and an optimizer as input, and it should restore ...
codefeedback
You are tasked with implementing a function that calculates the sum of the values in the neighborhood cells of a given cell in a 2D grid. The neighborhood cells are defined as the cells immediately surrounding the given cell in a 3x3 grid pattern. The function should take the grid and the coordinates of the cell as inp...
codefeedback
You are tasked with creating a Python function that processes benchmarking data and generates a plot based on the benchmark results. The function should take in parameters related to the benchmarking data and produce a plot with appropriate labels and formatting. Write a Python function `generate_benchmark_plot` that ...
codefeedback
You are tasked with creating a Discord bot command that updates the reason for a specific infraction case. The bot is connected to a database and has access to a table called `infractions`, which contains information about each infraction, such as the real ID, serial ID, moderator, target, guild, time punished, and rea...
codefeedback
You are tasked with creating a Python program to manage employee leave requests using the `leavemanager` library. The program should allow users to add, view, and approve leave requests based on the company's leave policy. The leave policy is defined in a configuration file, and the program should enforce these policie...
codefeedback
You are tasked with implementing a custom neural network architecture called DoveNetG for image classification. The DoveNetG architecture is designed for processing high-resolution images and has shown promising results in various computer vision tasks. Your goal is to create the structure of the DoveNetG neural networ...
codefeedback
You are tasked with understanding and analyzing a given sequence of hexadecimal escape sequences. These sequences represent shellcode, which is a small piece of code typically used as the payload in a software exploitation scenario. Your goal is to decode and understand the functionality of the shellcode. The given co...
codefeedback
You are given a simplified representation of a control flow graph (CFG) manipulation in a programming environment. The code snippet provided is part of a larger program that processes a CFG representing a kernel function and performs certain operations on the nodes within the graph. The `if` condition checks if the cu...
codefeedback
You are working on a tool to generate an eBook in mobi format using Python. The code snippet provided contains commented-out lists and a list of excluded files. Your task is to write a function that processes these lists and generates the final list of files to be included in the mobi file. You need to implement a fun...
codefeedback
You are tasked with creating a Python module that generates a map displaying the 10 nearest movie locations based on user input. The module should integrate data reading, location finding, and map generation functionalities. Your task is to implement the following functions within the module: 1. `read_data(filename: ...
codefeedback
You are tasked with implementing a function that formats a list of website links based on certain field configurations. The function should take a field object and a field value object as input and return an array of formatted HTML anchor tags representing the website links. The field object has the following properti...
codefeedback
You are tasked with implementing a class method for a USB device class that finds and returns the appropriate usage page based on a given value. The provided code snippet is a skeleton of the method `find_usage_page` within the USB device class. The method is responsible for mapping the given value to the corresponding...
codefeedback
You are tasked with implementing a custom dataset reader for a natural language processing (NLP) model. The dataset reader is responsible for converting raw text data into a format suitable for training the NLP model. The provided code snippet is a part of the dataset reader class, which contains two methods: `predict_...
codefeedback
You are tasked with creating a Python program that dynamically loads a worker class based on a configuration setting. The program should be able to instantiate the specified worker class and execute a method from it. You are given a configuration setting `worker_class` which contains the fully qualified name of the wo...
codefeedback
You are tasked with implementing a Python function that processes feature vectors using Factor Analysis (FA) and then formats and prints the shape of the resulting feature vectors. Factor Analysis is a statistical method used to describe variability among observed, correlated variables in terms of a potentially lower n...
codefeedback
You are given the definition of a binary tree node and a method to calculate the diameter of a binary tree. The diameter of a binary tree is defined as the number of nodes along the longest path between any two nodes in the tree. Your task is to implement the `diameterOfBinaryTree` method to find the diameter of a give...
codefeedback
You are tasked with creating a web application feature that involves managing timers for different courses. The code snippet provided is from a Laravel controller responsible for handling the creation and storage of timers. The `storeTimer` method is used to store a new timer in the database. The `Timer` model has a `c...
codefeedback
You are tasked with implementing a Python class method that tests the functionality of a batch normalization layer in a neural network. The method should take various input arguments and verify that the batch normalization layer behaves as expected under different conditions. You are given the following code snippet a...
codefeedback
You are tasked with implementing a custom list data structure in Rust. The list should support adding elements, removing elements, and checking if it contains a specific value. Additionally, the list should implement the `Value` trait, which requires the implementation of a `value` method that returns the sum of all el...
codefeedback
You are tasked with creating a program that processes a large XML file containing the revision history of a French Wikipedia page. The XML file is available for download via the given URL. Your program needs to extract specific information from this XML file and perform some calculations based on the data. Your progra...
codefeedback
You are tasked with implementing a quantum tensor network (QTN) simulator for a quantum circuit using Python. A quantum tensor network is a graphical representation of a quantum state or operator, where tensors represent quantum gates or states and indices represent the qubits they act on. The given code snippet is a p...
codefeedback
You are tasked with creating a program that processes a series of commands to manipulate a mock file system. The file system consists of directories and files, and the commands will involve creating, deleting, and navigating through the file system. The commands will be provided as a series of strings, each representi...
codefeedback
You are tasked with creating a program that generates a random image with a specific number of stars and their positions. The program should use the `numpy` and `cv2` libraries in Python to create the image. The number of stars to be generated will be specified by the variable `<gh_stars>`, which will be an integer bet...
codefeedback
You are tasked with implementing a custom module resolution system for a JavaScript application. The system should mimic the behavior of the `export * from 'module'` syntax in ES6 modules. Your task is to create a function `resolveModule` that takes two parameters: 1. `moduleMap`: A JavaScript object representing the...
codefeedback
You are tasked with creating a Python class that processes and submits data to a specified URL. The class should have a method `url_submit` that takes in a data URL, a submit URL, and an optional parameter `times` representing the number of times the submission should be attempted. The method should make a POST request...
codefeedback
You are tasked with implementing a TypeScript function that processes a set of request methods and their corresponding callback functions. The function should take in a map of request methods and their arguments, as well as a map of request methods and their corresponding callback functions. The goal is to create a new...
codefeedback
You are tasked with implementing a program to analyze the efficiency of different algorithms. The efficiency of each algorithm is calculated using specific formulas and then compiled into a single list for further analysis. You are given the following code snippet as a reference: ```python boeffc = [((i + (((i**2) - ...
codefeedback
You are tasked with implementing a simple rule engine for a game. The game has various rules that are defined in a separate module called `rules`. The `rules` module contains functions that represent different game rules. Each rule function takes a player's score as input and returns a boolean value indicating whether ...
codefeedback
You are tasked with implementing a function that calculates the average rating of a product based on the given array of rating values. The function should handle cases where the input array is empty or contains non-numeric values. You are given the following code snippet as a starting point: ```javascript } const...
codefeedback
You are tasked with implementing a simple traffic light simulation program in C#. The program should control the state of a traffic light, allowing it to transition between red, yellow, and green lights at specific time intervals. Additionally, the program should include a method to throttle the CPU load to prevent exc...
codefeedback
You are tasked with implementing a function that calculates the maximum of two floating-point numbers using bitwise operations. The function should take two 64-bit floating-point numbers as input and return the maximum of the two numbers. You are provided with the following code snippet for inspiration: ```rust #[no_...
codefeedback
You are tasked with implementing a method that processes a collection of session objects. Each session object contains information about a user's session, including the start time, end time, and duration. Your goal is to filter the collection to include only the sessions that meet specific criteria. You are given a co...
codefeedback
You are tasked with implementing a generic data structure that represents a sequence of elements. The data structure should provide a method to retrieve the next element in the sequence and a method to print a greeting message. You are given a code snippet that outlines the interface for this data structure: ```rust t...
codefeedback
You are tasked with implementing a function to combine two code strings based on a given template. The template contains placeholders that will be replaced by the two code strings. Your task is to write a function `combine_two_code_strings(template, cs1, cs2)` that takes in three parameters: - `template`: A string repr...
codefeedback
You are tasked with implementing a class hierarchy for a fantasy-themed strategy game. The game involves different types of armies, each consisting of battalions, traits, and units. Your task is to create a class structure that represents this game's entities and their relationships. You are provided with a code snipp...
codefeedback
You are tasked with creating a Python function that retrieves a list of available software views from a server using a socket connection. The server is running a Django web application, and the views are to be displayed in a web interface. Your function should establish a connection to the server, send a request for th...
codefeedback
You are tasked with creating a command-line tool that can format and print messages to the terminal with different text and background colors. Your task is to implement a class that provides methods for formatting and printing messages with specific color combinations. You are given a partial code snippet of a PHP cla...
codefeedback
You are tasked with implementing a color selection algorithm for a 3D image processing application. The algorithm should select pixels or voxels within a specified color range from an input image or volume data. The provided code snippet is a part of the existing codebase for the color selection module. Your task is to...
codefeedback
You are tasked with implementing a Python function that simulates a simplified version of a protein structure prediction algorithm. The provided code snippet contains a part of the algorithm, and your task is to complete the implementation by writing the missing parts of the function. The function `fold_protein` takes...
codefeedback
You are tasked with implementing a function that generates the Cartesian product of multiple input sequences. The Cartesian product of two sets A and B is defined as the set of all possible ordered pairs (a, b) where a is in A and b is in B. For example, the Cartesian product of sets {1, 2} and {3, 4} is {(1, 3), (1, 4...
codefeedback
You are given a code snippet that appears to be part of a larger program. Your task is to identify the missing code that would logically fit into the snippet. The missing code should complete the program in a way that adheres to best practices and ensures the program's correctness. Your task is to write the missing co...
codefeedback
You are working on a program that simulates interactions between particles in a 3D space. The code snippet provided is a part of this simulation and involves updating the interactions between particles. The `p_coords` and `l_coords` represent the coordinates of two particles, and `dist` is the distance between them. Th...
codefeedback
You are tasked with creating a script that manages an SSH agent and handles cleanup when the script exits. The script should set the `SSH_AUTH_SOCK` environment variable to a default value if it is not already set, and it should define a function to be executed when the script exits to stop the SSH agent. Your task is...
codefeedback
You are tasked with creating a Rust program to manage real-time data subscriptions from the Binance cryptocurrency exchange. The program will utilize asynchronous programming with the Tokio runtime to handle WebSocket connections and receive subscription updates. Your task is to implement a function that subscribes to...
codefeedback
You are given a singly linked list of integers. Your task is to write a function `next_larger_nodes(head)` to return an array representing the next larger node for each node in the input list. If there is no such larger node, the value should be 0. The function should take the head of the linked list as input and ret...
codefeedback
You are tasked with implementing a custom stub index for a programming language plugin in an IntelliJ-based IDE. The stub index is used to store all names defined in the project, specifically for the "go to symbol" feature, which allows users to quickly navigate to a specific symbol or declaration within the codebase. ...
codefeedback
You are tasked with creating a Python function that processes a list of database migration operations and generates SQL statements for applying those operations to a database. Each migration operation is represented as an instance of a class, and the function should handle different types of operations such as creating...
codefeedback
You are tasked with creating a Flask web application that manages user roles using SQLAlchemy. The provided code snippet includes the definition of a `Role` model with attributes `id` and `name`. Your task is to extend this code to include functionality for creating, updating, and deleting roles through API endpoints. ...
codefeedback
You are tasked with implementing a Python generator function for in-order traversal of a binary tree. In-order traversal visits the nodes in the following order: left, root, right. You are given the definition of the TreeNode class, which represents a node in the binary tree. The class has three attributes: val, left, ...
codefeedback
You are tasked with creating a Python program that utilizes the Pygame and ModernGL libraries to render a simple 2D triangle on the screen. The program should set up a Pygame window and use ModernGL to create a shader program that renders a colored triangle. Your task is to complete the Python program by writing the n...
codefeedback
You are tasked with creating a Python function that processes image data using a pre-trained deep learning model. The function should take a PyTorch model and a PyTorch dataloader as input and return predictions for the images in the dataloader using the provided model. Additionally, the function should have an optiona...
codefeedback
You are tasked with creating a program to parse and extract data from an HTML table. The HTML snippet provided represents the beginning of a table containing information about orders. Each row in the table represents a single order, and the columns contain the order number, date, and the person who placed the order. Yo...
codefeedback
You are tasked with creating a script to process data from multiple files and calculate the total value of a specific column, as well as the percentage of that column's total value compared to the overall total value. The script should iterate through each file, extract the necessary data, and output the number of colu...
codefeedback
You are tasked with implementing a school management system in C#. The system should have the ability to store classes within a school. Each class should have a unique identifier and a list of students enrolled in that class. Your task is to implement the necessary classes and interfaces to fulfill these requirements. ...
codefeedback
You are tasked with creating a Telegram bot that provides users with images based on selected categories. The code snippet provided is a part of the bot's functionality. The `await call.answer()` line indicates that the bot has received a callback query, and the subsequent lines show the bot editing a message to prompt...
codefeedback
You are tasked with implementing a custom sorting algorithm for a specific data structure. The data structure is represented by a class `OlapTableIndexSchema`, which contains information about an index schema for an OLAP (Online Analytical Processing) table. The class has a member function `sortIndexes` that sorts a ve...
codefeedback
You are tasked with implementing a function to calculate the cumulative distribution function (CDF) of a given dataset. The CDF represents the cumulative probability distribution of a random variable taking on a value less than or equal to a given value. The function should take a pandas Series `s` as input, where each...
codefeedback
You are working on a machine learning pipeline using Apache Airflow, a platform for programmatically authoring, scheduling, and monitoring workflows. Your task is to create a new operator that will evaluate the trained model and generate performance metrics. The performance metrics will then be persisted to an MLFlow s...
codefeedback
You are tasked with creating a web application that displays a list of accounting records in a table format. The application uses the Laravel framework and the Blade templating engine. The provided code snippet is a part of the Blade template file that generates the HTML for displaying the accounting records. The `acc...
codefeedback
You are given a nested dictionary representing a file system structure. Each key in the dictionary represents a directory, and the corresponding value can be either another nested dictionary (representing a subdirectory) or a string (representing a file). The depth of the nested dictionaries represents the depth of the...
codefeedback
You are tasked with creating a function that determines the number of positions a given word can occupy within a string of a specified length. The function should take two parameters: the word to be positioned and the length of the string. The function should return the number of positions the word can occupy within th...
codefeedback
You are tasked with creating a script to automate the process of updating a version control system and uploading files to a remote server. Your script should perform the following steps: 1. Commit a change to the local repository with a message indicating an update to the build log, using the current date as part of t...
codefeedback
You are tasked with implementing a function that checks the version compatibility of two software components. The function should compare the major and minor version numbers of the components and log a warning if there is a difference in the minor version. However, the warning should only be logged once, even if the fu...
codefeedback
You are tasked with implementing a priority queue data structure in C#. A priority queue is a data structure that maintains a set of elements, each associated with a priority. The following code snippet provides a simplified representation of a priority queue using abstract methods and a class method. ```csharp /** Mo...
codefeedback
You are tasked with creating a Python function that uses the Keras library to build, train, and evaluate a neural network model for classifying images of handwritten digits from the MNIST dataset. The code snippet provided serves as a starting point for your task. Your function should take the following inputs: - `X_t...
codefeedback
You are tasked with implementing a function that filters a given model based on a set of key-value pairs. The model has various types of fields such as foreign key fields, one-to-one fields, and many-to-many fields. The function should handle different types of fields and their corresponding filter conditions. You are...
codefeedback
You are tasked with creating a Python class that facilitates automated testing of a web application using Selenium. The provided code snippet includes a `locator_dictionary` containing web element locators and a `CartPopup` class that inherits from `BasePage`. Your task is to complete the `CartPopup` class by implement...
codefeedback
You are tasked with creating a program that analyzes a given software license disclaimer to extract and count the occurrences of unique words. The disclaimer is a multi-line string containing various legal terms and disclaimers. Your program should ignore any special characters, punctuation, and case sensitivity when c...
codefeedback
You are tasked with creating a program to process a live video feed from a camera and save every other frame as a GIF. The program should use the OpenCV library to display the live video feed and capture frames, and the imageio library to save the frames as a GIF. Your task is to implement a Python program that accomp...
codefeedback
You are tasked with creating a Python class that interacts with the Twitter API to perform a proximity search for tweets within a given radius of specified geographical points. Your class should have a method to execute the search and return the relevant tweets. Your class should have the following structure: ```pytho...
codefeedback
You are tasked with creating a Python class that simulates a simple form validation system. The form class should be able to handle both GET and POST requests, and it should be capable of validating and processing the form data. Your task is to implement the `Form` class with the following requirements: - The `Form` c...
codefeedback
You are tasked with creating a custom Django REST Framework (DRF) endpoint that integrates with the Sentry error monitoring platform. Your goal is to implement an endpoint that retrieves and returns information about the plugins bound to a specific organization in Sentry. The plugins are managed through the `sentry.plu...
codefeedback
You are given a stack data structure that supports the following operations: 1. Push: Add an element to the top of the stack. 2. Pop: Remove the element from the top of the stack. 3. Max: Return the maximum element in the stack. You need to implement a class `MaxStack` that supports the above operations efficiently. T...
codefeedback
You are working on a large Angular project that utilizes various third-party libraries and modules. As the project has grown, you have noticed that the bundle size has increased significantly, impacting the application's performance. To optimize the bundle size, you decide to analyze and optimize the import statements ...
codefeedback
You are given a Python function that processes a list of feasible values and selects the best feasible value based on certain criteria. Your task is to implement a function that finds the best feasible value and its corresponding index. You are to implement the function `find_best_feasible_value(feasible_values: List[...
codefeedback
You are tasked with creating a Python function that parses a dictionary file and returns a specific value based on the input key. The dictionary file contains key-value pairs separated by a colon, with each pair on a new line. The function should take the file name and the key as input and return the corresponding valu...
codefeedback
You are tasked with implementing a binary search algorithm to efficiently find the position of a given element in a sorted list. The provided code snippet outlines the structure of the binary search algorithm, but it is incomplete. Your task is to complete the binary search algorithm and implement the necessary logic t...
codefeedback
You are working on a Python project that needs to handle serialization and deserialization of data using different libraries based on the Python version and available modules. Your task is to create a function that can handle this dynamically and efficiently. Write a Python function called `dynamic_serialize` that tak...
codefeedback
You are tasked with implementing a TypeScript function that manipulates and combines two types. The function should take two type parameters and return a new type that combines the properties of the input types while omitting specific properties from one of the input types. You are given the following code snippet as ...
codefeedback
You are tasked with creating a Python metaclass that enforces specific metadata requirements for Ansible roles. Ansible is an open-source automation platform that facilitates configuration management, application deployment, and task automation. The metadata for an Ansible role is defined in a `meta/main.yml` file and ...
codefeedback
You are tasked with implementing a custom error handler for a Python application that uses the GDAL library for geospatial data processing. The GDAL library provides the ability to open various types of data sources, including those stored in Azure Blob Storage. Your goal is to create a custom error handler that detect...
codefeedback
You are tasked with simulating the trajectory of a projectile in a 2D space. The projectile is launched from the origin (0, 0) with an initial velocity v0 at an angle θ to the horizontal axis. The simulation should consider the effects of air resistance, which is proportional to the square of the projectile's velocity ...
codefeedback
You are tasked with creating a Python program to manage and monitor multiple IoT devices using different protocols. The program should be able to handle devices such as iGrill and TokenCube, each with its own set of functionalities and data formats. Your task is to implement a Python class called `IoTDeviceManager` th...
codefeedback
You are tasked with implementing a Swift program to facilitate fund transfers between accounts using the provided code snippet as a reference. The program should handle the creation of transfer parameters and the execution of the transfer using an API. You are given the following code snippet as a reference: ```swift ...
codefeedback
You are tasked with implementing a neural network model for a sequence classification task using TensorFlow and Keras. The dataset consists of sequences of categorical data, which need to be converted to one-hot encoded format before being fed into the model. The model architecture includes an LSTM layer followed by a ...
codefeedback
You are tasked with creating a program that generates a customized presentation sheet using a Python library called `ui`. The snippet provided demonstrates the usage of the `ui` library to present a sheet with specific formatting and content. Your task is to write a function that takes in the necessary parameters and g...
codefeedback
You are tasked with implementing a custom stack allocator class in C++. A stack allocator is a type of memory allocator that operates on a last-in, first-out (LIFO) basis, making it efficient for managing short-lived memory allocations. Your goal is to complete the implementation of the `StackAllocator` class template ...
codefeedback
You are tasked with implementing a progress tracking system for a script that processes and saves data from a large zip file containing the text of the Bible. The script currently uses a generator function `main_progress_iterator` to iterate through the books of the Bible, process the text, and save the results to indi...
codefeedback
You are tasked with implementing a genetic algorithm solver for a specific optimization problem. Genetic algorithms are a type of evolutionary algorithm that uses techniques inspired by natural selection, such as mutation, crossover, and selection, to evolve a population of candidate solutions toward an optimal solutio...
codefeedback