instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a Python function to calculate the variance bound for a reinforcement learning estimator. The function should take in several parameters and return the variance bound value. The variance bound calculation involves using constants derived from Gaussian smoothing and Pirotta coefficients...
codefeedback
You are tasked with implementing a function to calculate the number of facets in a 3D mesh. A facet is a flat surface that forms part of the boundary of a solid object. The mesh is represented as a collection of vertices and a collection of facets, where each facet is defined by a set of vertices. You are given the fo...
codefeedback
You are tasked with implementing a Python function to calculate the number of samples with missing data in a Variant Call Format (VCF) file. The VCF file contains genetic variation data and is structured with columns representing different attributes. The missing data is denoted by './.' in the file. Your function shou...
codefeedback
You are tasked with creating a custom configuration for a Book entity in a library management system. The Book entity has various properties such as Title, Author, ISBN, and PublishedDate. Your task is to implement the BookConfiguration class, which should define the database schema and constraints for the Book entity ...
codefeedback
You are tasked with creating a function that calculates the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1...
codefeedback
You are tasked with creating a Python function that simulates a simplified version of a blockchain-based cryptocurrency mining process. In this simplified model, miners attempt to generate a new block by solving a computational puzzle. The function should take a difficulty level as input and return the number of attemp...
codefeedback
You are tasked with implementing a data structure to efficiently manage a hierarchical relationship between nodes. Specifically, you need to create a class that represents a tree structure and provides methods for traversing and manipulating the tree. Your task is to implement the `Tree` class with the following speci...
codefeedback
You are tasked with implementing a simple word frequency counter in Rust. You need to create a function that takes a string as input and returns a HashMap containing the frequency of each word in the input string. For this problem, a word is defined as any sequence of non-whitespace characters. Your task is to impleme...
codefeedback
You are tasked with creating a program that generates antonyms for a given word. An antonym is a word that has the opposite meaning of another word. Your program should take a word as input and then provide its antonym. To achieve this, you will use a pre-defined list of antonyms for various words. If the input word is...
codefeedback
You are tasked with implementing a middleware system for a web framework. The middleware system should allow for the sequential execution of multiple middleware functions before and after the main request handler. Each middleware function can modify the request and response objects, and can either terminate the request...
codefeedback
You are tasked with creating a program that generates and validates random data based on a JSON schema. Your task is to implement a function that takes a JSON schema as input, generates random data based on the schema, and then logs the generated data to the console. You are provided with a code snippet that demonstra...
codefeedback
You are tasked with implementing a Python function that processes a list of strings representing code comments and extracts the license information from the comments. The license information is typically found at the beginning of the file and follows a specific format. The function should return the license text if fou...
codefeedback
You are tasked with implementing a class hierarchy for a network server application. The provided code snippet outlines the interface for a `ListenStrategy` class and its derived class `SelectListenStrategy`. Your goal is to create the necessary classes and methods to manage the listening behavior of a network server u...
codefeedback
You are tasked with implementing a simple graphics library for a new programming language. The library should support popups and widgets for creating graphical user interfaces. The library should have the ability to manage and display popups and widgets on the screen. Your task is to design a class structure for the g...
codefeedback
You are tasked with implementing a simplified version of a hash map data structure in Java. Your task is to complete the implementation of the `SimpleHashMap` class by adding the `get` and `put` methods. The `SimpleHashMap` class should use separate chaining to handle collisions. The `SimpleHashMap` class has the fol...
codefeedback
You are tasked with implementing a Python function that processes a list of viewsets and returns the name of the viewset with the most child classes. A viewset is a class in Python that provides the logic for a set of related views. The number of child classes for a viewset is determined by the number of classes that i...
codefeedback
You are tasked with creating a Python script that reads a configuration file and extracts environment variable assignments from it. The configuration file follows a specific format where each line contains a variable assignment in the form of `VARIABLE_NAME=value`. Your script should extract these assignments and print...
codefeedback
You are tasked with implementing a program to simulate a simple queue management system for a bank. The bank has multiple tellers, and customers arrive at random intervals to be served by the tellers. Each customer has a specific service time, and the tellers serve customers in a first-come, first-served manner. Your t...
codefeedback
You are tasked with implementing a file upload manager that interacts with a remote server. The provided code snippet is a part of this manager and contains a function for uploading a file to the server. Your task is to complete the implementation of the `_upload_blob` function and handle potential errors. The `_uploa...
codefeedback
You are tasked with implementing a dense matrix module in Rust. The module should provide functionality for creating, manipulating, and performing operations on dense matrices. A dense matrix is a two-dimensional array in which most of the elements are non-zero. Your task is to implement the basic operations for dense ...
codefeedback
You are tasked with creating a custom hook in a React application that manages the state of a user's nickname. The hook should be responsible for fetching and updating the user's nickname. Your goal is to implement the `useNickname` custom hook, which will be used within the `MessengerProvider` component. Your task is...
codefeedback
You are tasked with creating a Python class that simulates a simple file management system. Your task is to implement a class called `FileManager` with the following functionalities: 1. `__init__(self, base_directory: str)`: A constructor that initializes the `base_directory` attribute with the provided `base_director...
codefeedback
You are tasked with implementing a function that calculates the number of non-zero elements along a specified axis of a given numpy array. Additionally, the function should handle cases where the input array contains NaN (Not a Number) values and where the degrees of freedom (ddof) parameter exceeds the number of non-N...
codefeedback
You are tasked with implementing a function that calculates the total duration in months given a list of durations in different units. The durations can be in the format of years, months, or days. Your task is to write a function `calculateTotalMonths` that takes a list of durations and returns the total duration in mo...
codefeedback
You are tasked with implementing a metadata parser that extracts key-value pairs from a given metadata string. The metadata string is a series of key-value pairs separated by commas, where each key and value are separated by an equal sign. However, the metadata string may contain nested key-value pairs enclosed within ...
codefeedback
You are tasked with implementing a PHP interface for handling route arguments in a web application framework. The interface, `ArgumentHandlerInterface`, defines a method for attaching route arguments to a `ServerRequestInterface` object. Your goal is to create a concrete class that implements this interface and provide...
codefeedback
You are working on a project that involves processing output tensors from a machine learning model. The code snippet provided is part of a larger system that handles these tensors. The `model_output_tensors_` is a vector containing pointers to the model's output tensors, and `output_tensors_` is a vector of tensors tha...
codefeedback
You are tasked with creating a Python function that processes a list of module imports and returns a dictionary containing the imported modules and their corresponding import statements. The function should handle both direct and relative imports and should ignore any exceptions raised during the import process. The f...
codefeedback
You are tasked with implementing a class that represents a visualizer for graphs. The class has a method `graph` which returns the graph associated with the visualizer, and a setter for `graph` which validates and sets the graph. The `_validate_graph` method is used internally to ensure that the graph is suitable for t...
codefeedback
You are tasked with implementing a simulation of a Roomba vacuum cleaner's movement in a room. The room is represented as a grid, and the Roomba moves according to a set of instructions. The grid is represented by a 2D array, where each cell can be either clean (0) or dirty (1). The Roomba's initial position and the in...
codefeedback
You are tasked with creating a TypeScript decorator that modifies the behavior of a class method. Decorators are a powerful feature in TypeScript that can be used to modify the behavior of classes and their members at design time. Your task is to implement a decorator called `logExecutionTime` that logs the execution ...
codefeedback
You are tasked with creating a Python class that represents a user profile in a social media platform. The class should have attributes to store the user's verification level, NSFW (Not Safe For Work) content preference, and a method to update the verification level. Your task is to implement the `UserProfile` class w...
codefeedback
You are tasked with implementing a feature flag system for a software application. Feature flags are used to control the enablement of certain features within the application. The code snippet provided contains declarations related to feature flags in a C++ codebase. Your task is to create a class that manages feature...
codefeedback
You are tasked with implementing a custom command system for a Discord bot using Python. The `setup` function is used to initialize and set up the bot with a custom command module. The `add_cog` method is used to add a new custom command module to the bot. Your task is to create a class `CustomCommands` that will handl...
codefeedback
You are tasked with implementing a function that converts a string representation of a positive integer to an integer value. The function should take a string as input and return the corresponding integer value. You need to handle the conversion without using any built-in conversion functions or libraries. Write a fun...
codefeedback
You are tasked with implementing a function to perform color mapping on an image. The function takes an input image represented as a 3D array, where the first dimension represents the y-coordinate, the second dimension represents the x-coordinate, and the third dimension represents the color channels (in the order of b...
codefeedback
You are tasked with implementing a visitor pattern in C++ for a specific use case. The visitor pattern allows for adding new operations to existing classes without modifying those classes. In this scenario, you will be working with the classes `BM188X` and `AveragePool`, as well as the `ComputeVisitor` and `BM188xVisit...
codefeedback
You are tasked with creating a Python program that simulates the behavior of a Katamari Damacy game. In this game, the player controls a sticky ball called "katamari" that rolls around a play area, picking up objects and increasing in size as it collects more items. Your program should implement the functionality of th...
codefeedback
You are tasked with implementing a custom layout for a collection view in a medical records app. The code snippet provided is a part of the view controller responsible for managing the collection view's layout and appearance. The `viewDidLoad` method sets up the layout for the collection view, while the `viewWillAppear...
codefeedback
You are tasked with implementing a state management system for adding new employees in a company's HR application. The provided code snippet outlines a Swift class `AddNewEmployeeState` that manages the state changes during the process of adding a new employee. The state changes are represented by the `Change` enum, wh...
codefeedback
You are tasked with implementing a function to extract and validate a JSON Web Token (JWT) from an HTTP request header. The function should take the request object and header key as input and return the decoded JWT payload if it is valid. If the header is missing, has an incorrect format, or the token is invalid, the f...
codefeedback
You are tasked with implementing a custom pause functionality for a game. The game has ongoing tasks, timers, and graphics rendering callbacks that need to be paused when the game is paused. Your task is to create a class that manages the pausing and resuming of these tasks. You are provided with a skeleton code for t...
codefeedback
You are tasked with creating a Python function that compares two Spark DataFrames and returns a summary of their differences. The function should take two Spark DataFrames as input and output a summary of discrepancies between the two DataFrames. The function signature should be: ```python def compare_spark_dataframes...
codefeedback
You are tasked with creating a program that processes a software license agreement to extract specific terms and conditions. The license agreement is provided as a string containing multiple lines of text. Each line may contain various types of information, including copyright notices, permissions, conditions, and disc...
codefeedback
You are given a sequence of operations performed on a set of colored balls. Each ball is represented by a pair of integers (x, c), where x is the position of the ball and c is its color. The operations involve adding new balls to the sequence and querying the number of distinct colors present in a specified range of po...
codefeedback
You are tasked with creating a Python class that simulates a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should implement a custom logging handler to log all account transactions using the `structlog` library. You...
codefeedback
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The program should allow a user to input their choice (rock, paper, or scissors), generate a random choice for the computer, determine the winner based on the choices, and display the result. Your program should follow these ru...
codefeedback
You are tasked with implementing a data processing algorithm for reading and processing orders and line items from two separate files. The code snippet provided is a part of a larger system that reads data from these files and generates SQL insert queries for a database. Your task is to complete the implementation of t...
codefeedback
You are tasked with implementing a graph convolutional network (GCN) using the Deep Graph Library (DGL) in Python. The provided code snippet is a part of a GCN implementation using DGL and PyTorch. Your task is to complete the implementation of the GCN_DGL class by defining the missing parts of the forward method. You...
codefeedback
You are tasked with creating a Python package for controlling smart bulbs. The package should be able to connect to a hub and control individual bulbs connected to it. Your task is to implement the necessary classes and methods to achieve this functionality. You are provided with a code snippet that imports the `Hub` ...
codefeedback
You are tasked with creating a validation function for user input in a registration form. The function should validate the length of the first name, last name, and username based on the given constraints. The constraints are defined as constants in the code snippet provided. The function should return an error message ...
codefeedback
You are tasked with implementing a class that manages the validity period of certificates. The class should have methods to set the start and end times of the validity period and to check if a given timestamp falls within the validity period. Your task is to implement the `CertificateValidity` class with the following...
codefeedback
You are tasked with creating a Python program that simulates a simple autograding system for student assignments. The program should be able to handle multiple assignments, each with its own set of test cases and grading criteria. Your task is to implement a class `Assignment` that represents a single assignment. The ...
codefeedback
You are tasked with implementing a network port abstraction in C++. The given code snippet shows a part of the interface for the network port abstraction. The `NetworkPort` class has several virtual member functions that need to be implemented in a derived class. The member functions `id()`, `kind()`, `link()`, `speed(...
codefeedback
You are given a C++ program that contains a preprocessor directive `#define private public`. Your task is to analyze the impact of this directive on the program's behavior and identify potential issues that may arise due to this modification. Your analysis should include the following aspects: 1. Explain the significa...
codefeedback
You are tasked with implementing a caching mechanism for a class that stores attributes. The class has a method that takes a list of attributes, concatenates their string representations, and uses the resulting string as a key to retrieve a value from a dictionary. Your task is to complete the implementation of the `ge...
codefeedback
You are tasked with creating a program that processes and manipulates images. Your goal is to implement a function that takes an input image and applies a series of transformations to it. The input image is represented as a 2D array of pixels, where each pixel is a tuple of RGB values. The transformations to be applied...
codefeedback
You are tasked with creating a command-line interface (CLI) parser for a software tool. The CLI parser should be able to handle various command-line parameters and set corresponding environment variables based on the provided options. Your task is to implement a Python function `parse_params()` that parses the command-...
codefeedback
You are tasked with implementing a function that checks for the presence of a specific label in a given array of issue labels. Each issue label is represented by a struct `IssueLabelDetail`. The function should return `true` if the label is found in the array, and `false` otherwise. The function should handle potential...
codefeedback
You are tasked with implementing a generic validation system in C#. The system should allow for validating objects of different types using a set of validation rules. The `ValidationResult` class represents the result of a validation operation, and the `ValidationResults` property is a list of these results. Your task...
codefeedback
You are tasked with implementing a TypeScript function that validates the props object for a React component. The props object contains various optional and required properties, each with specific data types and constraints. Your goal is to create a function that checks whether the provided props object adheres to the ...
codefeedback
You are tasked with implementing a class that supports variant types in C++. A variant type is a data type that can hold values of different types, but only one value at a time. Your task is to implement the `VariantSupport` class with the following requirements: 1. The class should have a constructor that takes a `de...
codefeedback
You are tasked with creating a program that extracts specific information from a collection of assembly attributes. The assembly attributes are in the format of key-value pairs, and you need to extract the values associated with certain keys. Write a function or method `extractAssemblyInfo` that takes in a list of st...
codefeedback
You are tasked with creating a Python function to parse and process football league data. The function should take in a league name and a year as input and return the team standings for that league and year. The provided code snippet is part of a larger program that processes football statistics and fixtures. Your tas...
codefeedback
You are tasked with implementing a function that processes and manipulates data related to 3D graphics. The function is responsible for updating the position of a vertex buffer based on certain conditions and constraints. You are given a code snippet that represents part of the function's implementation. The snippet i...
codefeedback
You are tasked with implementing a function that parses a given HTML snippet and extracts all the classes used in the `div` and `ul` elements. The function should return a list of unique class names found in the snippet. You are given the following HTML snippet as an example: ```html <ul class="list"> <li>Item 1</...
codefeedback
You are tasked with creating a Python class for peptide sampling. A peptide is a short chain of amino acids, and in this context, sampling refers to generating a three-dimensional structure for the peptide. The provided code snippet includes fixtures for loading default major histocompatibility complex (MHC) and peptid...
codefeedback
You are tasked with implementing a function to fill a mesh with a specific pattern. The mesh is represented as a prism mesh with dimensions defined by the tuple (0, 100, 0, 200, 0, 50). The fill function takes an integer parameter i and should fill the mesh according to the following rules: - If i is divisible by 2 an...
codefeedback
You are tasked with implementing a class that can parse an HTTP response and extract relevant information from it. The class should have a method that takes an `HttpResponseMessage` and a `string` representing the HTTP response body, and returns a tuple containing an instance of `CentralConfigReader` and `CentralConfig...
codefeedback
You are tasked with optimizing a C++ program by replacing a slow function with a more efficient assembly implementation. The given C++ program contains a function `slowFunction` that calculates the sum of all elements in an array. Your goal is to create an optimized assembly implementation of this function and integrat...
codefeedback
You are tasked with implementing a task scheduler for a mobile application. The application has four lifecycle methods: `applicationDidEnterBackground`, `applicationWillEnterForeground`, `applicationDidBecomeActive`, and `applicationWillTerminate`. Your task is to design a scheduler that can execute tasks based on the ...
codefeedback
You are tasked with creating a Swift function that retrieves weather data from the OpenWeatherMap API using an API key stored in a property list file. Your function should take a city name as input, read the API key from the property list file, and then make an HTTP request to fetch the weather data for the specified c...
codefeedback
You are working on a Python application that interfaces with a database using SQLAlchemy. The code snippet provided is a part of a larger application that manages relationships between different entities. In this case, the `application_reason_codes` variable is defined as a relationship to the `ApplicationReasonXref` e...
codefeedback
You are tasked with implementing a custom neural network layer using PyTorch. The layer will consist of a series of modules, such as convolutional layers, batch normalization, and activation functions. Your goal is to create a Python class that can dynamically construct this custom layer based on a given configuration....
codefeedback
You are tasked with creating a program that interacts with the operating system to execute a command and capture its output. Your program should take a command as input, execute it, and then return the standard output of the command. You should implement this program in Rust using the `std::process::Command` module. Y...
codefeedback
You are tasked with implementing a language detection system that can identify the language of a given text. To achieve this, you need to create a Swift program that utilizes the `LanguageError` enum to handle potential errors during the language detection process. Your program should consist of the following componen...
codefeedback
You are tasked with implementing a plugin for a game server using Python and the minqlx library. The plugin, named "onjoin", is designed to automatically display a set message when a player who has set their onjoin message connects to the game server. The plugin utilizes a key-value store to store the onjoin messages f...
codefeedback
You are tasked with implementing a custom data structure in Rust that simulates a simple version of a tuple. The tuple will consist of two elements, each of which is a custom structure. Your task is to ensure that the tuple's elements are properly initialized and that any attempts to partially reinitialize an uninitial...
codefeedback
You are tasked with implementing a simple UART (Universal Asynchronous Receiver/Transmitter) controller in Rust. The provided code snippet is a part of the initialization process for the UART controller. The controller has several registers that can be accessed and configured to control its behavior. The code snippet s...
codefeedback
You are tasked with implementing a Singleton design pattern in Python using a metaclass. The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. Your goal is to create a metaclass that will enforce the Singleton pattern for any class it is applied to. Yo...
codefeedback
You are tasked with implementing a soft delete functionality for a cohort management system. The system currently supports the deletion of cohorts, but it needs to be enhanced to support soft deletion, where the cohorts are not permanently removed from the system but are marked as deleted. You need to implement the `de...
codefeedback
You are tasked with implementing a web page parser that can extract specific information from a webpage. The parser needs to handle both single and multiple queries and return the results accordingly. You are given a Python code snippet that includes a class `PageParser` and a dictionary `TEST_DATA` containing test ca...
codefeedback
You are tasked with implementing a function to delete a group by its ID in a Node.js/Express application. The provided code snippet is a part of an Express route handler function that handles the deletion of a group. The `deleteGroupById` function is an asynchronous function that takes in the request (`req`), response ...
codefeedback
You are tasked with creating a simple maze generation program using the Bash scripting language. The program should take two command-line arguments: `--seed` and `--height`. The `--seed` argument is used to specify the seed for the random number generator, and the `--height` argument is used to specify the height of th...
codefeedback
You are working on a project that involves numerically differentiating a given function with respect to its argument. You need to implement a function `grad_num(fn, arg, step_size=1e-7)` that takes in a function `fn` and its argument `arg`, and numerically differentiates `fn` with respect to `arg` using the specified `...
codefeedback
You are tasked with creating a method to parse and analyze a given C# code snippet. The code snippet contains a method for obtaining a specific type of window in the Unity game development environment. Your goal is to extract relevant information from the code and perform specific operations based on the extracted data...
codefeedback
You are tasked with creating a Python function that generates a plot with multiple lines using the Bokeh library. The function should take in an array of x-values and a list of y-values for each line to be plotted. The plot should have specific tools enabled, axis labels, and legends for each line. Write a function `g...
codefeedback
You are tasked with creating a Python class that models a simple database table using SQLAlchemy. Your class should represent a table called "User" with the following columns: 1. id: UUID primary key 2. username: String 3. email: String 4. created_at: DateTime Your class should also include the following requirements:...
codefeedback
You are tasked with creating a Rust program to control a Crazyradio device, which is used for wireless communication. The Crazyradio library provides functionalities to interact with the device, such as opening a connection, setting the channel, and configuring the data rate. Your goal is to implement a Rust program th...
codefeedback
You are tasked with implementing a class to manage registry hives in a Windows application. The class should provide functionality to get and set the registry hive values, as well as a method to determine if a given registry hive value is valid. You are given the following code snippet as a reference for the registry ...
codefeedback
You are given a scenario where a software system is being used to solve a mathematical problem related to positive definite matrices and vector operations. The code snippet provided is a part of a larger program that is solving a system of linear equations involving positive definite matrices. The specific task involve...
codefeedback
You are tasked with creating a script to automate the installation of a specific version of dotnet-script. The script should check if the dotnet-script directory exists, and if not, it should download the specified version from GitHub and unzip it into the designated build directory. Your task is to write a Bash scrip...
codefeedback
You are tasked with implementing a function that takes a list of numbers as input and returns the sum of the squares of all the even numbers in the list. You should use Python and the numpy library to accomplish this task. Your function should be named `sum_of_squares_of_even_numbers` and should accept a single parame...
codefeedback
You are tasked with creating a script that processes a list of files and directories and performs specific operations based on their types. Your script should handle files, directories, and symbolic links differently, and it should be able to handle nested directories as well. You are given a code snippet of a Bash s...
codefeedback
You are tasked with implementing a run-length encoding (RLE) decoder function. Run-length encoding is a simple form of data compression where consecutive identical elements are replaced with a single element and the count of repetitions. For this problem, you will be given a run-length encoded string and the shape of t...
codefeedback
You are given a binary tree where each node has an integer value. A node is considered "lonely" if it has no siblings (i.e., it is the only child of its parent). You are required to implement a function to find and return all the lonely nodes in the given binary tree. The function signature is: ```python def find_lone...
codefeedback
You are tasked with implementing a custom data structure to manage a collection of movies. Each movie has a unique identifier (`id`), a title, a release year, and a flag indicating whether it is a favorite. Additionally, the structure should support the following operations: 1. Adding a movie to the collection. 2. Remo...
codefeedback
You are tasked with implementing a multiplexing algorithm for a communication protocol. The multiplexing algorithm is responsible for efficiently combining multiple data streams into a single stream for transmission over a network. In this problem, you will be working with a Rust code snippet that initializes a multipl...
codefeedback
You are tasked with creating a Python function that processes and writes statistical data to a log file. The function should take in various statistical metrics and write them to a specified log file in a specific format. Write a Python function `write_stats_to_log` that takes in the following parameters: - `graph_pat...
codefeedback
You are working as a DevOps engineer for a company that uses Elasticsearch for its data storage and retrieval needs. As part of your responsibilities, you need to manage the security of the Elasticsearch cluster by setting up SSL/TLS encryption for communication between nodes and clients. To achieve this, you decide to...
codefeedback