instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a Python program that performs time series analysis using Fourier analysis and percentile calculation. The program should take command-line arguments to specify the number of days in the time window, the percentile to calculate, and the number of Fourier harmonics to keep. Your program...
codefeedback
You are tasked with implementing a Python function that generates a placeholder name based on the base name of a given variable. The base name is obtained by removing any prefixes or suffixes from the variable name. The placeholder name should be in the format "placeholder_{base_name}". Write a function `generate_plac...
codefeedback
You are working on a project that involves loading a cryptographic library called ZkSyncCrypto in a web application. The library is loaded asynchronously using the `loadZkSyncCrypto` function. The code snippet provided is a part of this process. Your task is to implement the `loadZkSyncCrypto` function and ensure that ...
codefeedback
You are tasked with creating a Swift function that calculates the total cost of a shopping cart, including any applicable discounts. The function should take in an array of tuples, where each tuple represents an item in the shopping cart. Each tuple contains the item's name, price, and quantity. Additionally, the funct...
codefeedback
You are tasked with creating a Python class to manage a library's collection of books. The class should allow for adding new books, removing existing books, and updating book information. Additionally, the class should provide a method to search for books by title or author. Your task is to implement the `Library` cla...
codefeedback
You are tasked with implementing a card sorting algorithm based on correctness of answers. The algorithm will use a context model to keep track of the number of cards in each bin. The context model is represented by the `RegisterAnswerContextModel` class, which contains a dictionary `CardsInBins` to store the number of...
codefeedback
You are tasked with implementing a generic method for inserting data into a database using a Data Access Object (DAO) in Java. The method signature is as follows: ```java public <T extends DAO> T insert(DAO dao, boolean excludePrimaryKeys) throws DatabaseException; ``` The method takes two parameters: 1. `dao`: A Dat...
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. You need to implement the `NodeContext` cl...
codefeedback
You are tasked with creating a function to validate responses in a credit transaction system. The function should check if all responses have a blank field for a specific attribute and return a boolean value accordingly. You are provided with a code snippet that demonstrates the usage of the function `assertAllResponse...
codefeedback
You are tasked with creating a Python function that extracts the copyright year from an HTML snippet. The function should take a string of HTML code as input and return the copyright year if found, or "Copyright year not found" if no copyright year is present. The HTML snippet will contain a `<p>` tag with the class "...
codefeedback
You are tasked with creating a Python package manager that can handle dependencies and resolve them in a given project. The package manager should be able to parse a project's requirements and resolve the dependencies in the correct order. Each package may have dependencies on other packages, and it's essential to reso...
codefeedback
You are given a 2D grid representing a maze. The maze consists of cells, where each cell can either be empty or blocked. You are initially positioned at the top-left cell (0, 0) and your goal is to reach the bottom-right cell (x, y). You can move in four directions: up, down, left, and right. Each move to a neighboring...
codefeedback
You are tasked with implementing a Python decorator that tracks the order of function calls within a program. The decorator should maintain a list of visited functions in the order they are called and print the list when a specific condition is met. You are provided with a code snippet that defines a function `d` and ...
codefeedback
You are tasked with creating a utility function to validate user input for mobile numbers and passwords. The given code snippet contains two functions, `isValidateMobile()` and `isMedPassword1()`, which use regular expressions to perform the validation. Your task is to implement a similar utility function for validatin...
codefeedback
You are given a square maze represented as a 2D list of characters. The maze has a size of `n x n`, where `n` is an odd number. Each cell in the maze contains either a space (' ') or an obstacle ('#'). Your task is to create a function that takes the maze as input and returns a new maze that is twice the size of the or...
codefeedback
You are tasked with implementing a Python function that calculates the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. For example, the first few terms of the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21...
codefeedback
You are tasked with implementing a function that manipulates a directed graph represented by nodes and edges. The graph is used to model a flow network, where each edge has a capacity and a flow. Your goal is to implement a function that updates the flow in the graph based on a given path and a flow value. You are giv...
codefeedback
You are tasked with implementing a function that determines whether a given string is a palindrome, considering both the original string and its reverse. However, the function should also ignore the case of the characters in the string. A palindrome is a word, phrase, number, or other sequence of characters that reads ...
codefeedback
You are tasked with implementing a function that processes a sequence of integers and performs specific actions based on the values encountered. The function should iterate through the sequence and carry out the following operations: 1. If the current integer is less than or equal to 10, it should be ignored. 2. If the...
codefeedback
You are tasked with creating a Python function that processes a list of compartments and their subcompartments to generate a hierarchical full path for each active subcompartment. The function should take in the list of subcompartments and their corresponding names, and then construct the full path for each active subc...
codefeedback
You are working on a deep learning project and need to implement a custom callback function for model training. The callback function should monitor the training process and perform specific actions based on the training progress. Your task is to create a custom callback class in Python that logs the training progress ...
codefeedback
You are tasked with implementing a Python module that provides a function for visualizing data from a CSV file. The module should include a function called `csviz` that takes in the file path of a CSV file and generates a bar chart to visualize the data. The bar chart should display the frequency of occurrence of each ...
codefeedback
You are tasked with implementing a circular queue data structure using an array. A circular queue is a data structure that follows the FIFO (First In First Out) principle and has a fixed size. Once the queue is full, adding a new element will overwrite the oldest element in the queue. You are given the variable `queue_...
codefeedback
You are tasked with implementing a function that performs a 3D pixel shuffle operation with channel-to-space alignment. The function takes in various parameters and performs the pixel shuffle operation based on the provided input. Your task is to understand the requirements and implement the pixel shuffle function acco...
codefeedback
You are tasked with implementing a Merkle Tree data structure in Python. A Merkle Tree is a binary tree in which each non-leaf node is labeled with the cryptographic hash of the labels or values of its child nodes. The leaves of the tree contain the actual data or values to be hashed. The Merkle Tree is commonly used i...
codefeedback
You are tasked with implementing a simple navigation system for a web application using React Router. The provided code snippet is a part of the navigation component. Your task is to complete the navigation by adding routes and corresponding components to render when the user navigates to different paths. Your goal is...
codefeedback
You are tasked with implementing a function that checks the validity of a given license key. A license key is a string that consists only of alphanumeric characters and dashes, with a specific pattern. The pattern is as follows: - The string is composed of segments, where each segment is a group of characters separated...
codefeedback
You are tasked with implementing a parallel reduction algorithm using CUDA to efficiently compute the sum of an array of integers. The provided code snippet initializes the CUDA blocks for this task. Your task is to complete the CUDA kernel function for parallel reduction, which will be responsible for reducing the in...
codefeedback
You are working on a Kubernetes deployment script that involves creating and managing Certificate Signing Requests (CSRs) for securing communication between server and client components. The script includes the following relevant code snippet: ```bash - key encipherment - server auth EOF ) echo_or_run --with-kubec...
codefeedback
You are tasked with creating a Python program that establishes a secure communication channel between a client and a server using a custom protocol. The server will generate a random secret key, which will be used to encrypt and decrypt messages sent between the client and the server. Your task is to implement the clie...
codefeedback
You are tasked with optimizing the performance of a cluster mapping algorithm. The algorithm is part of a larger system and is implemented in a class with the following relevant attributes and methods: ```python class ClusterMapper: def __init__(self): self._clusters = [] @property def clusters(se...
codefeedback
You are tasked with implementing a simplified version of a web service for managing lots in a parking system. The provided code snippet is a part of an asynchronous Rust web service using the Tower gRPC framework. The `merge_unit` function is responsible for handling a gRPC request to merge two parking lots into a sing...
codefeedback
You are tasked with implementing a custom React hook that dynamically adjusts the number of columns in a grid layout based on the screen size. The hook should be able to determine the appropriate number of columns for different screen sizes and return this value to be used in a grid component. Your task is to create a...
codefeedback
You are tasked with creating a custom page validator for a search engine optimization (SEO) tool. The SEO tool operates within a .NET environment and utilizes the SEO.Model namespace for various SEO-related functionalities. Your task is to implement a custom page validator within the SEO.PageValidators namespace that c...
codefeedback
You are tasked with implementing a custom precision arithmetic class in C++ using the Boost library. The custom precision arithmetic class should be capable of performing arithmetic operations with a specified precision and expression template option. Your task is to create a class template named `CustomPrecisionArith...
codefeedback
You are tasked with creating a Python script that automates the installation of a specific PPA (Personal Package Archive) and the subsequent installation of a package from that PPA. PPAs are commonly used in Ubuntu-based systems to provide additional software and updates not available in the official Ubuntu repositorie...
codefeedback
You are tasked with creating a Python unit test for a function called `load_initial_data` within a larger application. The `load_initial_data` function is responsible for loading initial data into the application and is expected to interact with the environment using `os.environ.get`. The test is written using the `uni...
codefeedback
You are tasked with implementing a Python module that provides a simple logging mechanism for a data processing pipeline. The module should allow users to log messages at different levels of severity and direct these messages to various destinations, such as the console or a file. Additionally, the module should suppor...
codefeedback
You are tasked with implementing a class hierarchy for a simple file system. The base class `FileSystemItem` represents a generic file system item, and it has two subclasses: `File` and `Directory`. The `File` class represents a file in the file system, while the `Directory` class represents a directory that can contai...
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 have a method to display the account holder's information. Your task is to complete the implementation of t...
codefeedback
You are tasked with creating a function that will parse and analyze a given JavaScript code snippet to identify and extract all the unique JavaScript global objects and functions used within the code. A JavaScript global object or function is considered to be any object or function that is accessible from the global sc...
codefeedback
You are tasked with creating a Swift program to model and manage the deployment status of airbags in a vehicle's cabin seat. The provided code snippet defines a Swift struct `CabinSeatRow2Pos5Airbag` that represents the airbag deployment status for a specific seat in a vehicle. The struct contains a property `isDeploye...
codefeedback
You are tasked with creating a program that processes a given text to extract specific information. The text contains statements made by a speaker during a legislative committee meeting. The goal is to identify the political parties that submitted a dissenting opinion and the proposed amendments to certain sections of ...
codefeedback
You are tasked with creating a script to automate the verification of network configuration files on a Linux system. The script should search for a specific network configuration file and then check system logs for a particular message related to network configuration. The script should perform the following steps: 1....
codefeedback
You are tasked with implementing a function to draw a series of rectangles on a screen using the Pygame library. The function `draw_next` takes in the following parameters: - `screen`: the Pygame screen object to draw on - `bot_left`: a tuple representing the bottom-left corner of the area to draw on - `top_right`: a t...
codefeedback
You are tasked with creating a Python program to validate and process user input for a price. The program should repeatedly prompt the user to enter a price, validate the input, and handle any errors that may occur. The input should be a string representing a price, which may contain commas as decimal separators. The p...
codefeedback
You are tasked with creating a custom error type in Rust to handle errors related to parsing a schema. Your custom error type should implement the `std::error::Error` trait. Your task is to define the custom error type `SchemaParsingError` and implement the `std::error::Error` trait for it. Additionally, you need to ...
codefeedback
You are tasked with implementing a simple game interface feature that detects right-clicks within a specified rectangular area. You are given a code snippet that demonstrates the use of a method `DetectClickInRect` to detect right-clicks within a GUI rectangle. Your task is to implement the `DetectClickInRect` method a...
codefeedback
You are tasked with creating a script to automate the release process for a Node.js project. The release process involves updating the project version, committing the changes to the version control system, and pushing the changes to the remote repository. Additionally, the script should handle the publishing of the pro...
codefeedback
You are tasked with implementing a function that simulates a simple text-based adventure game. The game will involve navigating through different rooms, interacting with objects, and making decisions that affect the outcome of the game. Your task is to implement the `adventureGame` function, which takes no parameters ...
codefeedback
You are given a list of integers representing the heights of a row of buildings. The buildings are of unit width and are aligned in a row. Your task is to find the total amount of rainwater that can be trapped between the buildings. The height of each building is represented by the integers in the list. For example, g...
codefeedback
You are tasked with implementing a class method that retrieves a list of members belonging to a specific group. The method should handle two different scenarios: one where the member information is retrieved from an LDAP server, and another where it is retrieved from a mock member list. The class `CSHMember` has the f...
codefeedback
You are tasked with creating a JavaScript program that processes a given code snippet to perform specific modifications. The program should add a console log statement to all functions and insert running counts to the methods `m.redraw()` and `m.render()` in a file named `mithril.js`. Your task is to write a function ...
codefeedback
You are tasked with creating a program that simulates a simplified version control system. Your program should be able to handle basic version control operations such as committing changes, checking out specific versions, and displaying the commit history. Your program should support the following commands: 1. `commit...
codefeedback
You are tasked with creating a Swift function that takes an array of integers as input and returns a new array containing the cumulative sum of the input array. The cumulative sum at each index `i` in the output array should be the sum of all elements from index 0 to `i` in the input array. For example, given the inpu...
codefeedback
You are tasked with creating a program that reads a text file and counts the occurrences of specific words within it. The program should be able to handle large text files efficiently and accurately. Your task is to implement a Python function `count_word_occurrences(file_path: str, words: List[str]) -> Dict[str, int...
codefeedback
You are tasked with implementing a simple linked list in Python. Your task is to create a class `LinkedList` with the following methods: 1. `__init__(self)`: Initializes an empty linked list. 2. `add_node(self, value)`: Adds a new node with the given value to the end of the linked list. 3. `print_list(self)`: Prints th...
codefeedback
You are tasked with creating a program to simulate an online advertising platform's bidding and targeting system. The system involves setting bids, targeting integral validation, and viewability checks. Your task is to implement a method that handles the positive flow scenario for setting bids when the ad targeting int...
codefeedback
You are tasked with creating a Python function that generates a GeoDjango model based on a given data source and model name. The function should take two parameters: the data source (either a string or a DataSource object) and the model name. The generated GeoDjango model should be compatible with the Django framework ...
codefeedback
You are working on a text processing pipeline that involves reading and processing JSON documents from a compressed file. The code snippet provided is a part of a method that reads JSON documents from a compressed file, extracts text from the documents, detects the language of the text, and filters the documents based ...
codefeedback
You are given a Python code snippet that processes a list of lists and an integer. The code aims to find elements that appear exactly `x` times across all the lists and then appends these elements to an output list. Your task is to understand the code and implement a function that achieves the same result. You need to...
codefeedback
You are tasked with implementing a voting system for a decentralized governance platform. The platform uses a canister-based architecture, and the code snippet provided initializes a governance canister and a raw proposal. Your task is to implement a function that processes a vote for a given proposal. The function sh...
codefeedback
You are tasked with creating a function that processes a list of instances and categorizes them as either running or terminated based on their uptime and end time. The function should also calculate the uptime for each running instance and store it in a compatible format for further processing. Additionally, the functi...
codefeedback
You are tasked with implementing a function to parse and process HTTP GET requests in a C++ program. The function should extract and handle the parameters from the request URL. You are given a partial code snippet from a `ConnectionsHandler` class, which includes the `handleGETRequest` method. This method is responsib...
codefeedback
You are tasked with implementing a payload class for an airport management system. The payload class should be able to store and manage various fields of data related to cargo and passengers. The fields can have different metadata associated with them, such as data type, size, and constraints. Your task is to implemen...
codefeedback
You are given a string representing the size of a file in bytes. Your task is to write a function to convert this size into a human-readable format. The function should convert the size into the most appropriate unit (bytes, kilobytes, megabytes, gigabytes, etc.) and round the result to two decimal places. For example...
codefeedback
You are given a Swift code snippet that defines a generic class `B` with a nested class `b`. Your task is to complete the implementation of the `B` class by adding a method and a property, and then utilize the class to perform a specific operation. Complete the `B` class by adding the following: 1. A method `printInfo...
codefeedback
You are working on a system that manages simulation snapshots for a scientific computing application. The provided code snippet is a part of a script that handles the management of these snapshots. The script is responsible for creating a symbolic link to the most recent snapshot file and updating some status files. T...
codefeedback
You are tasked with implementing a method to process a layout string and a document using the given code snippet as a reference. The `exec` method takes an input `a` and processes it to obtain a document and a layout string. Your task is to complete the method by implementing the processing logic for the layout string ...
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 implement a feature to check if the account holder has exceeded a predefined withdrawal limit. Your task is...
codefeedback
You are tasked with implementing a Bayesian inference algorithm to estimate the probability of a binary event occurring. The given code snippet provides some initial calculations and visualization related to the problem. Your task is to complete the implementation by writing a Python function that performs Bayesian inf...
codefeedback
You are tasked with implementing a data preprocessing function for a given dataset. The function should normalize a specific column of the dataset and then create a scatter plot using the normalized data. You are given the following information: - The dataset `data_sample2` is a pandas DataFrame containing various col...
codefeedback
You are tasked with creating a Bash script that automates the process of setting up a Docker environment for a development project. The script should handle error checking and ensure that it runs smoothly. Your task is to complete the Bash script by adding the necessary commands to achieve the desired functionality. T...
codefeedback
You are given a Java code snippet that imports classes from the `hu.nemes.projecteuler` package and defines a few Java utilities. Your task is to implement a program that utilizes these utilities to solve a specific problem related to prime numbers. Write a Java program to find the smallest prime number that is a conc...
codefeedback
You are tasked with creating a Python program that simulates a simple game of dice rolling. The game should involve two players taking turns to roll a six-sided die and accumulate points based on the outcome of each roll. The game should continue until one of the players reaches a predetermined winning score. Your tas...
codefeedback
You are tasked with creating a Python class that manages commands for a web server application. The class should inherit from the `uWSGICommand` class and provide a specific command to start the Nautobot uWSGI server. Your task is to complete the implementation of the `Command` class by adding the necessary code to def...
codefeedback
You are tasked with implementing a custom class for managing key exchanges in a messaging application. The class, named `KeyExchangeError`, is responsible for representing errors that occur during the initial key exchange process. The provided code snippet contains a partial implementation of the `KeyExchangeError` cla...
codefeedback
You are tasked with creating a Python program that reads a specific environment variable and performs a series of operations on its value. The environment variable "VAR" is expected to be set, and its value will be a string containing a sequence of comma-separated integers. Your program should read the value of "VAR", ...
codefeedback
You are tasked with creating a Python module that provides support for running machine learning models on various hardware accelerators. The module should be able to seamlessly integrate with different hardware acceleration backends such as EdgeTPU, OpenVINO, and ONNX. Your task is to implement a function that dynamica...
codefeedback
You are tasked with implementing a database migration and seeding process for a web application using Entity Framework Core. Your goal is to modify the provided code snippet to include the necessary logic for database migration and seeding. The `BuildWebHost` method is responsible for setting up the web host for the a...
codefeedback
You are tasked with implementing a Python function that simulates a simple variable management system. The system consists of two modules, `variables_lib` and `variables_lib2`, which provide functions for creating and initializing variables. The code snippet provided is a unit test for this variable management system. ...
codefeedback
You are tasked with implementing a custom neural network model for a natural language processing task. The given code snippet is a part of the model definition, which includes a pooler layer and a loss function. The `forward` method is also provided, which takes various input parameters and performs the forward pass th...
codefeedback
You are tasked with creating a script to automate the process of cleaning specific packages in a monorepo using the `yarn` package manager and `lerna` tool. The script should take a range of GitHub stars as input and clean the packages that fall within that range. Write a bash script that takes a range of GitHub stars...
codefeedback
You are tasked with creating a script to convert an amount in IOTX (IoTeX cryptocurrency) to its equivalent value in USD. The script should take the amount in IOTX as a command-line argument and output the corresponding value in USD. The current exchange rate is 1 IOTX = 0.03 USD. Your task is to complete the script b...
codefeedback
You are tasked with creating a web page that displays a list of pet categories with corresponding links. The web page should be designed using HTML and PHP. Your task is to write the HTML and PHP code to display the pet categories and their links based on the given code snippet. The provided code snippet is a part of ...
codefeedback
You are tasked with implementing a web crawler that will visit a set of seed URLs and extract all the unique domain names from the URLs it encounters. A domain name is considered to be the part of a URL between the protocol (e.g., "http://") and the first subsequent slash ("/"). For example, in the URL "http://www.exam...
codefeedback
You are tasked with implementing a function to validate and process payment requests in a payment processing system. The system interacts with a blockchain node to create payment requests and handle the payment process. Your task is to complete the implementation of the `processPaymentRequest` function, which takes in ...
codefeedback
You are tasked with implementing a caching mechanism for a function that converts WebAssembly (Wasm) modules to an intermediate representation (IR) using the `wasm_to_ir` function. The goal is to optimize the performance by avoiding unnecessary re-compilations of the same Wasm module. The provided code snippet contain...
codefeedback
You are tasked with implementing a function to check for infinite loops in a chain of `ofxSoundObject` objects. The `ofxSoundObject` class represents audio processing objects in an audio processing chain. Each `ofxSoundObject` can have an input object, forming a chain of audio processing objects. The function `checkFor...
codefeedback
You are tasked with implementing a Swift class that performs an asynchronous operation to download the balance of a cryptocurrency wallet. The balance is represented as a large integer using the `BigInt` library. Your task is to complete the implementation of the `DownloadBalanceOperation` class by adding the necessary...
codefeedback
You are tasked with creating a script to automate the cleanup of old files in a specific directory. The script should identify files in the specified directory that are older than 7 days and remove them. Write a Python script that accomplishes the following: 1. Uses the `os` module to traverse the specified directory ...
codefeedback
You are tasked with creating a program that simulates a simple banking system using Rust. The program will involve creating bank accounts, transferring funds between accounts, and verifying the transactions. You are provided with a code snippet that involves signing a transaction and processing it using the `banks_cli...
codefeedback
You are tasked with creating a function that takes a JSON object representing an image and returns the image name without the file extension. The JSON object will have a "name" key containing the image name with the file extension. Your function should extract the image name without the extension and return it. For ex...
codefeedback
You are tasked with creating a program that simulates the installation and uninstallation of Windows services. Windows services are long-running executable applications that run in the background and perform specific functions. Your program should allow users to install, uninstall, start, stop, and query the status of ...
codefeedback
You are working on a machine learning project and have a script that trains a neural collaborative filtering (NCF) model using a dataset from MovieLens. The training process involves modifying certain files, executing shell commands, and monitoring the training progress. Your task is to write a Python function to autom...
codefeedback
You are tasked with implementing a TypeScript function that takes a specified number of elements from an iterable and returns them as an iterator. The function signature is provided as follows: ```typescript declare function take<T>(n: number, iterable: Wrappable<T>): IterableIterator<T>; declare function take<T>(n: n...
codefeedback
You are tasked with implementing a function to calculate the coordinates of a 2D point after rotating it around the origin by a given angle. The rotation is performed in the counterclockwise direction. The function should take the original coordinates of the point and the rotation angle as input and return the coordina...
codefeedback
You are given a binary tree where each node contains a single digit from 0 to 9. The root-to-leaf path represents a number. For example, the root-to-leaf path 1->2->3 represents the number 123. Your task is to write a function `sumNumbers` to find the total sum of all root-to-leaf numbers. The function `sumNumbers` sh...
codefeedback
You are tasked with creating a unit test for a view controller in a messaging app. The view controller, `messagesViewController`, is part of a navigation stack managed by `navigationController`. The app uses an `apiClientFake` to simulate network responses. The `testViewDidLoad` function is intended to test the behavio...
codefeedback
You are working on a project to process and analyze profile data from tunnel linings. The given code snippet is a part of the data processing pipeline. The code snippet loads a profile from a file, applies a power gain transformation, resizes the profile, normalizes the data, extracts patches, and appends the processed...
codefeedback