instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a C++ class that provides compatibility between two different peripheral libraries for microcontrollers. The given code snippet is a part of a namespace `lpc17xx` which is intended to be compatible with the `lpc40xx` peripheral library. The snippet shows that the `lpc17xx` namespace is ...
codefeedback
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should keep track of the total number of transactions performed on all instances of the class. Your task i...
codefeedback
You are tasked with implementing a function that will parse a given HTML code snippet and extract the names of all HTML tags present in the snippet. An HTML tag is defined as a string enclosed within angle brackets, such as `<div>`, `<p>`, or `<img>`. The function should return a list of unique tag names present in the...
codefeedback
You are tasked with creating a function that retrieves the user scopes from a given object hierarchy. The object structure consists of an issue, project, and organization, and the function should return the user scopes associated with the given user. You are given the following class definitions: ```python class Orga...
codefeedback
You are tasked with creating a Python function that interacts with InfluxDB to store financial transaction data from multiple bank accounts. The function should take in a configuration dictionary containing InfluxDB and bank account details, and then iterate through the bank account configurations to store the transact...
codefeedback
You are tasked with implementing a Python class that handles Twitter access tokens and mutations for a GraphQL API. The class should handle the creation of a Twitter request token and the mutation for obtaining an access token. Your task is to complete the implementation of the `TwitterAccessToken` class by writing the...
codefeedback
You are tasked with implementing a custom slider control in Swift that allows users to select different filters. The slider control will be represented by the `SNSlider` class, and it will have a delegate protocol `SNSliderDelegate` for handling filter selection events. The `SNSliderDelegate` protocol contains a single...
codefeedback
You are tasked with implementing a function that will parse a given HTML file and count the occurrences of specific HTML comments within it. HTML comments are defined within `<!--` and `-->` tags. Your function should take the HTML file content as input and return the count of the specified HTML comments. Function Sig...
codefeedback
You are tasked with implementing a Python function that interacts with a RESTful API. The function, `api_request`, takes in several parameters and makes an HTTP request to the specified URL. Your task is to complete the function by handling the response based on the provided `response_type`. The `api_request` function...
codefeedback
You are tasked with implementing a Python class that manages external command execution. The class, named `CommandManager`, should handle the execution of shell commands and provide functionality to start, stop, and retrieve the output of the executed commands. However, the initial implementation of the class contains ...
codefeedback
You are given a string representing a video file name. The file name consists of the video title, followed by a series of characters representing the video's properties. The properties are enclosed within square brackets and separated by a single space. Each property is in the format "key=value". Your task is to extrac...
codefeedback
You are tasked with creating a function that processes HTTP response status codes and returns an appropriate result based on the status code range. Your function should handle different status code ranges and return a specific result for each range. Write a function `handleResponse` that takes two parameters: 1. `stat...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should be able to create and manage bank accounts, allowing users to deposit, withdraw, and check their balance. Additionally, the program should be able to transfer funds between accounts. Your task is to implement the `BankAcc...
codefeedback
You are tasked with creating a Python program that utilizes the Elasticsearch library to perform text searching and benchmark the performance against a custom implementation using SimString. The program should measure the time taken for each search method and compare their efficiency. Your program should include the f...
codefeedback
You are given a grayscale image represented as a 2D array of integers, where each integer represents the intensity of a pixel. Your task is to implement a program that simulates a game where the player tries to guess the values of k pixels in the image. If the player guesses the correct value for a pixel, they earn a p...
codefeedback
You are tasked with creating a Python function that generates a Linux user creation command based on given parameters. The function should take in the following parameters: - `username` (string): The username for the new user. - `system_user` (boolean): A flag indicating whether the user should be a system user. - `cr...
codefeedback
You are tasked with creating a Git automation script that performs the following actions: 1. Adds all the modified files to the staging area. 2. Commits the changes with the message "auto push". 3. Pushes the committed changes to the remote repository with the main branch as the default branch. Write a Python function...
codefeedback
You are tasked with implementing a Swift function that converts a value from the Cassowary library to a corresponding Strength enum value. The Cassowary library is used for constraint solving in user interface layout systems, and the Strength enum represents the strength of a constraint. The Strength enum has cases for...
codefeedback
You are given a list of integers representing the daily stock prices of a company. Your task is to write a function that calculates the maximum profit that can be obtained by buying and selling the stock on different days. The function should take the list of stock prices as input and return the maximum profit that can...
codefeedback
You are tasked with implementing a function that manipulates stack views in a user interface. Stack views are a fundamental component in iOS development for laying out a collection of views either horizontally or vertically. Your task is to create a function that takes in an array of event views and arranges them in a ...
codefeedback
You are tasked with implementing a custom string class in C++ called `CustomString`. This class should have the following functionalities: 1. A default constructor that initializes an empty string. 2. A parameterized constructor that takes a C-style string (null-terminated character array) as input and initializes the ...
codefeedback
You are tasked with implementing a memory management system for a slab allocator. A slab allocator is a memory allocation algorithm that manages memory in fixed-size blocks called slabs. Each slab is divided into slots, and each slot can hold an element of a specific type. The allocator maintains a list of slabs, and e...
codefeedback
You are tasked with implementing a neural network architecture using PyTorch for a computer vision project. The given code snippet is a part of the network definition and includes the initialization of various layers and operations. Your task is to understand the code snippet and answer a question related to the networ...
codefeedback
You are tasked with creating a Python function to analyze a given directory structure and generate an API analysis report. The function should take the input directory path and the output report directory path as input parameters. The analysis should involve traversing the input directory, extracting relevant informati...
codefeedback
You are tasked with implementing a confidential token transfer system for a blockchain application. The system involves encrypting and decrypting token balances and approving token transfers between accounts. You are provided with a code snippet that demonstrates the usage of a hypothetical `alice_ae_key` object to dec...
codefeedback
You are tasked with creating a function that processes a list of actors and their movies. Each actor is represented by an object containing their ID, name, and a list of movies they have starred in. Your goal is to implement a function that takes this list of actors and returns a new list containing only the names of t...
codefeedback
You are tasked with creating a Python function that processes HTML content to extract specific information from a website. The function should take a list of HTML elements as input and extract the href, title, and src attributes from each element. Additionally, it should make an HTTP request to a specific URL construct...
codefeedback
You are tasked with implementing a custom DataGridView control in C# that includes a specialized checkbox column. The code snippet provided initializes the header cell and cell template for the custom checkbox column. Your task is to complete the implementation by adding functionality to handle the checkbox state chang...
codefeedback
You are tasked with implementing a program to rotate a given array of integers by a specified number of positions to the right. The rotation should be performed in-place, meaning that the original array should be modified directly. Additionally, you need to handle the case where the rotation count exceeds the length of...
codefeedback
You are tasked with creating a custom error type for a Rust application. Your error type should represent a failure to connect to a server. Additionally, you need to implement a function that attempts to connect to a server and returns a result containing either a successful connection or an error of the custom error t...
codefeedback
You are tasked with implementing a defense mechanism for a machine learning classifier using the Keras library. The defense mechanism aims to protect the classifier from adversarial attacks by modifying the input data before it is fed into the classifier. The defense mechanism is implemented using the ActivationDefence...
codefeedback
You are tasked with creating a Rust function that interacts with two different endpoints asynchronously. Your goal is to implement a function that takes two `Uri` parameters representing the URLs of two different endpoints and returns a new application. You are provided with the following code snippet as a starting po...
codefeedback
You are tasked with creating a program that performs Dead Code Elimination (DCE) and Common Subexpression Elimination (CSE) on a binary file. The given code snippet is a part of a test function for this program. The program uses the `FileSource` and `RadecoModule` structs to open and analyze the binary file. Your task...
codefeedback
You are tasked with implementing a function to read and process image files. The function should validate the file extension and then read the image data into a suitable data structure. Your task is to complete the implementation of the `ReadImageFromFile` function, ensuring that it correctly handles the file extension...
codefeedback
You are tasked with creating a data streaming application that reads a file in batches and sends each batch over a network connection. The provided code snippet is a simplified version of the streaming logic. The `tail` command extracts lines from the end of a file, the `head` command selects a specific number of lines...
codefeedback
You are tasked with creating a Python function that efficiently determines whether a given number is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take an integer as input and return `True` if the number is prime, and `False...
codefeedback
You are tasked with creating a Python class that simulates the financial behavior of agents over time. The class should include methods for initializing agent parameters and simulating their financial decisions. The provided code snippet is a part of the class and includes some initial parameters for the simulation. Y...
codefeedback
You are tasked with simulating a progress bar for a file download process. You are given a `ProgressBar` class with a method `reach_percent(percent: u32)` that updates the progress bar to the specified percentage. Your goal is to implement a function `simulate_file_download(total_size: u32)` that simulates the file dow...
codefeedback
You are tasked with creating a program to generate multiple-choice history questions based on a given set of parameters. The program should take in a list of historical facts and generate a set of questions based on these facts. Each question should be in the form of a JSON object with the following structure: ```json...
codefeedback
You are tasked with creating a function that converts a given entity of type `FeaturedContentType` into a set of form values of type `FeaturedContentFormValues`. The function should handle the conversion by extracting specific properties from the entity and mapping them to the corresponding properties in the form value...
codefeedback
You are tasked with implementing a prime number generator in Python. Your goal is to create a function `prime_generator()` that returns an iterable of integers, with each next element being the next prime number. You should also implement a helper function `is_prime(n: int) -> bool` that takes an integer `n` as input a...
codefeedback
You are given a list of integers `nums`. Your task is to write a function that returns the second largest element in the list. You should not use any built-in sorting functions or libraries. Function signature: `def second_largest(nums: List[int]) -> int:` Example: Input: `nums = [3, 8, 1, 6, 4, 5, 7, 2]` Output: `7`
codefeedback
You are tasked with implementing a thread-safe circular buffer for a communication interface in C++. The circular buffer will be used to store incoming data from an I2C device. The buffer should support the following operations: 1. `void write(uint8_t data)`: Adds a byte of data to the buffer. 2. `uint8_t read()`: Remo...
codefeedback
You are tasked with creating a form validation function for a web application using PHP. The form is built using Laravel's Blade templating engine, and the validation rules need to be implemented in the backend using Laravel's validation system. The form contains a submit button and an error message container. The sub...
codefeedback
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score, excluding the highest and lowest scores. Write a function `calculate_average_score(scores)` that takes in a list of integers `scores` and returns the average score, rounded to the nea...
codefeedback
You are tasked with implementing three evaluation metrics for information retrieval systems: Recall, Mean Reciprocal Rank (MRR), and Mean Average Precision (MAP). These metrics are commonly used to assess the performance of search engines, recommendation systems, and other information retrieval applications. For this ...
codefeedback
You are tasked with implementing a simple error checking system for a document processing application. The system should allow the registration of different severity levels of checks and provide a mechanism to consume the results of these checks. To achieve this, you need to define a function type `CheckResultConsumerF...
codefeedback
You are working on a project that involves building a web application using the Vapor framework, which is a popular web framework for Swift. As part of this project, you need to create a model for managing user accounts. The user model should include fields for the user's name, email, and password. Additionally, you ne...
codefeedback
You are working on a mapping application that uses GeoJSON data to represent geographic features. You need to implement a function to parse GeoJSON LineString and Point objects into an array of CLLocationCoordinate2D objects. The GeoJSON data is represented as a JSON dictionary with specific keys and values. Write a f...
codefeedback
You are tasked with creating a Swift program to process and update the status of bulk shift trade operations. The program should define a `Status` enumeration with cases for "Processing", "Complete", "Canceled", and "Error". Additionally, the program should include a class with the following properties: - `status`: An ...
codefeedback
You are tasked with creating a Python decorator that tracks the number of times a function is called and enforces a cooldown period between successive calls. The decorator should be able to handle different cooldown periods for different functions. Your task is to implement the `cooldown` decorator function, which tak...
codefeedback
You are tasked with creating a Python programming problem that involves testing a command-line tool using the `unittest` framework. The problem will require students to write a test case for a specific command-line tool and verify its functionality. You are provided with a code snippet that imports the necessary modul...
codefeedback
You are tasked with creating a Python class that simulates a simple library management system. The class should be able to handle the borrowing and returning of books by library members. Additionally, it should keep track of the availability of each book and the members who have borrowed them. Your task is to implemen...
codefeedback
You are tasked with implementing a payment validation system for a Financial Institution. The system should validate payment details for a specified Settlement Date and ensure that the payment instruction is submitted before the cut-off time on the same Business Banking Day as the Settlement Date. Additionally, the sys...
codefeedback
You are tasked with implementing a simple protocol state machine in Rust. The protocol has three states: `Init`, `Established`, and `Closed`. The state machine transitions between these states based on events and actions. Your task is to define the `ProtocolState` enum and implement the transition logic for the state ...
codefeedback
You are tasked with implementing a constraint satisfaction problem (CSP) solver in Rust. A CSP consists of a set of variables, each with a domain of possible values, and a set of constraints that specify the allowable combinations of values for different variables. Your task is to implement the `Constraint` struct and ...
codefeedback
You are tasked with creating a custom event system for handling interactions with XR (extended reality) buttons in a Unity application. The provided code snippet is a starting point for this task. Your goal is to extend this event system to support additional functionality and ensure proper integration with XR interact...
codefeedback
You are tasked with implementing a custom data loader for a computer vision project. The data loader will be used to load and preprocess images for training a machine learning model. The provided code snippet initializes the data loader for the training dataset and sets some configuration parameters. Your task is to i...
codefeedback
You are tasked with implementing a function to decode a URI (Uniform Resource Identifier) that has been encoded using the UTF-8 encoding scheme. The function should handle the decoding process by replacing '+' characters with spaces and converting any percent-encoded sequences back to their original characters. You ar...
codefeedback
You are tasked with implementing a function to calculate the moving average of a stream of numbers. The function should take in a new number at each step and return the average of the last N numbers, where N is a parameter provided to the function. You should also handle the case where there are fewer than N numbers in...
codefeedback
You are tasked with implementing a state builder for an equation of state in a thermodynamics library. The state builder is responsible for creating a state with specific thermodynamic properties such as temperature, volume, density, and moles. Your task is to complete the implementation of the `StateBuilder` struct an...
codefeedback
You are tasked with implementing a function that validates a given view ID based on certain criteria. The view ID is a string that should adhere to the following rules: 1. The view ID must be exactly 4 characters long. 2. The first two characters must be digits between 01 and 12, representing the month. 3. The last two...
codefeedback
You are working on a compiler infrastructure project and need to implement a new pass for optimizing operations targeted for execution on a specialized hardware accelerator called TPU (Tensor Processing Unit). The provided code snippet is a part of the infrastructure for registering and creating this pass using MLIR (M...
codefeedback
You are tasked with implementing a class that manages spending limits for a wallet application. The provided code snippet is a part of the implementation and contains the initialization of certain UI elements and the `viewDidLoad` method of a view controller. Your task is to create a `SpendingLimitManager` class that ...
codefeedback
You are tasked with implementing a C++ function that applies a transformation to a vector based on two input vectors. The transformation is defined by the `Apply3` struct, which overloads the `operator()` to take in a vector `vec` and two additional vectors `vec2` and `vec3`. Your task is to complete the implementation...
codefeedback
You are tasked with implementing a custom chart plotting functionality for a reporting tool. The tool uses the JasperReports library, and you need to create a custom area plot for visualizing data. The area plot should be able to display data in a filled area format, providing a visual representation of the data's magn...
codefeedback
You are tasked with implementing a function to calculate the similarity matrix of a given set of sentences. The similarity matrix will represent the pairwise similarity between the sentences based on the presence of common words. The similarity between two sentences is calculated as the ratio of the number of common wo...
codefeedback
You are tasked with creating a function to calculate the overall activity portfolio based on the provided arguments and report data. The function should handle various types of activities and their corresponding weights to generate a comprehensive portfolio report. The function `calculate_activity_portfolio` takes two...
codefeedback
You are tasked with creating a program to manage course listings for various departments in a university. The program should scrape course information from each department's webpage and compile a list of all available courses. Each department has a unique set of courses, and the program needs to collect this informatio...
codefeedback
You are tasked with creating a Python function that simulates a simple text-based game. The game involves a player receiving a message and responding within a specified time limit. The player must either provide a message that is similar to a given title or enter "forcestop" to end the game prematurely. The game is pla...
codefeedback
You are tasked with creating a Bash script that processes command-line arguments to set input and output directories for a data processing task. The script should handle the options `-i` for input directory and `-o` for output directory. Once the script is executed, it should process the provided arguments and then shi...
codefeedback
You are tasked with implementing a Python decorator that registers strategy classes for building Element objects. The decorator, `@strategy('id')`, is used to mark strategy classes, and the registered strategies are used to build Element objects. Your goal is to create a decorator that allows strategy classes to be reg...
codefeedback
You are given a class `StringManipulator` with a method `FindLongestWord` that takes a string as input and returns the longest word in the string. However, the method is incomplete and needs to be implemented. Your task is to complete the `FindLongestWord` method to return the longest word in the input string. A word i...
codefeedback
You are tasked with creating a Rust plugin system for a game engine. The game engine provides a set of hooks that plugins can register to, allowing them to execute custom code at specific points during the game's runtime. Your goal is to implement the plugin registration system using the provided code snippet as a star...
codefeedback
You are tasked with implementing a custom logging system for a home automation platform. The provided code snippet includes a Python module that sets up a logger and defines a callback function for registering an API in the home automation system. Your task is to extend this code by creating a custom logging handler th...
codefeedback
You are tasked with creating a program that reads a text file and counts the occurrences of each word in the file. Your program should ignore punctuation and consider words regardless of their case (i.e., "Hello" and "hello" should be considered the same word). Additionally, the program should exclude common stop words...
codefeedback
You are tasked with implementing a custom memory allocator in Rust. Your allocator should support allocating and freeing memory for a specific data structure. The allocator should be able to handle memory allocation and deallocation efficiently, without causing memory leaks or fragmentation. Your task is to implement ...
codefeedback
You are tasked with creating a Python script that automates the installation of software packages on a Linux system. Your script should take a list of packages as input and install them using the appropriate package manager commands. For this problem, you will focus on using the `apt-get` package manager, commonly foun...
codefeedback
You are tasked with implementing a simple encounter state system for a text-based adventure game. The provided code snippet shows a base class for all encounter state objects, along with a method `doTurn` that executes the next action for the encounter state. Your task is to create a subclass of the encounter state th...
codefeedback
You are tasked with implementing a function to perform standard kernel tests on a given kernel function. The kernel function is a mathematical function that quantifies the similarity between two data points in a higher-dimensional space. The standard kernel tests involve evaluating the kernel function on various input ...
codefeedback
You are tasked with creating a caching mechanism for a Flask web application. The application should utilize Flask-Caching to store and retrieve cached data efficiently. Your goal is to implement a simple Flask route that retrieves data from an external API and caches the response for a specified duration. You will nee...
codefeedback
You are tasked with creating a script to automate the testing of a Kubernetes cluster using Minikube. Your script should perform the following steps: 1. Start a Minikube cluster. 2. Deploy a sample application to the cluster. 3. Verify that the application is running and accessible within the cluster. 4. Output a succe...
codefeedback
You are tasked with creating a script that performs a find-and-replace operation on files within a specified directory. Your script should prompt the user for a file pattern to search for, an existing string to replace, and a replacement string. After receiving these inputs, the script should then execute the find-and-...
codefeedback
You are tasked with implementing a simplified version of an interrupt handler in Swift. An interrupt handler is a callback function that is executed in response to an interrupt signal. In this problem, you will create a class that sets up an interrupt handler and writes to a file upon initialization. You will also impl...
codefeedback
You are tasked with creating a Django migration for a new model in a web application. The model represents a simple online store product, with fields for the product's name, price, and description. Your task is to write a migration file that will create the corresponding database table for this model. The model defini...
codefeedback
You are tasked with creating a program that reads a directory and its subdirectories to count the total number of files with a specific file extension. Your program should take the directory path and the file extension as input and return the count of files with that extension. Your task is to implement the `FileCount...
codefeedback
You are tasked with creating a function that parses HTML code to extract the text content of a specific element identified by its ID. Your function should take two parameters: the HTML code as a string and the ID of the element to extract. The function should return the text content of the specified element. For examp...
codefeedback
You are tasked with creating a command-line interface for a chatbot using Python's `asyncio` library. The chatbot has a predefined list of commands and their corresponding categories. Your goal is to implement a function that processes user input and provides appropriate responses based on the input. You are given the...
codefeedback
You are tasked with implementing a function to parse a binary data stream and extract subpackets of varying lengths. The input data stream consists of packets, each prefixed by a length field indicating the number of bits in the packet. Your task is to implement a function that can parse the input binary data stream an...
codefeedback
You are tasked with creating 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. Create a Python class named `BankAccou...
codefeedback
You are tasked with writing a script to automate the installation of a device driver on a Windows system. The script needs to use the provided variables and directory paths to locate and install the driver file. Given the code snippet: ``` drivername="$TARGETNAME" driver="${drivername}.sys" DDK_DIR="C:\\WinDDK\\7600.1...
codefeedback
You are tasked with implementing a custom iterator class in Python that takes a list of Union[int, str] as input and iterates through the list, returning only the integer values in ascending order. If the input list contains strings that represent integers, they should be converted to integers before being returned. If...
codefeedback
You are working on a project that involves analyzing the stability of molecules using quantum mechanics calculations. The project utilizes the QM9 library, which provides various functionalities for molecular analysis. One of the tasks is to sample molecular chains and individual molecules for further analysis. Your t...
codefeedback
You are given a binary search tree (BST) with distinct nodes. Write a function to find the minimum absolute difference between values of any two nodes in the tree. The BST is represented by a root node, and each node's value is an integer. For example, given the following BST: ``` 4 / \ 2 6 / \ 1 3 ```...
codefeedback
You are tasked with implementing a user access control system for a company's internal application. The system should allow certain users, such as administrators and managers, to view the profiles of other employees within the same company. The `show` function in the provided code snippet is a part of this access contr...
codefeedback
You are tasked with creating a Python script that automates the process of building and distributing a Python package using the `setuptools` library. The script should perform the following tasks: 1. Create a `setup.py` file with the necessary metadata for the package. 2. Build a wheel distribution of the package using...
codefeedback
You are tasked with creating a Java program that processes date and time information using the `java.time` package. Your program should read a string representing a date and time in ISO 8601 format with an offset, convert it to a different time zone, and then output the date and time in the new time zone. Your program...
codefeedback
You are tasked with creating a function that converts hexadecimal strings found in a YAML input to their corresponding base64 representation. The input YAML may contain various fields, some of which may include hexadecimal strings that need to be converted. However, there is a special case where fields containing the w...
codefeedback
You are tasked with implementing a simple snake game using Python and the Pygame library. The provided code snippet is part of the game loop, responsible for updating the game state and rendering the game objects. Your task is to complete the implementation by defining the missing methods and classes. You are given a ...
codefeedback
You are tasked with creating a Python function that interacts with a PostgreSQL database to create a fixture for testing purposes. The function should connect to the specified database, generate a fixture, and save it for later use in testing. Your task is to implement the `create_fixture` function using the `psycopg2`...
codefeedback