instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a method to calculate the pixel weights of a given geometry. The pixel weights are defined as the proportion of the input geometry that falls within each pixel of a grid. The grid represents the total area of the input geometry, and the weights are relative to this total area. You are ...
codefeedback
You are tasked with implementing a browser history navigation system. The given code snippet provides a basic structure for managing the navigation functionality. The `GoBack` and `GoForward` methods are responsible for navigating backward and forward in the browser history, respectively. The `CanGoBack` and `CanGoForw...
codefeedback
You are given a matrix of integers representing a two-dimensional array. Your task is to write a function to calculate the average of each row and each column in the matrix and then determine if there exists a row whose average is greater than the average of any column. If such a row exists, return its index; otherwise...
codefeedback
You are tasked with implementing a class that creates instances of metro windows with customizable parameters. The class should have a method to create a new metro window instance with the given parameters. The parameters include options to control the window's appearance and behavior, such as whether it should be show...
codefeedback
You are tasked with implementing a function to delete a bookmark for a server using a given API endpoint. The function should handle the case where the server is not bookmarked and should return a boolean value indicating whether the bookmark has been successfully deleted. You are provided with a code snippet that con...
codefeedback
You are tasked with creating a Python class that represents a leaderboard for a gaming application. The class should allow for the addition of player scores and provide functionality to retrieve the top N players based on their scores. Create a Python class called `Leaderboard` with the following requirements: - The c...
codefeedback
You are tasked with implementing a program to evaluate the performance of a text summarization algorithm using the ROUGE (Recall-Oriented Understudy for Gisting Evaluation) metric. ROUGE is commonly used to determine the quality of automatic summaries by comparing them to reference summaries. The given code snippet is ...
codefeedback
You are given a class `TreeNode` representing a node in an n-ary tree. The class has an `__init__` method that takes in a value `val` and a list of children nodes `children`. Your task is to implement a method `max_depth` for the `TreeNode` class, which calculates the maximum depth of the n-ary tree. The maximum depth...
codefeedback
You are tasked with implementing a simplified job scheduler in Rust. The job scheduler should support adding jobs, executing them in a specific order, and handling job cancellation. You are provided with a partial implementation of the `JobScheduler` struct and its associated methods. The `JobScheduler` struct has the...
codefeedback
You are tasked with creating a program that generates a calendar for a specific month and year. Your program should take input for the month and year, and then output the calendar for that month in a specific format. Write a Python function `generate_monthly_calendar(month, year)` that takes two integer parameters: `m...
codefeedback
You are tasked with implementing a geofence management system. Geofences are virtual perimeters for real-world geographic areas. Your task is to create a class that manages a collection of geofences and provides methods for adding, removing, and updating geofences. You are given a partial code snippet for the `Geofenc...
codefeedback
You are tasked with creating a script to automate the setup of a CouchDB cluster. The script should be able to handle both single-node and multi-node clusters. For a single-node cluster, the script should create the necessary system databases directly. For a multi-node cluster, the script should initiate the cluster se...
codefeedback
You are tasked with implementing a function `upgrade()` that takes an array of integers as input and returns a new array where each element is the sum of itself and all previous elements in the input array. For example, given the input array `[1, 2, 3, 4]`, the output array should be `[1, 3, 6, 10]` because the first e...
codefeedback
You are tasked with implementing a simplified task execution system. The system consists of a task queue, a result queue, and a worker that processes tasks. The worker executes tasks using different executors, such as TERRAFORM, and then places the results in the result queue. Your goal is to implement the `execute_tas...
codefeedback
You are tasked with creating a function that simulates a simplified version of a real-time event polling system for a chat application. The function will receive a user object, an explicit room ID, and a pagination configuration. The pagination configuration includes a "from_token" and a "limit" for the number of event...
codefeedback
You are given a code snippet that involves the manipulation of a variable `place_holder` based on certain conditions. Your task is to understand the logic behind the code and implement a function that replicates the behavior of the code snippet. You need to write a function `calculate_placeholder` that takes the follo...
codefeedback
You are tasked with implementing a function that calculates the area of a 2D polygon given its vertices. The vertices are represented as a list of 2D points in the form (x, y). The function should return the area of the polygon as a floating-point number. The vertices are listed in clockwise or counterclockwise order, ...
codefeedback
You are given a circular track with N segments, numbered from 0 to N-1. Each segment has a specific length associated with it. Additionally, there is a starting point S on the track, and a cyclist who starts at segment 0. The cyclist moves along the track in a circular manner, adding the length of the current segment t...
codefeedback
You are working on a data processing project that involves reading and manipulating JSON files. Your task is to create a Python function that reads a directory containing multiple JSON files, processes the data from each file, and returns a summary of the processed data. You are provided with the following code snippe...
codefeedback
You are working on a quantum computing simulation project and need to implement a function to calculate the combined effect of two quantum gates: Rz and Ry. The Rz and Ry gates are represented by matrix exponentials and are used to manipulate the state of a quantum system. The function takes three parameters: detuning,...
codefeedback
You are tasked with creating a Python function that processes a list of strings representing commands and their arguments. The function should execute the commands and return the final state of a system based on the commands executed. You are given a list of strings, where each string represents a command in the follo...
codefeedback
You are tasked with implementing a data transformation pipeline in Python for integrating two datasets related to materials science. The code snippet provided is a part of the pipeline setup and involves the initialization of a data integration class. Your task is to complete the implementation of the data integration ...
codefeedback
You are tasked with creating a Python script that processes a list of tasks using Celery, a distributed task queue. Your script should define a Celery task that takes a list of integers as input, squares each integer, and returns the sum of the squared values. Additionally, the script should configure Celery to use Red...
codefeedback
You are tasked with creating a function that processes a list of integers and returns the maximum product that can be obtained by multiplying any three integers from the list. If the list contains less than three integers, the function should return 0. You need to implement the function `maxProductOfThree` that takes ...
codefeedback
You are tasked with implementing a custom widget class in Python that extends the functionality of an existing widget class. The custom widget, named `CustomWidget`, needs to inherit from the `TtkResizeWidget` class and have additional features related to managing a TV (Table View) component. The `CustomWidget` class s...
codefeedback
You are working on a software project that involves creating a parameter management system. The system has a class `Params` with virtual member functions for setting and retrieving parameter values. You need to implement a concrete subclass of `Params` called `ConcreteParams` that provides the functionality for setting...
codefeedback
You are tasked with creating a unit test for a method that updates a "terimaBarang" (received goods) object in a system. The code snippet provided is a part of the unit test for this method. The test uses a repository to update a fake "terimaBarang" object and then asserts that the updated object matches the fake objec...
codefeedback
You are tasked with creating a program that processes a list of student scores and returns the top N students based on their scores. You are given a class `Student` with properties `Name` (string) and `Score` (int). You need to implement a method `GetTopStudents` that takes a list of `Student` objects and an integer N,...
codefeedback
You are tasked with implementing a simplified peer-to-peer (P2P) server class in C++. The provided code snippet contains part of the implementation for the server, including the `connect_to_peer` and `stop_server` methods. Your task is to complete the implementation of the `p2p_server` class by adding the missing metho...
codefeedback
You are working on a project related to astrophysics and need to calculate the wavelengths of spectral lines in the Lyman series. The Lyman series describes the wavelengths of electromagnetic radiation emitted by hydrogen atoms when an electron transitions from a higher energy level to the first energy level (n=1). Yo...
codefeedback
You are tasked with implementing a preprocessing tool for Chinese natural language processing (NLP). The tool should be able to perform several essential preprocessing tasks on Chinese text, including tokenization, part-of-speech (POS) tagging, and named entity recognition (NER). Your task is to create a Python class...
codefeedback
You are tasked with creating a Python program that interacts with a SQLite database to perform various operations. The program should include functions to create a new database, create a table, insert data into the table, retrieve data from the table, and delete the database. Your program should provide a command-line...
codefeedback
You are given a snippet of code that is part of a function. Your task is to complete the function by implementing the missing part. The function takes in an array of integers and should return true if the array is sorted in non-decreasing order, and false otherwise. The given code snippet is as follows: ```java public...
codefeedback
You are tasked with implementing a class that represents a simple bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. Additionally, the class should keep track of the total number of transactions (deposits and withdrawals) made on the account. You need to implem...
codefeedback
You are tasked with implementing a Python decorator that adds a set of features to a function. The code snippet provided is a simplified version of the decorator implementation. The `feature_list` is a list of feature names, and the `function` is the original function to which the features will be added. Your task is ...
codefeedback
You are tasked with creating a program that analyzes HTML code to identify the number of sections and their respective classes. Your program should read the HTML code and output the count of sections and the classes associated with each section. For example, given the following HTML code snippet: ``` <h1>Category Deta...
codefeedback
You are given a Rust function `solve_part2` that takes a reference to a vector of `Move` objects and returns an `isize` value. The `Move` type is not explicitly defined in the code snippet, but it is assumed to be a custom type representing different moves in a game or puzzle. Your task is to implement the `solve_part...
codefeedback
You are tasked with creating a Python class that interacts with a storage system to manage tables, schemas, and data. Your task is to implement the `StorageManager` class with the following methods: 1. `create_table(table_name, schema_file)`: This method should create a new table in the storage system using the provid...
codefeedback
You are tasked with creating a simple login system for GoozOS, a fictional operating system. The system should prompt the user for a username and password, and grant access if the provided credentials match the predefined values. Your task is to complete the Python code snippet provided below to implement the login sys...
codefeedback
You are tasked with designing a role-based access control system for a web application. The application has a controller method that handles the deletion of records, and it is annotated with various security and logging annotations. Your goal is to create a role-based access control system to determine whether a user h...
codefeedback
You are tasked with creating a program to analyze and display the publishing activity of a blog over a given period. The program should take into account the month and year filters provided by the user and generate a report showing the number of published posts for each month within the specified year. Your task is to...
codefeedback
You are tasked with creating a program that reads a series of integers from a file, performs a specific operation on each integer, and then writes the results back to the file. The program should also calculate and output the sum of all the modified integers. You are given a code snippet that opens a file named "file....
codefeedback
You are tasked with creating a Python function that processes a list of video objects and returns a dictionary containing the ownership permission policy for each video. The ownership permission policy is determined based on the video's ownership status and the user's role. The ownership status can be "owned", "shared"...
codefeedback
You are given a Python code snippet that processes a depth image represented as a 2D matrix. The code snippet contains operations to handle duplicate indices, update the depth values, and perform normalization. Your task is to understand the code and implement a function to perform a specific operation on the depth mat...
codefeedback
You are tasked with implementing a Python class that represents a file system path. The class should provide methods for navigating and manipulating the path, similar to the functionality provided by the `os.path` module in Python. Your task is to create a class `FileSystemPath` with the following methods: 1. `__init...
codefeedback
You are working on a programming language interpreter that supports lazy namespace creation and usage. The code snippet provided is a part of the interpreter implementation. The `root` object represents the root namespace, and the `create_lazy_namespace` method is used to create a new lazy namespace within the root nam...
codefeedback
You are tasked with implementing a simulated annealing optimizer for a given optimization problem. Simulated annealing is a probabilistic optimization algorithm that is used to find the global optimum in a large search space. The algorithm starts with an initial solution and iteratively explores the search space by acc...
codefeedback
You are tasked with implementing a custom error type for handling encoding errors in a text processing application. The error type, `EncodingError`, should provide specific error variants for different types of encoding issues. The provided code snippet shows the implementation of the `Display` trait for the `EncodingE...
codefeedback
You are tasked with creating a Rust library for controlling General Purpose Input/Output (GPIO) pins on a microcontroller. The library should provide an interface for interacting with the GPIO pins, allowing users to set pin modes, read and write pin values, and configure interrupts. Your task is to implement the `gpi...
codefeedback
You are tasked with implementing a custom view in Swift that includes a gradient view and a background view container. The gradient view should be a subview of the custom view and should have a gradient layer applied to it. The background view container should also be a subview of the custom view and should have a top ...
codefeedback
You are tasked with implementing a custom string type in Rust that allows for efficient manipulation and conversion of strings with different lifetimes. The custom string type, `Kstr`, is designed to represent a borrowed string slice with a specific lifetime. Additionally, you need to implement a method to convert the ...
codefeedback
You are tasked with implementing a command-line processor for a fictional application. The `CCommandLineProcessor` class needs to be extended to support the processing of command-line parameters. The `Process` method should parse the input parameters and perform the necessary actions based on the provided commands. The...
codefeedback
You are tasked with implementing a function to calculate the gradient magnitude of a given matrix. The gradient magnitude is a measure of the change in intensity or color in an image, and it is commonly used in image processing and computer vision applications. You are provided with a Python code snippet that calls a ...
codefeedback
You are tasked with creating a program that analyzes a given software license text to extract specific information. The license text follows a standard format, with the permissions and conditions specified in a block of text. Your program should extract and display the following information: 1. List of permissions gran...
codefeedback
You are tasked with implementing a custom `Answer` class in Java that represents an answer to a question in a quiz application. The `Answer` class should have the following properties and behaviors: Properties: - `aid` (answer ID): an integer representing the unique identifier for the answer. - `qid` (question ID): an...
codefeedback
You are tasked with implementing a class that simulates a simple queue data structure using a stack. The class should support the following operations: 1. `Enqueue(int value)`: Add an element to the end of the queue. 2. `Dequeue()`: Remove the element at the front of the queue and return its value. 3. `IsEmpty()`: Retu...
codefeedback
You are tasked with implementing a deck-building algorithm for a collectible card game. The algorithm should load settings from a file, perform a search to find the best deck, and then display the best deck along with its probability of winning. Additionally, it should provide an option to dump additional information i...
codefeedback
You are tasked with implementing a JSON schema validator that can resolve and validate JSON references. JSON references are defined using the "$ref" keyword, which allows a JSON object to reference another part of the document. The referenced part is identified by a JSON Pointer, which is a string containing a sequence...
codefeedback
You are tasked with implementing a trait for a custom type in Rust. The trait, `MemoryInputStreamExt`, extends the functionality of the `MemoryInputStream` type, which is a part of the `gio` library in Rust. Your goal is to implement a method for this trait that reads data from the input stream. Your task is to comple...
codefeedback
You are tasked with implementing a simplified version of a class-based object creation system in Python. Your goal is to create a class that can parse a JSON dictionary and instantiate objects based on the data provided in the dictionary. You are given the following code snippet as a starting point: ```python for obj...
codefeedback
You are tasked with creating a program that processes command-line arguments to extract the name of the exported source file. The program should handle both default and explicitly provided output file names. Your program should accept the following command-line arguments: 1. `-o <output_file>`: Specifies the name of t...
codefeedback
You are tasked with writing a function to convert a given positive integer into its binary representation. The function should take an integer `num` as input and return a string representing the binary equivalent of the input number. For example, if the input `num` is 13, the function should return the string '1101', ...
codefeedback
You are tasked with creating a Python class that generates SQL queries for altering table columns with default values. Your class should have a method to generate and execute the SQL query for setting a default value using a sequence. The provided code snippet is part of the class method that executes the generated SQL...
codefeedback
You are tasked with implementing a custom hook in a React application that optimizes the rendering performance by caching the result of a computationally expensive operation. The provided code snippet exports a custom hook called `useCachedNode` from a file named `useCachedNode.js`. Your task is to create the implement...
codefeedback
You are tasked with implementing a function that checks the correctness of the scope of delimiters in a multi-line string. The delimiters to be checked are the dollar sign ($) and the at symbol (@). The function should return True if the delimiters are correctly scoped and False if they are not. The delimiters are cor...
codefeedback
You are tasked with creating a program that simulates a simple inventory management system for a retail store. The system should allow users to add, remove, and update products in the inventory. Additionally, it should be able to display the current inventory and calculate the total value of the inventory based on the ...
codefeedback
You are tasked with implementing a function that will handle directory monitoring and file listing. The function should be able to handle exceptions and raise custom exceptions when necessary. You are given a code snippet that demonstrates part of the functionality required for this task. Your task is to implement the...
codefeedback
You are tasked with creating a Python class that interacts with a web service to fetch and process data. The class should have a method `fetch_moves` that takes two `datetime` objects as input and retrieves information from a web page. The method should handle the login process, make an HTTP request, and extract releva...
codefeedback
You are tasked with creating a custom text view component for a mobile application using React Native. The custom text view should have the ability to display text with a specified font, size, color, and alignment. Additionally, it should support the functionality to handle user interactions such as tapping and long-pr...
codefeedback
You are working on a decentralized finance (DeFi) project called Badger, which involves deploying and setting up logic for various components. One of the tasks involves deploying a logic contract called "CurveTokenWrapper" and setting it as the CurveTokenWrapper for a bridge adapter. The code snippet provided demonstra...
codefeedback
You are tasked with creating a Python decorator that measures the execution time and memory usage of a given function. Your decorator should take the name of the function as an argument and print the time taken for execution and the memory used by the function. You can use the `time` and `resource` modules to accomplis...
codefeedback
You are tasked with creating a Python function that manipulates files and directories using the `pathlib` module. Your function should take in a directory path and a list of filenames, and then create new files within the specified directory. Additionally, the function should create migration files for a database, foll...
codefeedback
You are tasked with implementing a PHP interface for a meeting management system. The interface, named `CampaignAwareInterface`, is intended to be used by classes that need to be associated with a campaign. The interface contains a method signature for retrieving the associated campaign. Your task is to complete the `...
codefeedback
You are tasked with creating a password validation function that checks whether a given password meets certain criteria. The function should take a password as input and return True if the password meets the criteria, and False otherwise. The password criteria are as follows: 1. The password must be at least 8 charact...
codefeedback
You are tasked with implementing a function to calculate the aligned size based on the input size, with a specific alignment requirement. The alignment requirement depends on whether the application is running on a 32-bit system or a 64-bit system. The alignment calculation should consider the architecture and adjust t...
codefeedback
You are tasked with creating a script to automate the process of joining worker nodes to a Kubernetes cluster. The script should generate the necessary join command for the worker nodes to connect to the cluster's master node. The join command should be modified to use a custom command `cks cluster join --master` inste...
codefeedback
You are working on a Python web application project and need to manage its dependencies and entry points. The project structure includes a `setup.py` file, which is used to define the project's metadata and dependencies. The `setup` function is used to configure the project's details, including its name, dependencies, ...
codefeedback
You are tasked with creating a Python class method that interacts with a database using SQLAlchemy. Your task is to complete the implementation of the method `get_database_version` in the given Python class. The method should connect to the database using the provided `db_url` and retrieve the database version. If the ...
codefeedback
You are tasked with implementing a function to convert a given string to uppercase using C++. The function should modify the input string in place and return a reference to the modified string. You are not allowed to use any built-in functions or libraries for case conversion. You need to implement the `toupper` funct...
codefeedback
You are working on a 3D mesh processing application and need to calculate the vertex normal vectors for a given mesh. The mesh is represented by a set of vertices and triangular elements. Each vertex has an associated index, and each triangular element is defined by three vertex indices. The goal is to calculate the no...
codefeedback
You are tasked with implementing a function that simulates a simple asynchronous task scheduler. The scheduler should be able to execute a series of tasks in a non-blocking manner, where each task takes a certain amount of time to complete. Your goal is to design a scheduler that can efficiently manage the execution of...
codefeedback
You are tasked with creating a program to visualize data using a graphing library. The program should take a set of data points and plot them on a graph to provide a visual representation of the data. The graphing library used in this problem is called "pChart," which provides a simple and efficient way to create vario...
codefeedback
You are working on a Django web application that includes a model for machine learning models. The application uses Django's migration system to manage changes to the database schema. The code snippet provided is a part of a migration file that adds a new field to the `mainsite` app's `mlmodel` model. Your task is to ...
codefeedback
You are tasked with creating a Python function that optimizes a web page by conditionally adding a script tag to the HTML content based on the presence of a specific cookie. The function should read the content of a file, check for the existence of a cookie, and modify the content accordingly before returning it along ...
codefeedback
You are tasked with implementing a simplified version of a Byzantine Fault Tolerant (BFT) consensus algorithm using the BLS (Boneh-Lynn-Shacham) multi-signature scheme. The provided code snippet includes a class `BlsBftReplica` with a constant `PPR_BLS_MULTISIG_WRONG` defined as 1. Your task is to create a function tha...
codefeedback
You are tasked with implementing a function that encodes integers into bytes according to a specific encoding scheme. The function should take an integer as input and return the corresponding byte representation based on the following rules: - If the input integer `i` is less than 253 (0xfd in hexadecimal), the functi...
codefeedback
You are tasked with implementing a parser for a simple expression language. The language supports literals, parentheses, symbol invocations, member access, and array access. Your goal is to implement the `group` function, which parses an input expression enclosed in parentheses. The provided code snippet is a part of ...
codefeedback
You are tasked with implementing a class for a sparse linear solver in C++. The class should handle the setup and deletion of a matrix and provide a method for setting up the solver. The provided code snippet is a part of the class implementation and shows the initialization and deletion of a matrix. Your task is to c...
codefeedback
You are tasked with implementing a Python class that represents a section of a data file containing reference system definitions. The provided code snippet is part of a larger program and includes a function and variable assignments related to this task. Your goal is to create a class that adheres to the requirements i...
codefeedback
You are tasked with implementing a function that performs a safe conversion between two different types of pointers in Rust. The function should take two arguments: a mutable reference to a slice of integers and a mutable reference to a slice of floats. The goal is to convert the integer slice into a float slice withou...
codefeedback
You are tasked with implementing a Python class that manages data processing for a scientific experiment. The class, named `DataProcessor`, is responsible for handling various configurations and customizations for data processing. The class should have the following attributes and methods: Attributes: - `skims`: A li...
codefeedback
You are tasked with implementing a Python function that calculates the summary of a financial transaction. The function should take three parameters: `valor` (the transaction amount), `largura` (the width of the summary output), and `altura` (the height of the summary output). The function should then generate a visual...
codefeedback
You are tasked with creating a script to automate the setup of a Minecraft server. Your script should download the latest version of the Minecraft server software and set up the necessary configuration files. Your script should perform the following steps: 1. Use the `curl` command to fetch the version manifest JSON f...
codefeedback
You are tasked with implementing a custom `AnimatedRecyclerView` class in Android that extends the `RecyclerView` widget. The `AnimatedRecyclerView` should support various animation and layout configurations to provide a visually appealing user experience. Your task is to complete the implementation of the `AnimatedRec...
codefeedback
You are tasked with implementing a function that joins individual pieces of a URL together to form a complete URL. The function should handle various cases, including handling of slashes, ensuring proper formatting, and handling of special characters. You are given the following code snippet as a starting point: ```p...
codefeedback
You are tasked with implementing a class for creating fields in a data model. The class should have the ability to generate mock values based on the field type. Your task is to implement the `make_field` function and the corresponding `Field` class to fulfill the requirements. The `make_field` function should take two...
codefeedback
You are tasked with creating a Python script to analyze sequencing runs and identify missing parts of the analysis. The script should take input arguments specifying the sequencing runs to be analyzed and then perform the necessary checks to identify any missing components. Your task is to implement a function `analyz...
codefeedback
You are given a code snippet from a file that defines a data structure using a specific syntax. Your task is to write a program that can parse and extract the subtype and super-entity information from the given code snippet. Write a function or method that takes the code snippet as input and returns the subtype and su...
codefeedback
You are tasked with implementing a Python class that simulates a modified string object. The class, named `CustomString`, should have the following functionalities: 1. The `__repr__` method should return a representation of the string with the first character removed. 2. The `__str__` method should return the string wi...
codefeedback
You are tasked with implementing a custom type trait in C++ that determines whether a given type is a pointer type or not. You should create a type trait called `IsPointer` that evaluates to `true` if the provided type is a pointer, and `false` otherwise. Your task is to complete the implementation of the `IsPointer` ...
codefeedback