instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are given a list `A` of integers. Write a function `rearrange_max_to_front` that rearranges the elements of the list such that the maximum absolute value element is moved to the front of the list. If there are multiple elements with the same maximum absolute value, the one with the lower index should be moved to th... | codefeedback |
You are tasked with creating a Swift protocol that defines a base conversion functionality and implementing a mock class that conforms to this protocol. The protocol should have a method to convert a given string from one base to another, and the mock class should keep track of the number of times the conversion method... | codefeedback |
You are tasked with implementing a custom probability density function (PDF) for a statistical analysis library. The PDF function should be able to handle various input types and provide the probability density function normalized over a specified range.
Your task is to complete the implementation of the `ext_pdf` met... | codefeedback |
You are tasked with creating a Rust library that provides a unified interface for querying system information on various Linux distributions. The library should be able to retrieve data related to the distribution, uptime, package managers, shell, screen resolution, window manager, and desktop environment.
Your task i... | codefeedback |
You are tasked with creating a script that processes input using AWK. The script should be designed to take advantage of environment variables and produce specific output based on the input provided.
Your task is to write a Bash script that meets the following requirements:
- The script should check if the environment... | codefeedback |
You are tasked with implementing a Python class for simulating a universe. The universe is represented as a grid of cells, where each cell can either contain a value or be empty. The class should provide methods for creating a universe from a given dataset and for generating a random universe of specified dimensions.
... | codefeedback |
You are tasked with creating a validation function for a decentralized application (dApp) using the Holochain framework. Holochain is a platform for building decentralized applications that uses a unique approach to data storage and validation. In this problem, you will be working with the Rust programming language and... | codefeedback |
You are tasked with implementing a method to calculate the total cost of a user's shopping cart items, including any applicable taxes and shipping costs. You are provided with the following interfaces and classes:
```java
import com.rrcorpus.domain.ShippingAddress;
import com.rrcorpus.domain.ShoppingCart;
import com.r... | codefeedback |
You are tasked with implementing a dependency resolution algorithm for a package manager. The package manager maintains a list of dependencies for each package, and your goal is to resolve these dependencies in a way that satisfies all requirements and detects any unexpected dependencies.
You are given a Rust function... | codefeedback |
You are tasked with implementing a class to simulate the behavior of a screw (Sruba in Polish). The class, named `Sruba`, has a member function `krec` that rotates the screw by a specified angle. The rotation angle is accumulated in the member variable `kat_obrotu_sruby`. The function also checks if the total rotation ... | codefeedback |
You are tasked with implementing a function to calculate the joint probability distribution of a given set of random variables. A joint probability distribution represents the probability of each combination of values for the random variables.
You are given a code snippet that demonstrates part of the implementation. ... | codefeedback |
You are working on a data analysis project that involves predicting stock market behavior. You have a dataset containing historical stock prices and corresponding features. Your task is to implement a function that processes the data and makes predictions based on a linear model. The given code snippet is part of the p... | codefeedback |
You are tasked with implementing a file reading utility in Rust that can asynchronously read a file from a given path with an initial offset and endianness. Your task is to complete the implementation of the `from_file_with_offset_async` function, which is an asynchronous function that reads a file from the specified p... | codefeedback |
You are tasked with implementing a simple observer pattern in Python. The observer pattern is a behavioral design pattern that defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. In this problem, you will create a class that ... | codefeedback |
You are tasked with implementing a method to extract and set the video orientation metadata for filmstrip items in a media processing application. The provided code snippet contains a method `loadRotationMetadata` that takes a `FilmstripItem` object as a parameter. The `FilmstripItem` class has a method `getData()` tha... | codefeedback |
You are given a list of floating-point numbers representing the daily temperatures in degrees Celsius over a period of time. Your task is to write a program to find the longest consecutive sequence of days where the temperature was strictly increasing.
For example, given the following list of temperatures:
```
1.85, 1... | codefeedback |
You are tasked with creating a program to parse a Java class file and extract the names of the private fields along with their associated comments. The comments are written in Chinese and may contain multi-line descriptions. Your program should output the field names and their corresponding comments.
You are given a s... | codefeedback |
You are tasked with implementing a function to process and save annotations from a given file. The function `saveAnn(annpath, outpath, termcodes)` takes three parameters:
- `annpath`: a string representing the file path to the annotation file.
- `outpath`: a string representing the file path where the processed annotat... | codefeedback |
You are tasked with implementing a simple authentication and post management system using React and Redux. The given code snippet is a part of a React component that displays a list of posts and provides functionality for user authentication and post management.
Your task is to complete the implementation of the authe... | codefeedback |
You are given a code snippet from a graphical user interface (GUI) application. The code appears to be part of a function that updates the display of a horizontal scroll bar and associated label. The function seems to be responsible for drawing the label, formatting and drawing text, and updating the scroll bar's posit... | codefeedback |
You are tasked with implementing a C++ program to calculate the total surface area and volume of various 3D shapes. The program should utilize classes and inheritance to represent different shapes and should provide accurate calculations for each shape.
You are provided with the following class declarations in separat... | codefeedback |
You are tasked with implementing a custom asynchronous task scheduler in Rust. The scheduler will manage a set of tasks and execute them in a non-blocking, concurrent manner. To achieve this, you need to create a `Task` struct that represents an asynchronous task and a `Scheduler` struct responsible for managing and ex... | codefeedback |
You are tasked with creating a build automation tool that can handle dependencies and parallel execution. Your tool should be able to parse a configuration file, resolve dependencies, and execute build tasks in parallel. The configuration file will contain a list of tasks, each with its own dependencies and commands to... | codefeedback |
You are tasked with creating a program to encode and decode messages using the rail fence cipher. The rail fence cipher is a form of transposition cipher that rearranges the plaintext letters in a zigzag pattern along a set number of "rails" or rows.
For encoding, the message is written in a zigzag pattern down the ra... | codefeedback |
You are tasked with implementing a timer module in Rust. The timer should be able to start and measure the elapsed time since its start. You are provided with a code snippet that includes a method to create a new timer and start it. Your task is to complete the implementation of the timer module by adding the necessary... | codefeedback |
You are tasked with implementing a binary search tree (BST) in Python. A binary search tree is a binary tree in which each node has a key, and for any node, all the keys in its left subtree are less than its key, and all the keys in its right subtree are greater than its key. Your task is to implement the `insert` and ... | codefeedback |
You are tasked with implementing a pagination system for a web application. The pagination system should generate the necessary HTML code for displaying page numbers and navigation controls.
You are given a JavaScript function `generatePagination` that takes in three parameters:
- `totalPages` (integer): The total num... | codefeedback |
You are tasked with implementing a function that calculates the number of edits required to transform a given string into a target string using a sliding window approach. The function should take in three parameters: the original string, the target string, and the window size. The sliding window should move through the... | codefeedback |
You are tasked with creating a program that processes video files and extracts specific frames based on user-defined criteria. The program should utilize the AVKit framework for video processing and be designed to run on iOS devices.
Your task is to implement a function called `extractFrames` that takes in the followi... | codefeedback |
You are tasked with implementing a class that represents an image plotter. The class has three properties: `_f160`, `_grid`, and `pixels_per_image`. Your task is to complete the implementation of the `pixels_per_image` property, which should return the total number of pixels in the image based on the dimensions of the ... | codefeedback |
You are tasked with creating a Python module for analyzing and evaluating a set of Tweets. The module should include functionality for audience and/or conversation analysis. The provided code snippet is the beginning of the module and sets up the logging configuration.
Your task is to implement the following functions... | codefeedback |
You are tasked with implementing a Python function that extracts the argument specification from a function definition. The function should handle cases where the function has decorator(s) and return the argument specification if no decorator is present. The argument specification should include the function's argument... | codefeedback |
You are tasked with debugging a shader definition function in a game engine. The function `AddShaderDefinition` is used to add a new definition to a shader, but it seems that there is a bug in the code. The function takes two parameters: the name of the shader definition and a boolean value indicating whether the defin... | codefeedback |
You are tasked with implementing a Python class that represents a tree data structure. The tree should support adding branches for different types and checking if a given type is present in the tree. Additionally, the tree should be able to handle type dictionaries, where a type may be associated with another type in a... | codefeedback |
You are working on a project that involves processing audio data using a custom pipeline. As part of this pipeline, you need to implement a stage that applies a label to the processed audio data. The label is determined based on the input model and is selected from a predefined set of labels.
Your task is to create a ... | codefeedback |
You are tasked with creating a script to automate the deployment of a Docker image to a GitLab registry. The script should perform the following steps:
1. Log in to the GitLab registry using the provided credentials.
2. Build a Docker image tagged as `registry.gitlab.com/allawaabdat/haproxy`.
3. Push the built Docker ... | codefeedback |
You are tasked with creating a script to automate the download of various software packages based on their availability. The script should use the `curl` command to download the packages only if they do not already exist in the specified locations.
Given the provided code snippet, you need to extend the script to incl... | codefeedback |
You are tasked with implementing a timer system in a game engine. The timer should start counting when enabled and stop when a certain time threshold is reached. Additionally, the timer should trigger a flag when the specified time threshold is reached. You are provided with a code snippet that includes some variables ... | codefeedback |
You are tasked with creating a Bash script that searches for executable files within the directories listed in the PATH environment variable and counts the number of GitHub stars for each executable file's repository. The script should then display the top N repositories with the highest number of stars, where N is a u... | codefeedback |
You are tasked with implementing a singleton design pattern for a `PlanetEngine` class in C++. The given code snippet contains a destructor for the `PlanetEngine` class and a static method `Get()` which is intended to return the instance of the `PlanetEngine`. However, there is a comment indicating the intention to rem... | codefeedback |
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the balance. Additionally, the class should be able to generate a unique account number for each new account.
Your task is to implement the `BankAccoun... | codefeedback |
You are tasked with implementing a graph data structure with weighted edges and a method to find the shortest path between two nodes using Dijkstra's algorithm. The graph is represented using a custom class `GrafoComPesos` which takes a dictionary of edges and their weights as input. The class has a method `dijkstra` w... | codefeedback |
You are tasked with implementing a function that will generate all possible combinations of a given pattern. The pattern consists of placeholders represented by curly braces `{}` and non-placeholder characters. The function should replace each placeholder with all possible values from a set of options and return a list... | codefeedback |
You are tasked with implementing a digital-to-analog converter (DAC) top-level function in a hardware description language (HDL) for a digital signal processing (DSP) application. The function signature is as follows:
```c
output_type dac_top(input_type in, bool valid);
```
Where:
- `input_type` is the type of the in... | codefeedback |
You are tasked with implementing a Swift function that validates a given instance of `BuildAppEncryptionDeclarationLinkageRequest` based on certain criteria. The `BuildAppEncryptionDeclarationLinkageRequest` struct represents a request containing the ID of the related resource. It has a nested struct `Data` containing ... | codefeedback |
You are tasked with implementing a memoization utility for caching the results of opening iModel databases. Memoization is a technique used to improve the performance of functions by caching the results of expensive function calls and returning the cached result when the same inputs occur again. Your goal is to impleme... | codefeedback |
You are tasked with implementing a Python function to filter a list of dictionaries based on a specific condition. The function should take a list of dictionaries and a filter condition as input and return a new list containing only the dictionaries that satisfy the given condition.
You are given the following code sn... | codefeedback |
You are tasked with creating a function that determines the script (writing system) of a given Unicode character. The script can be one of the following: Han, Latin, Common, or Any. The function should return the appropriate script based on the input character.
Write a function `find_script` that takes a Unicode chara... | codefeedback |
You are working on a project that involves image processing and perspective transformation. Your task is to implement a function that takes an input image and performs a perspective transformation on it. The function should also provide the option to reverse the transformation and display the original and transformed i... | codefeedback |
You are tasked with implementing a simple stack data structure in Swift. A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. It has two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack.
Your task is to creat... | codefeedback |
You are tasked with implementing a caching mechanism for a function that evaluates leaf predicates in a tree structure. The function `leafpred(leaf)` takes a leaf object as input and returns a value based on some predicate evaluation. To optimize performance, a caching mechanism is introduced to store the results of pr... | codefeedback |
You are tasked with creating a secure file management system for a company. The system should allow users to upload files, access their own files, and delete files they have uploaded. To achieve this, you need to implement a secure file server with user authentication and file management capabilities.
You have been pr... | codefeedback |
You are tasked with implementing a function that processes a list of integers and returns the maximum sum of a contiguous subarray within the list. The function should have the following signature:
```swift
func maxSubarraySum(_ nums: [Int]) -> Int {
// Your implementation here
}
```
The function should take in a... | codefeedback |
You are tasked with creating a Python function to determine whether a given integer is a palindrome. A palindrome is a number that reads the same backward as forward. For example, 121 is a palindrome, while 123 is not.
Write a function `is_palindrome` that takes an integer `x` as input and returns `True` if `x` is a p... | codefeedback |
You are tasked with implementing a thread-safe storage system for handling results of asynchronous operations. The provided code snippet includes a Swift class with a private condition lock and an atomic variable for storing results. Your task is to extend this class by implementing methods for setting and getting resu... | codefeedback |
You are tasked with implementing a simplified version of Python's `OrderedDict` data structure. An `OrderedDict` is a dictionary subclass that remembers the order in which its contents are added. When iterating over an ordered dictionary, the items are returned in the order they were inserted.
Your task is to create a... | codefeedback |
You are tasked with creating a Python function that simulates a flight fare calculator using the requests library to send HTTP requests to a specific URL. The function should take in several parameters and return the calculated fare for a flight.
The function should have the following signature:
```python
def calcula... | codefeedback |
You are tasked with creating a program to help a Jedi Padawan manage their equipment budget. The program should take the following inputs:
- The amount of money the Padawan has (amountOfMoney).
- The number of students in the Padawan's class (studentsCount).
- The price of a lightsaber (priceOFLightsaber).
- The price ... | codefeedback |
You are tasked with implementing a function to process genomic data from a set of inputs and generate output files. The function takes a list of input samples, a list of background samples, and a working directory as input. The function processes each input sample to generate output files, including copy number ratio (... | codefeedback |
You are tasked with implementing a function that checks whether a given string matches a specific pattern. The pattern consists of letters and wildcards represented by asterisks (*). A wildcard can match any sequence of characters, including an empty sequence. The function should return true if the string matches the p... | codefeedback |
You are tasked with creating a program to analyze a given text corpus using natural language processing techniques. The program should perform the following tasks:
1. Preprocess the text data by removing punctuation and converting all words to lowercase.
2. Calculate the Term Frequency-Inverse Document Frequency (TF-I... | codefeedback |
You are tasked with implementing a simple fee management system for a national park API. The provided code snippet is a part of the `Fee` class in the `ParksApi.Models` namespace. Your task is to complete the implementation of the `Fee` class by adding properties and methods to manage fees for different activities with... | codefeedback |
You are tasked with implementing a function to calculate the distance between the centers of two objects represented by rectangles. The rectangles are defined by their top-left corner coordinates (x, y) and their width (w) and height (h). The distance between the centers of the rectangles is calculated using the Euclid... | codefeedback |
You are given a code snippet that contains a method. Your task is to identify the missing parts of the code and complete the method to achieve the desired functionality.
The method is intended to check whether a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that ... | codefeedback |
You are tasked with creating a Python script that simulates a simple text-based game. The game involves a player navigating through a series of rooms, each containing different challenges or rewards. The player must collect items and solve puzzles to progress through the game. Your task is to implement the logic for mo... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The system should be able to create and manage bank accounts, allowing users to deposit, withdraw, and check their balance. Additionally, the program should be able to transfer funds between accounts.
Your task is to implement the `BankAcco... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a specific rule for calculating the final score. The rule is as follows:
- If the score is even, it is added to the total score.
- If the score is odd, it is subtracted from the total score.
Write a function `calculate_final_score` that t... | codefeedback |
You are tasked with creating a script to automate the process of checking and updating the Linux kernel version on a system. The script should retrieve the latest stable kernel version from a specified URL and compare it with the current kernel version installed on the system. If the latest version is different from th... | codefeedback |
You are tasked with creating a script to automate the process of managing encrypted passwords using the `pass` command-line password manager. The script should handle the initialization of `pass` with a GPG key and the addition of new passwords to the password store. The script should also ensure that the GPG key is ge... | codefeedback |
You are tasked with creating a custom validation function for a Django model in a web application. The function should ensure that a specific field in the model adheres to a certain format. To achieve this, you need to implement a custom validator using Django's validation framework.
Your task is to create a custom va... | codefeedback |
You are given the definition of a binary tree node and a function `is_same_tree` that takes in two binary trees `p` and `q` as input. The function is expected to return `True` if the two trees are structurally identical and the nodes have the same value at each position, and `False` otherwise. The function should handl... | codefeedback |
You are tasked with implementing a function to calculate the molecular weight of a compound based on its chemical formula. The molecular weight of a compound is the sum of the atomic weights of all the atoms in the compound. You are given a code snippet that contains part of a function for reading the molecular weight ... | codefeedback |
You are tasked with implementing a Python function that processes a given string to convert it into title case. Title case means that the first letter of each word in the string should be capitalized, while the rest of the letters should be in lowercase. However, there are exceptions to this rule, such as certain words... | codefeedback |
You are tasked with implementing a graph visualization tool that can display a graph in a graphical user interface (GUI). The graph is represented using an adjacency list. Each node in the graph is represented by a unique integer, and the edges are represented as pairs of integers denoting the connected nodes. You need... | codefeedback |
You are tasked with implementing a custom data transformer class in Python for preprocessing numerical and categorical features. The class should have methods for fitting the transformer to the data and transforming the data based on the fitted transformer. The transformer should scale the numerical features using Stan... | codefeedback |
You are tasked with creating a Python program that performs DNS resolution and scanning for CDS (Child DS) records. The program should utilize multithreading to improve performance and handle potential delays in DNS resolution.
Your program should have the following features:
1. Accept a list of domain names as input.... | codefeedback |
You are tasked with implementing a custom transformer class for feature engineering in a machine learning pipeline. The class, named `CustomTransformer`, has a method `fit` that takes in a DataFrame `df` and several optional parameters. The method performs some operations on the input DataFrame based on the provided pa... | codefeedback |
You are tasked with implementing a Python function that processes data from a weather station and calculates the average temperature for each month. The function should handle missing data and allow for customization of units and color maps for visualization.
You are given a code snippet from the function that handles... | codefeedback |
You are given a list of weights representing the weights of items to be loaded onto a truck. The truck has a weight capacity of `capacity`. Your task is to implement a function `maximize_load(weights, capacity)` that maximizes the total weight of items that can be loaded onto the truck without exceeding its capacity. Y... | codefeedback |
You are tasked with creating a Python script to interact with an RFID reader using the RFIDIOt library. The script should establish a connection with the RFID reader and perform read operations on RFID tags. The RFID reader is connected to the computer via the serial port /dev/ttyUSB0, and the script should communicate... | codefeedback |
You are tasked with simulating the behavior of a simple neuron using the leaky integrate-and-fire (LIF) model. In this model, the membrane potential of the neuron is governed by a simple differential equation. When the membrane potential reaches a certain threshold, the neuron fires a spike and the potential is reset t... | codefeedback |
You are tasked with implementing a cross-entropy loss function and its gradient calculation using Python and NumPy. The cross-entropy loss function is commonly used in machine learning for classification tasks. The provided code snippet gives a hint about the structure of the functions to be implemented.
Your task is ... | codefeedback |
You are tasked with creating a Python program that interacts with the Telegram messaging platform using the `telethon` library. Your program needs to implement a message retrieval function that operates in "past mode" and requires a user account to function. The "past mode" should handle all existing messages, and the ... | codefeedback |
You are tasked with implementing a notification system for a social media platform that aggregates notifications from various sources and digests them for user consumption. The system should be able to handle notifications from Reddit, Stack Exchange, and credit card charges. To achieve this, you need to create a notif... | codefeedback |
You are tasked with implementing a custom virtual scrolling feature for a web application. Virtual scrolling is a technique used to efficiently render large lists by only rendering the items that are currently visible on the screen, thus improving performance and reducing memory consumption.
Your task is to create a V... | codefeedback |
You are tasked with implementing a command-line utility for managing files and directories. The utility should provide various commands for file operations such as creating, deleting, and listing files and directories. Additionally, the utility should support the ability to disable the deletion functionality for specif... | codefeedback |
You are tasked with creating a Django admin interface for managing employees in a company. The company already has a User model for authentication and wants to integrate the Employee model into the admin interface. The Employee model is defined in a separate file and needs to be registered with the Django admin.
Your ... | codefeedback |
You are tasked with implementing a 1D burgers' equation solver using the finite volume method. The code snippet provided initializes the parameters for the solver. The burgers' equation is given by:
∂u/∂t + ∂(u^2)/∂x = ν * ∂^2u/∂x^2
Where u is the velocity field, t is time, x is the spatial coordinate, and ν is the k... | codefeedback |
You are tasked with implementing a unit test for a module in an Intrusion Detection System (IDS) software. The code snippet provided is a part of the unit test for the module. The `ib_module_t` structure represents a module in the IDS software, and the test is validating various properties of this module.
Your task is... | codefeedback |
You are tasked with creating a function to process and aggregate data from a collection of elements. The input data consists of an array of objects, each representing an element in a subsection. Each object contains properties such as `shortLabel`, `longLabel`, `dropdownLabel`, `dropdownSearchString`, and `dropdownValu... | codefeedback |
You are tasked with implementing a function that processes filter widget settings in a Redux Saga middleware. The function `unapplyFilterWidget()` takes an action object as input and is responsible for unapplying the filter widget settings based on the provided widget ID. The function uses the `sagaHelper` utility to t... | codefeedback |
You are tasked with creating a Discord bot that sends a scheduled message to a specific channel at a given time using Python and the `discord.py` library. The bot should use the `apscheduler` library to schedule the message sending. Your task is to implement the necessary code to achieve this functionality.
You are pr... | codefeedback |
You are tasked with creating a Rust program that involves parsing and processing JSON data using the Serde library. Your goal is to define a data structure and implement a function to extract specific information from the JSON data.
You are given a JSON response from an API call, which represents a successful response... | codefeedback |
You are tasked with implementing a function to calculate the Kullback-Leibler (KL) divergence for a variational autoencoder (VAE) model. The function should take in the parameters of two normal distributions and return the reconstruction loss and the total KL divergence.
The function should be defined as follows:
```p... | codefeedback |
You are tasked with creating a shell script that automates the process of converting a file written in the "svgbob" format to an SVG file using the "svgbob" CLI tool. The "svgbob" format is a simple textual representation of ASCII art diagrams, and the "svgbob" CLI tool is capable of converting these textual diagrams t... | codefeedback |
You are tasked with creating a function that processes a given report aggregator state and returns a new object with the average values for each property. The report aggregator state is represented as an interface `IReportAggregator` with properties `weighted_score`, `time_allocated`, `time_taken`, and `weight`, each o... | codefeedback |
You are tasked with creating a program that utilizes a pre-trained clinical BERT model to predict the similarity between pairs of clinical sentences. The clinical BERT model is a specialized language representation model designed for clinical text. The model takes pairs of sentences as input and outputs a similarity sc... | codefeedback |
You are tasked with creating a function that retrieves data from a database using Laravel's Eloquent ORM. The database contains two tables: `stock_entries` and `books`. The `stock_entries` table stores information about stock entries, including the ISBN of the book, while the `books` table contains details about the bo... | codefeedback |
You are tasked with creating a Python function that utilizes the GPT (Generative Pre-trained Transformer) model to generate text based on a given prompt. The GPT model is loaded using the provided code snippet, and you need to implement a function that takes a prompt as input and generates a specified number of tokens ... | codefeedback |
You are tasked with implementing a dependency resolution algorithm for a software build system. The build system uses a custom format to define dependencies between different actions. Each action can depend on one or more other actions, and the dependencies are specified in a specific format within the source code.
Th... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.