instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a custom validation rule system for a web application. The application uses a PHP framework, and the validation rules are defined using the `SingleRuleValidator` class from the `App\Common\Validation\RuleValidator` namespace. The `SingleRuleValidator` class is responsible for validating...
codefeedback
You are tasked with implementing a cryptographic signature verification system using the Secp256k1 library in a WebAssembly (WASM) environment. The provided code snippet is a TypeScript declaration for the Secp256k1WASM module, which exposes the following functions: - `sign(e: number)`: A function that takes a number `...
codefeedback
You are given a 2D array `arr` containing numerical values. Your task is to implement a function that performs the following operations: 1. Convert all elements of the array to integers. 2. Print the modified array. Write a function `convert_and_print(arr)` that takes the input 2D array `arr` and performs the above op...
codefeedback
You are tasked with creating a class that represents a user entity in a system. The class should include properties for creation and deletion timestamps, user IDs for creation and deletion, as well as collections for grants and management units associated with the user. Additionally, it should have references to the us...
codefeedback
You are tasked with implementing a function to perform 3D transformations on a given object. The function should take in the initial position of the object and two rotation angles, and then apply the rotations to the object's position. You are given the following code snippet as a starting point: ```cpp glm::mat4 rot...
codefeedback
You are tasked with creating a program that automatically calculates and sets the optimal heap size for a virtual machine based on the available memory. The heap size is a critical parameter for the performance of applications running on the virtual machine. Your program should take into account the available memory an...
codefeedback
You are tasked with creating a program that simulates a simplified version control system. Your program should be able to handle basic version control operations such as committing changes, checking out previous versions, and displaying the commit history. You are given a code snippet from a version control system tha...
codefeedback
You are tasked with creating a Python class to represent a GitHub repository. The class should have attributes for the repository's full name, last push date, archived status, description, topics, and default branch. Additionally, the class should have a method to update the last push date and another method to add new...
codefeedback
You are tasked with creating a program to manage a virtual library system. The system should allow users to perform various operations such as adding books, searching for books, and displaying the available books. Your task is to implement a class `Library` that provides the necessary functionality for managing the vir...
codefeedback
You are tasked with creating a Python program that analyzes the disk space usage of a specified directory and its subdirectories. Your program should calculate the total size of all files within the directory and its subdirectories and display the results in a human-readable format. Your program should take a single c...
codefeedback
You are tasked with implementing a function that generates an SVG (Scalable Vector Graphics) file based on the input parameters. The function should take a filename, a title, and a vector of data points as input and produce an SVG file representing the data. Your task is to implement the `render_svg` function, which t...
codefeedback
You are given a 2D array representing an image, where each element represents the intensity of a pixel. Your task is to implement the Completed Local Binary Pattern (CLBP) algorithm to extract two types of features from the image. The CLBP algorithm works as follows: 1. For each pixel in the image, calculate the local...
codefeedback
You are tasked with creating a custom time zone implementation using Python. Your goal is to define a custom time zone class that inherits from `datetime.tzinfo` and implements the necessary methods to handle time zone conversions. Your custom time zone class should be named `CustomTimeZone` and should have the follo...
codefeedback
You are tasked with creating a Python program to fetch and process stock market data using the Tushare library. Your program should be able to retrieve historical stock data for a given stock symbol, calculate the moving average, and identify buy/sell signals based on the moving average crossover strategy. Your progra...
codefeedback
You are given a DNA sequence in the form of a string containing characters 'A', 'C', 'G', and 'T'. Your task is to write a function to find the reverse complement of the given DNA sequence. The reverse complement of a DNA sequence is formed by reversing the sequence and replacing each base with its complement: 'A' is r...
codefeedback
You are tasked with implementing a message passing system between a browser extension and a native application. The browser extension sends a message to the native application using the `browser.runtime.sendNativeMessage` method, and the native application processes the message and sends a response back to the extensio...
codefeedback
You are tasked with implementing a function that processes Lua scripts in a C# application. The given code snippet is part of a C# class that interacts with Lua scripts using the LuaInterface library. The class contains a method for registering a C# class with Lua and a callback function for creating instances of the r...
codefeedback
You are tasked with implementing a thread-local storage mechanism for an embedding layer store in Python. The `_EmbeddingLayerStore` class is designed to manage a collection of embedding layers in a thread-safe manner. The `_create_embedding` method is responsible for creating a new embedding layer and adding it to the...
codefeedback
You are tasked with implementing a function that calculates the sum of all the even numbers in a given array. The function should take an array of integers as input and return the sum of all the even numbers in the array. Function Signature: ```swift func sumOfEvenNumbers(_ numbers: [Int]) -> Int ``` For example, gi...
codefeedback
You are given a list of words and a target word. Your task is to write a function that determines whether the target word can be formed by concatenating any combination of the words from the list. Each word from the list can be used multiple times, and the order of the words can be rearranged. The function should retur...
codefeedback
You are tasked with implementing a data structure to efficiently store and retrieve encrypted server requests. Each request is identified by a unique request ID and includes the date of the request and the encrypted server data. Your task is to design a data structure and implement the necessary methods to store and re...
codefeedback
You are tasked with implementing additional functions for the MathServiceLibrary and creating a new client app to utilize these services. The MathServiceLibrary currently provides basic arithmetic operations and needs to be extended to include the following functionalities: 1. Compute the power of 2 values (v1 to the p...
codefeedback
You are tasked with implementing a simple event handling system for a mobile application. The provided code snippet contains empty event handler functions that need to be filled in with appropriate functionality. Each function corresponds to a specific application state transition and should be triggered accordingly. Y...
codefeedback
You are tasked with creating a program that analyzes a given text file to count the occurrences of each unique word. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters, excluding any punctuation or special characters. The program should be case-insensitive, meaning that "Hello" ...
codefeedback
You are tasked with creating a program that processes a network of people and their connections. Each person in the network is represented by a unique identifier, and their connections are represented as pairs of identifiers. Your task is to implement a function that takes in the list of connections and returns the num...
codefeedback
You are given a file containing a list of integers. For each integer in the file, you need to determine the remainder when the count of set bits (1s) in its binary representation is divided by 3. The count of set bits in a binary number is the number of 1s present in its binary representation. Write a program that tak...
codefeedback
You are tasked with implementing a file transfer protocol using Python's `serial` module for serial communication. The `force_write` function is provided to write a message to the serial port, and the `load` function is intended to load a file and send its contents over the serial port. However, the `load` function is ...
codefeedback
You are tasked with implementing a function to validate and process data related to a cryptocurrency token minting process. The function will take in a dictionary of keys and values, and it should extract specific information and perform validation checks on the data. You are given the following code snippet as a star...
codefeedback
You are tasked with implementing a filter module that expands a Kraken configuration file. The Kraken configuration file contains a set of key-value pairs, where the values can be simple strings or lists of strings. Your task is to create a Python class `FilterModule` with a method `expand_config` that takes the Kraken...
codefeedback
You are tasked with implementing a JSONParser class that extracts checklists from API JSON data. The JSONParser class should be able to handle different download formats and languages. Your task is to complete the implementation of the JSONParser class and ensure that it correctly extracts the checklists from the provi...
codefeedback
You are working on a project that utilizes the Flutter framework for building mobile applications. As part of the development process, you need to run a specific command to generate code using the build_runner tool. The command is as follows: ```bash flutter pub run build_runner build --delete-conflicting-outputs ``` ...
codefeedback
You are tasked with creating a program that utilizes a pre-trained model to perform named entity recognition (NER) on a given text. Named entity recognition is the process of identifying and classifying named entities in unstructured text into predefined categories such as names of persons, organizations, locations, ex...
codefeedback
You are tasked with implementing a Python class for a word prediction model. The model uses a word embedding layer to map words to a continuous vector space and then samples the next word based on the predicted probabilities. Your task is to complete the implementation of the `sample_next_word` method in the given Pyth...
codefeedback
You are tasked with implementing a Python function that filters a collection of objects based on certain conditions. The function takes in two parameters: `start` and `end`. The `start` parameter represents the starting point, and the `end` parameter represents the ending point for the filtering operation. The function...
codefeedback
You are tasked with creating a script to automate the download and extraction of the GeoLiteCountry database from MaxMind's GeoIP service. The GeoLiteCountry database provides information about the geographic location of IP addresses. The provided code snippet is a bash script that uses the `wget` command to download t...
codefeedback
You are tasked with implementing a function to estimate the time shift between camera and inertial measurement unit (IMU) data using a cross-correlation approach. The goal is to calculate the time shift that aligns the angular rates from the cameras and the IMU, assuming that the biases are small and the angular rates ...
codefeedback
You are tasked with creating a Python program that simulates a simple file management system. Your program should implement a class called `FileManager` which provides functionality for opening, writing to, and closing files. The class should have the following methods: 1. `open_file(filename: str, mode: str) -> None`...
codefeedback
You are tasked with implementing a program to filter and display words based on a given regular expression pattern. The program should read a list of words and their lengths from a table, apply the regular expression pattern to filter the words, and then display the filtered words along with their lengths in a tabular ...
codefeedback
You are tasked with implementing a parallel evaluation system for a genetic algorithm using the NEAT (NeuroEvolution of Augmenting Topologies) library in Python. NEAT is a method for evolving artificial neural networks through genetic algorithms. The given code snippet demonstrates the setup and execution of the NEAT a...
codefeedback
You are tasked with implementing a thread-safe permission management system for a service. The system should allow adding permissions for services, with the ability to filter permissions based on a provided filter. The code snippet provided is a part of the implementation for adding permissions to the system. Your task...
codefeedback
You are working on a security analysis tool that processes program paths and checks for tainted data. Tainted data is considered unsafe and needs to be sanitized before further processing. Your task is to implement a function that untaints buffers based on certain conditions. You are given a code snippet from the tool...
codefeedback
You are tasked with implementing a function that measures the execution time of another function. Your goal is to create a decorator that can be applied to any function to measure the time it takes to execute that function. The decorator should print the execution time in milliseconds after the function has completed i...
codefeedback
You are tasked with implementing a Python function to monitor the availability of a given URL by sending HTTP requests at regular intervals. The function should take the URL, response threshold, and timeout as input parameters. It should continuously send HTTP requests to the URL and return `True` if the number of cons...
codefeedback
You are tasked with creating a script that automates the process of weaving and tangling literate programming files using the noweb tool. Noweb is a simple, extensible tool for literate programming that allows mixing of documentation and code in a single source file. The given code snippet is a part of a script that pe...
codefeedback
You are tasked with implementing a custom string view class in C++. A string view is a non-owning reference to a sequence of characters. Your task is to create a class `CustomStringView` that mimics the behavior of `std::string_view` and supports the following functionalities: 1. Constructing a `CustomStringView` from ...
codefeedback
You are tasked with creating a program that analyzes the licensing information of software projects. The input will consist of a multi-line string representing the license information of various software projects. Each project's license information is structured as follows: - The license information starts with a comme...
codefeedback
You are tasked with implementing a training loop for a machine learning model. The given code snippet is a part of the training loop and includes the initialization of variables and the beginning of the training process. Your task is to complete the training loop by implementing the necessary steps for each batch of tr...
codefeedback
You are tasked with creating a Python program that simulates a simple chat server. The server will be able to accept multiple client connections and facilitate communication between them. Your task is to implement the server-side functionality for receiving and relaying messages between connected clients. Your program...
codefeedback
You are given a code snippet that is part of a program to print a specific pattern of numbers. Your task is to complete the program by writing the missing code to generate the desired pattern. The program is intended to print a pattern of numbers in the form of a pyramid. The pattern starts with the number 1 at the to...
codefeedback
You are tasked with implementing a Python package management system. The system should be able to resolve dependencies and import modules from different packages. The package manager should handle relative imports and resolve any circular dependencies. You are given a code snippet from a Python package named `my_packa...
codefeedback
You are working on a computer vision project and need to implement a class for handling image processing operations. The class has an initialization method with several parameters and functionalities. Your task is to complete the implementation of the `__init__` method by adding the missing parts. The `__init__` metho...
codefeedback
You are tasked with implementing a TypeScript type system for a simple data structure. The data structure consists of two types: `Nothing` and `Something`. The `Nothing` type represents the absence of a value, while the `Something` type represents the presence of a value. Additionally, two functions, `isNothing` and `i...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Additionally, the program should enforce a transaction limit for each account, preventing users from depositing or withdrawing amounts th...
codefeedback
You are tasked with creating a Python function that interacts with a database to retrieve the latest log entry. The function uses the `async` and `await` keywords to handle asynchronous operations. The code snippet provided is a part of the function and demonstrates the use of SQLAlchemy to insert a new log entry into ...
codefeedback
You are tasked with implementing a custom increment operator for a BigFloat data type in C#. The BigFloat data type represents a large floating-point number with arbitrary precision. Your goal is to create a class that includes both post-increment and pre-increment operators for the BigFloat type. Your task is to comp...
codefeedback
You are tasked with implementing a logging system for a software application. The system should support different log levels (DEBUG, INFO, WARNING, ERROR, etc.) and be able to format log messages with tags and optional auxiliary values. Your task is to create a class `Logger` with the following requirements: 1. The cl...
codefeedback
You are tasked with creating a program that simulates a simplified version of the `tmux` command-line tool. `tmux` is a terminal multiplexer that allows multiple terminal sessions to be accessed and controlled from a single window. Your program should handle the creation, management, and switching of terminal sessions ...
codefeedback
You are tasked with implementing a custom comparison class in C++ that can compare objects of different types. The class should support comparison between strings, custom configuration objects, and boolean values. Your task is to create a `CustomComparator` class that overloads the comparison operators to achieve the f...
codefeedback
You are tasked with creating a program that simulates a simple file system. The file system will consist of directories and files, and you need to implement the functionality to navigate through the directories, create new files, and list the contents of a directory. Your task is to implement a class `FileSystem` with...
codefeedback
You are tasked with creating a function that takes a list of integers as input and returns the maximum sum of a contiguous subarray within the input list. The function should efficiently handle both positive and negative integers. You need to implement the following function: ```python def max_subarray_sum(nums: List...
codefeedback
You are tasked with creating a simple iOS app that displays a list of items in a table view. The app should fetch data from a remote server and display it in a user-friendly manner. To achieve this, you need to implement the networking code to fetch the data and the table view code to display it. Your task is to compl...
codefeedback
You are tasked with implementing a shell script that processes files in a given directory. The script should skip any directories and only concatenate the contents of all the files within the directory. The concatenation should be performed in lexicographical order of the file names. If the file is empty, it should be ...
codefeedback
You are tasked with creating a Python program that simulates a simple document processing system. The system will process different sections of a document, such as front matter, main matter, appendix, and back matter. Each section will have its own directive and format. Your task is to implement the necessary functions...
codefeedback
You are tasked with implementing a Python class method that processes a model dictionary and populates certain attributes based on the data within the dictionary. The method should extract specific values from the model dictionary and use them to populate the `model_output` attribute and initialize the `inner_param` at...
codefeedback
You are tasked with implementing a custom debugging tool that can interpret and execute commands based on a given code snippet. The tool should be able to navigate through a stack trace, retrieve specific information, and execute commands to manipulate the debugging process. The debugging tool should support the follo...
codefeedback
You are tasked with creating a program that analyzes a given text file to determine the frequency of each word in the file. Your program should ignore punctuation, capitalization, and any common stop words (e.g., "the", "and", "is") while counting the occurrences of each word. The program should then output the top N m...
codefeedback
You are tasked with implementing a Java class that manages exclusive audited commands. An exclusive audited command is a type of command that requires special handling and auditing. Your task is to create a Java class that extends a base class and sets the exclusive audited type for the command. You are provided with ...
codefeedback
You are given a program that contains a while loop. However, the opening brace for the while loop is missing. Your task is to write a function that takes the code snippet as input and returns the missing opening brace for the while loop. You need to implement the function `findMissingBrace` that takes a string `code` ...
codefeedback
You are tasked with creating a Python package management system that can analyze the dependencies specified in a setup.py file and provide a summary of the required packages. The setup.py file contains information about the Python version required, installation dependencies, test dependencies, and development status cl...
codefeedback
You are tasked with implementing a conditional hiding mechanism for a settings class in a Unity game development environment. The provided code snippet is a simplified representation of the settings class structure. The `NoiseSettings` class contains an enumeration `FilterType` with two options: `Simple` and `Rigid`. D...
codefeedback
You are tasked with implementing a class that represents a photo editing tool. The class should have a method to apply a mask to the photo. The mask is represented by a 2D array of integers, where each integer represents the intensity of the mask at that position. The photo is also represented by a 2D array of integers...
codefeedback
You are tasked with creating a web application that displays user details and allows for user data modification. The application uses PHP with the Yii framework for backend development and HTML for frontend rendering. The given code snippet is a part of the application's view file and is responsible for displaying the ...
codefeedback
You are working on a project that involves evaluating the performance of a machine learning model using a specific evaluation library. The library provides a function `nusc_eval.main()` that takes two optional boolean parameters: `render_curves` and `plot_examples`. The `render_curves` parameter, when set to `True`, en...
codefeedback
You are working on a project to analyze and visualize electromagnetic responses in a material. As part of this project, you need to develop a Python program to calculate and plot the magnetic dipole-dipole response and the electric dipole-dipole response for a given material. The magnetic dipole-dipole response is giv...
codefeedback
You are tasked with creating a Python function that simulates a proxy rotation mechanism for making requests to a web API. The function should rotate through a list of proxies and attempt to send a PUT request to a specified API endpoint using the chosen proxy. If the request encounters an exception, the function shoul...
codefeedback
You are tasked with implementing a URI parser interface in a programming language of your choice. The interface, `Parser`, contains a method `parseURI` that takes a string representing a URI and returns an object with parsed URI parts. The parsed URI parts should include the scheme, host, port, path, query parameters, ...
codefeedback
You are tasked with implementing a function that translates a given hostname into a region name by finding the first part of the domain name that matches a known region. The function should take a string representing the hostname and return an optional string representing the region name. You are provided with a code ...
codefeedback
You are tasked with creating a Python program that interacts with a Bluetooth Low Energy (BLE) device to retrieve and display the characteristics of a specific service. The program should utilize the `bleak` library, which provides a Python interface for interacting with BLE devices. Your task is to implement a functi...
codefeedback
You are tasked with creating a Python program to monitor a temperature sensor and display the temperature readings on a character LCD screen. The program should also log the temperature readings to a file for future analysis. You have been provided with a code snippet that initializes the necessary components for the p...
codefeedback
You are tasked with creating a Python programming problem related to training a neural network using TensorFlow. The problem will focus on implementing a custom training loop for a simple neural network model. Your task is to create a function that takes in training data and labels, and uses TensorFlow to train a neu...
codefeedback
You are given a Python code snippet that is intended to print a pattern of numbers and spaces. However, the code contains a logical error, and your task is to identify the error and fix it to produce the correct pattern. The original code snippet is as follows: ```python if j % 2 != 0: print(j, end=' ') else: ...
codefeedback
You are tasked with creating a Python function that simulates a database migration process. In database migrations, fields can be added, removed, or modified in a database schema. Your function should take a list of migration operations and apply them to a given database schema. You are given a code snippet representi...
codefeedback
You are tasked with implementing a breadth-first search algorithm to solve a maze traversal problem. The given code snippet is a part of a Python class that aims to solve the maze traversal using the breadth-first search algorithm. The `solve` method is responsible for finding the shortest path through the maze. The `...
codefeedback
You are tasked with implementing a function to parse and extract data from a JSON-like structure. The structure is represented as a series of nested key-value pairs, where the keys are strings and the values can be strings, arrays, or nested key-value pairs. Your task is to implement a method to extract a specific valu...
codefeedback
You are tasked with implementing a Python function that calculates the area of a closed polygon defined by a set of vertices. The vertices are represented as a list of (x, y) coordinate pairs in counter-clockwise order. The function should use the shoelace formula to compute the area of the polygon. The shoelace formu...
codefeedback
You are tasked with implementing a simple cryptographic hash function called the Miyaguchi-Preneel (Miyaguchi-Preneel Compression Function) in Rust. The Miyaguchi-Preneel hash function is based on the Miyaguchi-Preneel construction, which is a method for constructing cryptographic hash functions from block ciphers. In ...
codefeedback
You are working on a data analysis project and need to implement a piecewise linear function (PWL) and a statistical hypothesis test. Your task is to create a Python function that takes in specific input data and parameters to construct the PWL function and perform a statistical test. You are given the following infor...
codefeedback
You are tasked with implementing a Python function that processes a list of dictionaries representing students' information. Each dictionary contains the keys "name", "age", and "grade". Your function should filter out students who are below a certain age and have a grade lower than a specified threshold. Additionally,...
codefeedback
You are given a list of space-separated integers. Your task is to find the maximum sum of consecutive integers after replacing all spaces with hyphens in each input integer. Write a function `max_consecutive_sum` that takes a list of integers as input and returns the maximum sum of consecutive integers after replacing...
codefeedback
You are tasked with creating a Python class that simulates a simple web application user authentication system. The class should include methods for user registration, login, logout, and checking the authentication status. Additionally, you need to implement a method for handling redirects after login. Your task is to...
codefeedback
You are tasked with creating a Python program that simulates a simple terminal-based game. The game involves navigating a character through a grid-based world, collecting stars, and avoiding obstacles. The game's output is tied to the terminal size, and the provided code snippet sets the terminal size to 25 lines and 2...
codefeedback
You are tasked with implementing a message class that can convert messages to and from a dictionary format. The message class has a payload, a UUID, and metadata. Your goal is to write a method to convert the message to a dictionary and another method to create a message from a dictionary. Additionally, you need to ens...
codefeedback
You are tasked with designing a version control system for a document management application. The system should be able to handle document changes and provide a way to retrieve the changes made to a document. You are given a code snippet that is part of the backend logic for retrieving document changes. The code snipp...
codefeedback
You are tasked with implementing a simple command-line DNS (Domain Name System) utility in Bash. The utility should support two main commands: "set" and "usage_dns". The "set" command should allow the user to set DNS configurations, while the "usage_dns" command should display usage information for the DNS utility. Yo...
codefeedback
You are tasked with implementing a simple HTTP server that serves a specific type of content. The server should be able to handle incoming requests and respond with the appropriate content type and data. Your task is to create a Python class that represents this server and implement the necessary methods to achieve the...
codefeedback
You are tasked with creating a Python script that dynamically sets the execution mode and messenger configuration based on the provided environment variables. The script should be able to handle both CPU and GPU execution modes and configure the messenger host and port accordingly. Your task is to complete the Python ...
codefeedback
You are given a code snippet that prints the multiplication table for numbers from 1 to 9. Your task is to write a Python function that takes an integer `n` as input and returns the multiplication table for the numbers from 1 to `n`. The function should return a list of lists, where each inner list represents a row in ...
codefeedback
You are tasked with creating a Python programming problem that involves testing a class using parameterized testing with pytest. The problem will require students to understand how to use pytest.mark.parametrize to test different scenarios for a given class. Write a Python class called `Rectangle` that has the followi...
codefeedback
You are tasked with implementing a function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take two integers, `start` and `end`, as input and return the sum of all prime numb...
codefeedback
You are tasked with creating a word-guessing game using Python and Flask. The game will involve guessing a word within a limited number of attempts. The game will be implemented using the Flask web framework, and the user interface will be rendered using an HTML file named "wordleui.html". The game state will be stored...
codefeedback