instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a generic cache system in C++ using templates and typedefs. The cache system should support storing and retrieving data based on a given tag. Your goal is to define a data structure that represents a queue for storing side packets associated with the cache. Given the following code sni...
codefeedback
You are tasked with implementing a memory management system for a kernel that loads modules during boot. The provided code snippet is part of a multiboot bootloader that loads modules into memory. The `multiboot.modules` function iterates over the loaded modules and processes them. The code snippet demonstrates how to ...
codefeedback
You are tasked with implementing a scheduling algorithm for a kernel. The provided code snippet is part of a larger system that manages background tasks and timers. The snippet includes a conditional block and an assertion related to the background task scheduling. Your task is to design a class that manages the schedu...
codefeedback
You are tasked with creating a Python class for generating synthetic data for a binary classification problem. The class should be able to generate a specified number of examples for each class, with control over the balance between the classes and the distribution of the features. Your task is to implement the `Synth...
codefeedback
You are tasked with creating a Rust library for cellular automata simulation using the Bevy game engine. The library should support both 2D and 3D cellular automata, with the ability to choose between different neighborhood types (e.g., Moore, Neumann) based on feature flags. Your task is to implement the `Cell` trait...
codefeedback
You are tasked with creating a simple dependency injection framework in Java. Your framework should support the `@Component` annotation for marking classes as components to be managed by the framework. The framework should be able to instantiate and manage these components, resolving their dependencies and providing in...
codefeedback
You are tasked with creating a Python function that extracts and prints the names of the imported modules from a given code snippet. The code snippet will contain import statements and a function call to `teal.print_tasknames`. Your function should parse the code snippet and return a list of imported module names. Cre...
codefeedback
You are tasked with creating a program that analyzes a given CSS code snippet and identifies the selectors and their corresponding properties. The CSS code snippet will be provided as a string, and you need to parse it to extract the selectors and their associated properties. Write a function `parseCSS` that takes a s...
codefeedback
You are tasked with creating a program that simulates a package manager for a programming language. The package manager should be able to handle the installation and updating of various packages. Your program should support the following commands: 1. `install <package_name>`: This command installs the specified packag...
codefeedback
You are tasked with implementing a version comparison algorithm to compare software version numbers. The version numbers are represented as strings in the format "major.minor.patch.build", where each component is an integer. Your task is to write a function that compares two version numbers and returns whether the firs...
codefeedback
You are working on a machine learning project and need to implement a custom loss function for a binary classification problem. The loss function is designed to address class imbalance by incorporating weighted penalties for positive and negative samples. The provided code snippet outlines the computation of the loss f...
codefeedback
You are tasked with implementing a custom CSS-in-JS component for a web application. The component, called `CustomHeading`, should render a heading with customizable styles based on the provided props. The component should accept the following props: - `as`: The HTML tag for the heading (e.g., "h1", "h2", "h3", etc.). ...
codefeedback
You are tasked with creating a custom exception handling mechanism for a Python package. The package contains a module named `exceptions` which is imported using a relative import statement. Your goal is to define a new custom exception class within this module and handle it in a specific way. Your task is to create a...
codefeedback
You are tasked with creating a script to process multiple input files and extract specific fields from lines that start with "CONTIG". The extracted fields should be formatted and appended to a single output file. Your script should be able to handle multiple input files and ensure that the output file contains the ext...
codefeedback
You are tasked with implementing a token-based authentication system for a web application. The system should handle incoming requests, verify the authenticity of the token, and grant access to the requested resources if the token is valid. Your task is to write a Python function that performs the token verification pr...
codefeedback
You are tasked with implementing a class that simulates a simple heat model using a grid. The model has a method to initialize the grid and two methods to retrieve the temperature values at specific grid points. Your task is to create a Python class `BmiHeat` that fulfills the requirements specified below. The `BmiHea...
codefeedback
You are tasked with creating a network connectivity monitoring system using RxSwift and Reachability library in a Swift application. The Reachability library provides a way to monitor the network status and RxSwift allows you to observe and react to changes in the network status in a reactive manner. Your task is to i...
codefeedback
You are tasked with creating a Python function that processes a series of Django migration files and extracts information about the fields being added to a model. Each migration file is a Python script that contains a series of `migrations.AddField` calls, which add fields to a Django model. Your function should parse ...
codefeedback
You are tasked with implementing a function that will generate a gallery HTML code based on a given array of product images. The function should take an array of product images as input and produce the corresponding HTML code for the gallery display. Additionally, the function should include a line break after the seco...
codefeedback
You are tasked with creating a Python script to automate the deployment process of a Dockerized application on a remote server using SSH. Your script should handle the following tasks: 1. Connect to the remote server via SSH using the provided email address. 2. Navigate to the directory `~/fb-event-scraper/` on the rem...
codefeedback
You are tasked with creating a program to solve a maze using the A* algorithm. The maze is represented as a 2D grid, where each cell can be either empty (denoted by 0) or blocked (denoted by 1). The program should find the shortest path from the start cell to the end cell, avoiding the blocked cells. You are given the...
codefeedback
You are tasked with creating a script to automate the generation of mock files for Go interfaces. The script should iterate through a specified range of GitHub repositories and generate mock files for all Go interface files found within them. Your script should take the following inputs: - `<gh_stars>`: A range of Git...
codefeedback
You are working on a data processing system that involves a series of operations on input data. One of the operations involves applying a sequence of functions to the input data. The code snippet provided is a part of this data processing system. The functions `czip`, `decoupler`, `fmap`, `Union`, `demux`, and `fifo` a...
codefeedback
You are tasked with simulating the behavior of a heart pumping function. The heart consists of two sides, the left and the right, each with its own pumping function. Additionally, the heart contains valves that ensure the proper flow of blood. Your goal is to implement a program that models the pumping function of the ...
codefeedback
You are tasked with implementing a data processing function for a transportation system. The function takes in two parameters: `gtfs_data` and `model`. The `gtfs_data` parameter represents the data from the General Transit Feed Specification (GTFS) and can be either a DataFrame or a list of data. The `model` parameter ...
codefeedback
You are tasked with creating a module loader for a JavaScript application. The module loader should be able to dynamically import and export modules based on the provided code snippet. The code snippet provided is a list of module names that need to be dynamically imported and exported by the module loader. Each modul...
codefeedback
You are tasked with creating a custom macro in Rust that generates a set of constants and associated tests. The macro should take a name and a value as input and produce a constant with the given name and value. Additionally, it should generate a test function to ensure the correctness of the constant. Your task is to...
codefeedback
You are tasked with creating a program that analyzes and manipulates CSS code. Your program should be able to extract specific CSS properties and their values from a given input, and then modify those properties based on certain conditions. Write a function `cssPropertyManipulator` that takes in two parameters: 1. `cs...
codefeedback
You are tasked with creating a Python class that simulates a simple bank account. The class should have the following attributes and methods: Attributes: - `balance`: A float representing the current balance of the account. Methods: - `deposit(amount)`: A method that takes a float `amount` as input and adds it to the...
codefeedback
You are tasked with creating a custom Angular directive that allows users to drag and drop elements within a web application. The directive should utilize the Angular CDK (Component Dev Kit) DragDropModule to enable this functionality. Your goal is to implement the directive and ensure that it can be seamlessly integra...
codefeedback
You are tasked with simulating a radar system in a 2D environment. The radar system consists of a radar object that emits waves in all directions from a given point. The waves will bounce off barriers and display the final path of the waves on the screen. You are provided with the following classes and functions: - `p...
codefeedback
You are tasked with creating a script that will automate the configuration of the `tmux` terminal multiplexer on a Fedora or Red Hat Enterprise Linux 8 system. The script should append a specific configuration line to the `/etc/tmux.conf` file. The configuration line to be added is `set -g lock-command locker`. This li...
codefeedback
You are given a system of linear equations in the form of a matrix equation. Your task is to implement a function that solves the system of equations and returns the solutions. You are given the following code snippet as a starting point for your implementation: ```python # (i = 1, ..., m) for some d1, ..., du in Con...
codefeedback
You are tasked with creating a Python function that processes an image and applies a specific transformation to it. The function should take an input image and perform the following steps: 1. Convert the image to grayscale. 2. Apply a Gaussian blur to the grayscale image. 3. Perform edge detection on the blurred image ...
codefeedback
You are tasked with creating a secure SQL query to insert chat messages into a database. Given the following code snippet, you need to write a secure and efficient SQL query to insert chat messages into a database table. The table has the following columns: `id` (auto-incremented), `chat_time`, `username`, `message`, a...
codefeedback
You are tasked with parsing and extracting specific information from an XML file containing food product data. The XML snippet provided is a part of a larger XML file that contains information about food products, including options, allergens, and nutrient values. Your goal is to extract the nutrient value for a specif...
codefeedback
You are tasked with creating a PHP script that dynamically includes different content based on the value of the `$_GET['aksi']` parameter. The script should include a main panel with a navigation bar and content area. If the `aksi` parameter is set to 'edit', the script should include the 'edit_pelanggan.php' file; oth...
codefeedback
You are tasked with creating a function that processes a list of files in a project and generates a new Xcode project with specific options. The function should take into account the presence of certain files and the options provided to generate the new project. You are given the following information: - The code snip...
codefeedback
You are tasked with implementing a function to calculate the signed speed and principal direction of water currents based on given eastward and northward velocity components. The function should also determine flood and ebb based on the principal direction using the Polagye Routine. Additionally, the function should ca...
codefeedback
You are tasked with creating a program that validates whether a given input is a valid floating-point number according to a specific set of criteria. The program should take a floating-point number as input and determine if it meets the validation requirements. Your task is to implement a function or method that takes...
codefeedback
You are tasked with implementing a class that manages a dictionary of naming attributes for a given enum type. The class should provide methods to add, retrieve, and remove naming attributes for enum values. The naming attribute for an enum value should consist of a name and a description. You are given the following ...
codefeedback
You are tasked with implementing a Python module that manages a list of unique elements. The module should provide functions for adding elements to the list, removing elements from the list, and checking if a specific element is present in the list. To achieve this, you need to create a class `UniqueList` with the foll...
codefeedback
You are tasked with implementing a function that processes a string containing data about folding along the x-axis and returns the final folded state of the data. The input string will consist of rows, each representing a step in the folding process. The folding process involves identifying the line containing the inst...
codefeedback
You are tasked with implementing a simple inventory management system for a retail store. The system should support adding, updating, and retrieving products, as well as calculating the total value of the inventory. You are given a partial implementation of the `Product` struct and the `Inventory` struct, along with a ...
codefeedback
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. However, if the last two scores are the same, the player's score is doubled. Your task is to write a function that calculates the total score for the game based o...
codefeedback
You are tasked with implementing a cookie management system for a web application. The system should allow users to store and retrieve their preferences using cookies. Cookies are small pieces of data stored on the client's machine and are sent with every request to the server. Your task is to create a JavaScript modul...
codefeedback
You are tasked with creating a Python function that processes a given text and returns the lemmatized form of a specific word. Lemmatization is the process of reducing words to their base or root form. For example, the lemmatized form of "was" is "be". You are provided with a code snippet that includes assertions and...
codefeedback
You are tasked with implementing a Python script that processes a configuration file for a deep learning model and extracts specific information from it. The configuration file is in the Protobuf format and contains information about the layers and their parameters. Your goal is to extract the names of all the batch no...
codefeedback
You are tasked with implementing a custom data structure called `TestRegistry` to manage a collection of test classes. Each test class represents a specific test case and should be registered with the `TestRegistry`. The `TestRegistry` should provide methods to add a new test, run all tests, and retrieve the results of...
codefeedback
You are given a Python function `QRD_inPlace(A)` that performs an in-place QR decomposition of a given matrix `A`. The function takes a matrix `A` as input and decomposes it into the product of an orthogonal matrix Q and an upper triangular matrix R, such that A = QR. The function description mentions that the matrix ...
codefeedback
You are tasked with creating a function that writes content to a file in a specific directory. The function should handle potential errors that may occur during the file writing process. Write a Swift function called `writeContentToFile` that takes in three parameters: 1. `content`: a string representing the content t...
codefeedback
You are tasked with implementing a function to find the shortest path between two nodes in a weighted graph using Dijkstra's algorithm. The graph is represented using an adjacency list, and the weights of the edges are non-negative integers. Your function should return the shortest path from the source node to the dest...
codefeedback
You are tasked with creating a Python function that automates the process of logging into a website using Selenium, a popular web automation tool. The function should take the website URL, username, password, and any other necessary information as input, and then use Selenium to locate the password input field and subm...
codefeedback
You are tasked with creating a custom error type in Rust using the `thiserror` crate. Your custom error type should represent different kinds of errors that can occur in a hypothetical file processing application. The application needs to handle errors related to file input/output operations, parsing, and validation. ...
codefeedback
You are tasked with implementing a sensor fusion algorithm for a localization system in a robotics application. The system uses data from multiple sensors to estimate the robot's position in a given environment. The provided code snippet imports necessary modules and initializes a dictionary called `positions` from the...
codefeedback
You are tasked with creating a Python program that generates a QR code in SVG format using the `qrcode` library. The program should take user input for the data to be encoded in the QR code and the filename for the output SVG file. The generated QR code should be saved as an SVG file with the specified filename. Your ...
codefeedback
You are tasked with implementing a function that will parse a given string and determine if it contains a valid set of parentheses. The function should return `true` if the parentheses are properly nested and balanced, and `false` otherwise. The function signature is: ```python def is_valid_parentheses(s: str) -> boo...
codefeedback
You are tasked with creating a program that interacts with the OpenDota API to retrieve and display information about Dota 2 matches. The OpenDota API provides various endpoints for accessing match data, including match details, player statistics, and more. Your program should be able to make HTTP requests to the OpenD...
codefeedback
You are tasked with creating a command-line tool that manages aliases for various commands. The tool should allow users to add, remove, list, and execute aliases for commands. An alias is a user-defined shorthand for a longer command, allowing for quicker execution. Your task is to implement a Python class `AliasManag...
codefeedback
You are tasked with creating a Rust function that interacts with a blockchain network to fund a new account. The function will utilize asynchronous programming and error handling to ensure robustness and reliability. Your goal is to implement the `fund_new_account` function, which will initiate the funding process for ...
codefeedback
You are tasked with creating a Python class that generates image URLs for different map styles using the Google Maps API. Your task is to implement the `GoogleTiles` class with the following requirements: - The class should have a constructor that takes a single argument `style`, which represents the map style ("roadm...
codefeedback
You are tasked with implementing a generic function that finds the closest endpoint from a given list of trip endpoints. Additionally, you need to create a class for drawing a route that implements a specific interface. Your task is to implement the `FindClosest` function and the `Drawable` class according to the foll...
codefeedback
You are tasked with creating a build automation tool similar to `make` that can handle parallel execution of tasks. Your tool should be able to execute a set of tasks concurrently, with a specified maximum number of parallel tasks. Each task is represented by a shell command that needs to be executed. Your task is to ...
codefeedback
You are tasked with implementing a multi-threaded UDP client in C++ that sends and receives data using User Datagram Protocol (UDP). The client will communicate with a server to exchange messages over the network. Your goal is to create a program that can handle concurrent communication with the server using multiple t...
codefeedback
You are tasked with creating a C++ program that reads and processes XML data using the XmlReader class. The program should utilize XmlNamespaceManager and XmlParserContext to handle XML namespaces and parsing context. Your task is to complete the code snippet provided below by instantiating an XmlReader object and usi...
codefeedback
You are tasked with implementing a simple dependency injection system in TypeScript. The provided code snippet is a part of a larger application that uses dependency injection to manage the creation and resolution of objects. Your goal is to create a class that can resolve dependencies based on the provided configurati...
codefeedback
You are tasked with implementing a simple HTTP request builder in Rust. Your task is to create a struct `RequestBuilder` and implement several methods for building different types of HTTP requests. The provided code snippet shows the beginnings of the implementation, with methods for `delete`, `head`, and a generic `re...
codefeedback
You are working on a project that involves controlling the color of an LED light using a microcontroller. The code snippet provided is a part of the program that sets the color of the LED based on input values from sliders. The `s` variable represents the brightness of the LED, and the `r`, `g`, and `b` variables repre...
codefeedback
You are tasked with implementing a function that processes event data based on the given code snippet. The function takes two parameters: `type` (a string) and `tokens` (an array of objects). The `type` parameter represents the type of event, and the `tokens` parameter contains objects with `type` and `value` propertie...
codefeedback
You are tasked with implementing a custom autocomplete feature for a text input field in a web application. The autocomplete feature should support the insertion of atomic components when a specific trigger character is entered. The atomic components are represented by a `CityChip` component and are triggered by the `/...
codefeedback
You are tasked with creating a Swift function that handles the decoding of JSON data and returns the result using a completion handler. Your function should handle both successful decoding and error cases, providing appropriate responses for each scenario. Write a function `decodeMap` that takes in JSON data and a com...
codefeedback
You are tasked with implementing a method to convert a given integer into a string using a custom encoding scheme. The encoding scheme involves converting the integer into a string by repeatedly taking the remainder of the number when divided by 32 and mapping it to a specific character. The characters are predefined i...
codefeedback
You are given an array `a` of size 210, a 2D array `val` of size 210x210, an array `b` of size 210, a vector of arrays `parent` of size 210, an array `ans` of size 110, and an integer `n`. The arrays and vectors are initialized as shown in the code snippet. Your task is to implement a function `calculateAnswer` that t...
codefeedback
You are tasked with creating a Python function that processes the results of a system check and generates a report based on the results. The function will take in a `result` object, which contains information about the host and the task, as well as the results of the system check. The function should extract relevant i...
codefeedback
You are tasked with implementing a migration tracking system for a database schema. The system should keep track of dependencies between migrations and provide a way to determine the order in which migrations should be applied. You are given a list of dependencies in the form of tuples, where each tuple contains two e...
codefeedback
You are tasked with implementing a TypeScript type utility called `WidenLiteral` that widens the literal types of a given input type. The `WidenLiteral` type should take an input type `A` and widen any literal types within `A` to their respective primitive types (string, number, or boolean). If `A` is not a literal typ...
codefeedback
You are tasked with creating a Rust function that manipulates URLs based on a given configuration. The function should take in a `DatabaseConfig` struct and return a modified URL based on the rules specified below. The `DatabaseConfig` struct has the following fields: - `url`: a string representing the database connec...
codefeedback
You are given a class `Matrix` that represents a matrix and the following code snippet: ```cpp FillWithValues(MWC, B); Matrix A1 = A; Matrix B1 = B; A.Release(); B.Release(2); swap(A, B); int a = A.size() - B1.size(), b = B.size() - A1.size(); Matrix D = A - B1; Print(D); D = B - A1; ``` Your task is to implement the...
codefeedback
You are tasked with implementing a class that handles the conversion of Data Transfer Objects (DTOs) to Models and vice versa, while ensuring the integrity of the data. Your task is to complete the implementation of the `updateOrFail` method in the given PHP class. The method should update the model with the data from ...
codefeedback
You are tasked with implementing a simple encryption and decryption algorithm using a Python class. The class has methods for generating a public key, setting a partner's key, encrypting a message, and decrypting a message. Your task is to complete the implementation of the encryption and decryption methods based on th...
codefeedback
You are tasked with implementing a function to handle error handling and data extraction from a ZooKeeper client in Rust. The given code snippet is part of a Rust program that interacts with ZooKeeper using the `tokio-zookeeper` library. The `.next()` method is used to retrieve the next event from the ZooKeeper client'...
codefeedback
You are tasked with creating a program that analyzes the frequency of words in a given text and outputs the top N most frequent words. Your program should ignore common English stop words (e.g., "the", "and", "of") and should be case-insensitive (e.g., "The" and "the" should be considered the same word). The program sh...
codefeedback
You are tasked with implementing a lazy evaluation mechanism using the Thunk data structure in Rust. Thunk is a container type that delays the evaluation of its content until it is explicitly requested. Your goal is to create a Thunk implementation and demonstrate its usage in a specific scenario. You are given the fo...
codefeedback
You are tasked with implementing a function that parses and processes an SVG path string to extract specific information about the path commands. The SVG path string consists of a sequence of commands such as M (move to), L (line to), H (horizontal line to), V (vertical line to), C (cubic Bézier curve), and Z (close pa...
codefeedback
You are tasked with implementing a web application feature for adding and editing articles. The application uses the Flask framework for the backend and Jinja2 templating for the frontend. The provided code snippet is from the backend Python code, where the `render_template` function is used to render the `add_article....
codefeedback
You are given a snippet of code that is part of a program to generate an HTML table based on a 2D vector `v` of integers and a set `failed_coords` containing pairs of coordinates. The code snippet iterates through the 2D vector and generates HTML table rows and cells based on the values in the vector and the presence o...
codefeedback
You are tasked with implementing a C++ class that applies the Porter2 stemming algorithm to a given set of words. The Porter2 stemming algorithm is a widely used algorithm for stemming words in the English language. Stemming is the process of reducing words to their root form, which helps in tasks such as text analysis...
codefeedback
You are given a list of Japanese manga titles as strings. Your task is to write a function to sort these titles in lexicographical order, ignoring any special characters such as kanji, hiragana, or katakana. The sorting should be case-insensitive and should treat the titles as if they were written in the Latin alphabet...
codefeedback
You are tasked with implementing a simple version control system for a text editor. The system should support the following operations: 1. `validate()`: This method should return a boolean value indicating whether the current version of the text is valid or not. A version is considered valid if it has not been rolled ...
codefeedback
You are tasked with creating a Python web application using FastAPI to manage user authentication and authorization. Your goal is to implement a nested router structure similar to the one shown in the code snippet below. The application should have routes for user actions, login actions, and logout actions, each with t...
codefeedback
You are tasked with optimizing a function using Differential Evolution (DE) algorithm. The given code snippet is a part of the DE algorithm implementation. The algorithm is being used to optimize a fitness function, and the code snippet shows the timing of the optimization process and the saving of fitness values and c...
codefeedback
You are tasked with creating a program that simulates a simplified version of a blockchain network. In this network, each block contains a transaction and a reference to the previous block. Your program should be able to add new blocks to the blockchain and verify the integrity of the entire chain. Your task is to imp...
codefeedback
You are tasked with implementing a function to perform quantized bias addition. Quantized bias addition involves adding a bias to a quantized input, where the input and bias are represented as fixed-point numbers with a specified number of integer and fractional bits. The function should take the quantized input, the b...
codefeedback
You are tasked with implementing a class that simulates a liquid container with a valve. The class should support filling the container with liquid, emptying the container, and checking the current volume of liquid. The provided code snippet is part of the implementation of this class. Your task is to complete the impl...
codefeedback
You are tasked with implementing a builder pattern for configuring SSL contexts in Java. The `SslConfigBuilder` class is provided as a starting point, and you need to extend it to support the configuration of various SSL parameters. The goal is to create a flexible and easy-to-use API for setting up SSL contexts for se...
codefeedback
You are tasked with creating a Python function that simulates a simple banking system. The function should allow users to create accounts, deposit funds, withdraw funds, and check their balance. Each account should have a unique account number and should store the account holder's name and current balance. Create a cl...
codefeedback
You are tasked with creating a simple GUI application using Python's PyHtmlGui library. The PyHtmlGui library allows for the creation of web-based graphical user interfaces using Python. Your goal is to create a basic application that displays a button and updates a counter each time the button is clicked. Your task i...
codefeedback
You are tasked with implementing a logging system for monitoring and tracking incidents in a software application. The system should be able to handle both incrementing and decrementing the count of incidents and log appropriate messages for each operation. You are provided with a code snippet that includes a conditio...
codefeedback
You are working on a robotics simulation software and need to implement a feature for exporting robot data. The software has a class `RobotExporter` with two methods: `export_failed_eval_robot` and `export_snapshots`. The `export_failed_eval_robot` method is responsible for exporting the genotype and phenotype of a rob...
codefeedback
You are working on a web application that manages educational institutions and their associated data. The application uses a PHP framework with an ORM (Object-Relational Mapping) library to interact with a database. The code snippet provided is a part of a larger query-building process where conditions are being applie...
codefeedback