instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function to generate a Discrete Fourier Transform (DFT) matrix of size N. The DFT matrix is a square matrix used in signal processing and other fields to perform the DFT operation on a sequence of values. The DFT matrix is defined as follows: \[ D_{jk} = \frac{1}{\sqrt{N}} e^{-2\pi i...
codefeedback
You are given a PHP code snippet that manipulates a string variable `$txt` based on the value of a variable `$tst` and an attribute. Your task is to understand the code and write a function that replicates its behavior. You need to implement a function `extractSubstring($txt, $attribute)` that takes in a string `$txt`...
codefeedback
You are tasked with implementing a method to find an available port for a server application. The method should continuously search for an available port and return the first one it finds. Additionally, you need to ensure that the server application stops properly and the port becomes available again after the server i...
codefeedback
You are given a Python class representing a graph structure. The class contains a method `timerange` that infers edge timeranges from the graph structure. The method takes in two timestamps `t1` and `t2`, a boolean parameter `inside`, and an optional parameter `sort`. The method is intended to return a list of nodes th...
codefeedback
You are tasked with implementing a Python class for managing datasets used in machine learning. The class, named `Dataset`, is designed to handle labeled collections of data for training and testing purposes. The class has an `__init__` method for initializing the dataset with training and test data, a vocabulary, and ...
codefeedback
You are tasked with implementing a deck of playing cards in a C# program. The deck should support adding and removing cards, as well as shuffling the deck. Each card has a suit (Hearts, Diamonds, Clubs, Spades) and a value (Two, Three, ..., Ten, Jack, Queen, King, Ace). Your task is to implement the `Deck` class with ...
codefeedback
You are tasked with implementing a WebSocket client class in Python. The class should include methods for handling the opening and closing of the WebSocket connection, as well as a method for handling incoming messages. Additionally, the class should allow for sending messages over the WebSocket connection. Your task ...
codefeedback
You are tasked with creating a Python class that manages timezones and handles timezone-related errors. Your task is to implement a `TimezoneManager` class that inherits from the `TimezoneNotFound` exception class. The `TimezoneManager` class should have methods to add timezones, retrieve timezones, and raise a `Timezo...
codefeedback
You are tasked with implementing a class to manage and calculate the sums of various features in a system. The class `Feature` represents a specific feature, and the class `Sums` is responsible for storing and managing the sums of these features. The method `getFeatures()` returns a collection of all features, and the ...
codefeedback
You are tasked with implementing a Python function that extracts a subquery from a given SQL string based on its alias. The function should take two parameters: the SQL string and the alias of the subquery to be obtained. The SQL string may contain multiple subqueries, each with a unique alias. The function should retu...
codefeedback
You are tasked with implementing a program to analyze the connectivity of a network using the NetworkX library in Python. NetworkX is a popular library for creating, manipulating, and studying the structure, dynamics, and functions of complex networks. Your task is to write a Python function that takes in a graph and ...
codefeedback
You are tasked with creating a Django view that handles the upload of images and videos to a web application. The view should validate the uploaded files and save them to the appropriate models in the database. The `Gallery` model is used to store images, while the `Video` model is used to store videos. You need to imp...
codefeedback
You are tasked with implementing a file server that can send parts of a file to a client upon request. The server code snippet provided below is responsible for handling client requests and sending the requested file parts. Your task is to complete the server implementation by writing the missing parts of the code. Th...
codefeedback
You are tasked with implementing a class that simulates a simple neural network layer. The layer will have the ability to store and manipulate data in the form of blobs. A blob is a multi-dimensional array used to store and process data within the neural network. Your task is to implement the `NeuralNetworkLayer` clas...
codefeedback
You are tasked with implementing a custom smart pointer class similar to `boost::shared_ptr` using C++ templates. The custom smart pointer should provide reference counting and automatic memory management features. Your task is to complete the implementation of the `CustomSharedPtr` class, which should have the follow...
codefeedback
You are tasked with simulating a simplified version of a Markov Chain Monte Carlo (MCMC) algorithm for sampling from a probability distribution. In this problem, you will implement a function to generate an initial set of MCMC walkers by perturbing an initial parameter set and checking if the perturbed parameters satis...
codefeedback
You are working on a project that involves simulating the evolution of a population of organisms. The code snippet provided is part of a Python program that uses a library called "pk3" to perform transformations on the population. The `transform_all` method is used to apply transformations to all individuals in the pop...
codefeedback
You are tasked with implementing a system for managing wallet accounts for trading and client purposes. The system involves creating wallet accounts for trades and clients, with specific attributes and relationships. Your task is to design a Django model for the wallet accounts and implement the necessary methods to en...
codefeedback
You are tasked with creating a function that generates configuration parameters for a calendar view in a mobile app. The function should take in various input parameters and return an object containing these parameters. The parameters include the start and end dates for the calendar, the number of rows to be displayed,...
codefeedback
You are given a simple state machine with three states: 0, 1, and 2. The state machine transitions between states based on the input. The transition rules are as follows: - If the current state is 0 and the input is "A", transition to state 1. - If the current state is 0 and the input is "B", transition to state 2. - I...
codefeedback
You are tasked with creating a Python function that organizes files into a destination directory based on a given playlist file. The function should take three parameters: `playlistfile` (string), `destpath` (string), and `filelist` (list of strings). The `playlistfile` represents the path to a playlist file containing...
codefeedback
You are tasked with implementing a function that takes in a list of imports and declarations from an Angular module file and returns a list of unused imports. An import is considered unused if it is not referenced in any of the declarations. You are given the following code snippet as an example of an Angular module f...
codefeedback
You are working on a project to forecast the discharge capacity of a system using time series data and a Long Short-Term Memory (LSTM) model. The given code snippet is a part of the process to forecast the discharge values. The `series_to_supervised` function is used to frame the time series training data as a supervis...
codefeedback
You are tasked with implementing a custom class loader in a C# application. The class loader should be able to load assemblies dynamically and optionally initialize their static members. Your task is to write a method that achieves this functionality. Write a C# method `CustomClassLoader` that takes the following para...
codefeedback
You are tasked with implementing a function to run a target in linearly-increasing round sizes and record the results for analysis. The function should take in the target to run, the default round size to start with, the increase in round size between rounds, and the total number of rounds to record. The function shoul...
codefeedback
You are tasked with creating a class hierarchy for a company's personnel management system. The system should be able to handle different types of employees, such as professionals, base-level employees, and clients. Each type of employee has specific attributes and behaviors that need to be captured in the class hierar...
codefeedback
You are tasked with implementing a firing sequence for a weapon system in a game development project. The provided code snippet is a part of the existing codebase for the weapon system. Your goal is to complete the implementation of the `BeginFiringSequence` function, which is responsible for initiating the firing sequ...
codefeedback
You are tasked with implementing a Trie data structure in Python. A Trie, also known as a prefix tree, is a tree-like data structure used to store a dynamic set of strings. It is commonly used for efficient retrieval of a key in a dataset of strings. Your task is to implement the `Trie` class with the following methods...
codefeedback
You are tasked with creating a program that simulates a simple test-taking scenario. The program should generate a set of random questions, prompt the user for answers, and then evaluate the user's performance. Here's a sample code snippet to get you started: ```python import random class Test: def __init__(self,...
codefeedback
You are tasked with implementing a class for reading and processing a custom file format called RSM (Random Scale Model). The RSM file format contains various data structures, including key frames for scaling and volume boxes for defining the volume of the model. The provided code snippet is a part of the implementati...
codefeedback
You are tasked with creating a command-line tool for importing development data into a system. The tool should be implemented as a Laravel Artisan command. The signature of the command is set to 'import:dev'. Your task is to write the code for the Artisan command that will handle the import of development data. Your c...
codefeedback
You are tasked with implementing a function to identify potential pairs of stars in a star catalogue that could be observed together in an image taken by a camera positioned within the solar system. The function should take into account the position of the camera and a flag indicating whether to allow a single catalogu...
codefeedback
You are tasked with implementing a Python function that processes a given file to extract specific information related to imports and a variable. Your function should read the file and return the number of GitHub stars, the imported modules, and the variable names found in the file. You are given a Python file snippet...
codefeedback
You are tasked with creating a Python function that simulates the process of reverting a virtual machine (VM) to a named snapshot using the `pyvmomi` library. The function should take the VM name and snapshot name as input parameters and handle the connection to the server, VM retrieval, and snapshot reversion process....
codefeedback
You are tasked with implementing a custom `ScalarDateTime` class in Python that can coerce input values into a standardized format. The `ScalarDateTime` class should have a method `coerce_input` that takes a single argument `val` and returns the coerced value according to the following rules: - If `val` is a string rep...
codefeedback
You are tasked with implementing a flow control algorithm for a high-speed data processing system. The system, named "Jetstream," processes a large volume of data and requires efficient flow control to prevent overload and ensure smooth operation. The provided code snippet initiates the Jetstream server and is a part o...
codefeedback
You are given a list of strings, each representing a pair of a word and a number separated by a comma. The number represents the length of the word. Your task is to sort the list based on the length of the word in ascending order. If two words have the same length, they should be sorted lexicographically. Write a fun...
codefeedback
You are tasked with designing a RESTful API for managing houses and photos. The given code snippet is a part of an Express.js router configuration for handling various HTTP requests related to houses and photos. The router is set up to handle GET, POST, and POST requests for houses and photos. Your task is to implemen...
codefeedback
You are tasked with implementing a function to validate a mnemonic string used in a cryptocurrency wallet. A mnemonic string is a human-readable representation of a cryptographic key used to access a wallet. The validation process involves converting the mnemonic string to a C string, passing it to a C function for val...
codefeedback
You are tasked with implementing a program to measure the fractal dimension of various layers in a given system. The layers are represented by sets, and the program should create an image corresponding to each layer and then measure its fractal dimension. The fractal dimension is a measure of the complexity of a fracta...
codefeedback
You are given an array `prices` where `prices[i]` is the price of a given stock on the `i`-th day, and a non-negative integer `fee` representing a transaction fee. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum...
codefeedback
You are tasked with creating a Python function that simulates a simple comment parser. Your function should take a string of Python code as input and return a list of all the commented-out lines in the code. Your function should consider both single-line comments (denoted by `#`) and multi-line comments (denoted by tr...
codefeedback
You are given a string containing a series of characters. Your task is to write a function that finds the longest substring of consecutive, non-repeating characters within the given string. If there are multiple substrings with the same length, return the first one found. If there are no non-repeating substrings, retur...
codefeedback
You are tasked with implementing a Python function that processes file paths and performs glob pattern matching. The function should take a path as input and return a modified path object with glob pattern results. Write a function `process_glob_patterns` that takes a `path` as input and returns a modified path object...
codefeedback
You are given a list of integers representing the prices of a stock on different days. Your task is to find the maximum profit that can be obtained by buying and selling the stock at most once. If it is not possible to make any profit, return 0. For example, given the list of stock prices: [7, 1, 5, 3, 6, 4], the maxi...
codefeedback
You are tasked with creating a form validation function for a web application. The function should validate the input fields based on the given HTML code snippet. The HTML code snippet represents a form input field for a phone number. The form input field has the following attributes: - Name: "no_telp" - Type: "text" ...
codefeedback
You are tasked with automating the installation process for a set of software packages using a package manager. The package manager in question is Homebrew, a popular package manager for macOS and Linux. Your goal is to write a script that installs the required packages and sets up the necessary environment variables. ...
codefeedback
You are tasked with creating a Python function that simulates the process of cloning a Git repository and removing a directory using the `shutil` module. Your function should take in a directory path, check if a specific subdirectory exists within it, and if so, remove it. Then, it should clone a specified Git reposito...
codefeedback
You are tasked with implementing a resource management system for materials in a game engine. The provided code snippet is a part of the MaterialManager class, responsible for creating and destroying material resources. Your task is to complete the MaterialManager class by implementing the destroyResource function and...
codefeedback
You are tasked with implementing a generic visitor pattern in C#. The visitor pattern is a behavioral design pattern that allows adding new behaviors to existing classes without altering their structure. In this problem, you are required to create a generic visitor interface and implement it in a class hierarchy. Your...
codefeedback
You are tasked with implementing a function that takes a dictionary of words and returns the longest word that can be constructed by concatenating other words in the dictionary. If there are multiple longest words, the function should return the first one in lexicographical order. The function signature is: ```python ...
codefeedback
You are tasked with creating a function that parses and extracts information from a given HTML code snippet. The HTML code snippet represents a confirmation message for deleting a specific item from a library. The function should extract the name of the item to be deleted and the associated message, and then return the...
codefeedback
You are tasked with implementing a class for user authentication in a social media platform. The class, `Auth`, is designed to handle account access restoration using a code received via SMS. The class is a part of a larger system and is initialized with a `VkApiClient` instance. The `Auth` class extends a superclass t...
codefeedback
You are tasked with implementing a simplified version of a promise-based asynchronous operation in Swift. You are given a ViewModel class that interacts with a repository to toggle the favorite state of a certificate identified by its `id`. The ViewModel uses the PromiseKit library to handle asynchronous operations. Yo...
codefeedback
You are tasked with creating a program to manage a library's book inventory. The program should allow librarians to add, remove, and update books in the inventory. Additionally, it should provide functionality to search for books by title, author, or category. To achieve this, you need to implement a class called `Libr...
codefeedback
You are tasked with implementing a test suite for a Java application using JUnit. The test suite should cover various classes and methods within the application. The code snippet provided contains a list of test classes that need to be included in the test suite. Your task is to write a JUnit test suite that includes a...
codefeedback
You are tasked with implementing a function to extract specific information from an array of `HtmlEntities` objects. Each `HtmlEntities` object contains an array of `Content` and optional `Pageable` properties, along with other metadata. You need to create a function `extractContentByPage` that takes in an array of `H...
codefeedback
You are tasked with creating a Swift protocol for validating a specific type of data. The protocol should include a property `isValid` that returns a boolean value indicating whether the data meets certain validation criteria. Your goal is to implement a concrete type that conforms to this protocol and provides a meani...
codefeedback
You are tasked with implementing a date formatting utility in Java. The provided code snippet includes a regular expression pattern for matching dates in the format "YYYY-MM-DD" and a method signature for formatting a Date object. Your task is to complete the implementation of the `format` method to return a string rep...
codefeedback
You are tasked with creating a custom property drawer for a specific type in Unity. The custom property drawer should be designed to handle a reference to a boolean variable. Your task is to implement the custom property drawer class for the `BoolReference` type, ensuring that it visually represents the boolean referen...
codefeedback
You are tasked with implementing a Pet Management System using Java. The system should allow for the management of pets, including adding new pets, retrieving pets by owner ID, and searching for pets by their unique ID. You are provided with a partial implementation of the PetService class, which interacts with a PetRe...
codefeedback
You are tasked with creating a command-line utility for generating text using a Markov chain model. The utility should accept various command-line arguments to customize its behavior. Your task is to implement the `parse_args` function to parse the command-line arguments using the `argparse` module in Python. The `par...
codefeedback
You are tasked with implementing a custom asynchronous context manager in Python. An asynchronous context manager is a special type of object that can be used with the `async with` statement to manage asynchronous resources. Your task is to create a class that can be used as an asynchronous context manager and handles ...
codefeedback
You are tasked with implementing a method to parse a string representation of a decimal number into its corresponding decimal value. The method should handle both whole numbers and numbers with decimal points. You are provided with a partial code snippet for the method `ParseStringToDecimal` as a starting point. The `...
codefeedback
You are tasked with creating a Django model for a customer database. The model should include fields for customer information and preferences. One of the fields should be a boolean field to indicate whether the customer's address should be ignored. Your task is to define the Django model with the required fields and th...
codefeedback
You are working on a project to develop a trajectory filter for a particle tracking system. The filter is designed to process subcluster shapes in a particle detector and make decisions based on certain criteria. Your task is to implement a function that takes the configuration parameters for the trajectory filter and ...
codefeedback
You are tasked with implementing a custom layout for a collection view in a mobile app. The collection view displays cells in a horizontal scrolling manner. The goal is to adjust the content offset of the collection view such that a specific target cell is centered after the user finishes scrolling. The given code sni...
codefeedback
You are tasked with implementing a custom data structure in C# that mimics the functionality of a stack, but with an added feature of tracking the minimum element in the stack at any given time. You need to create a class `MinStack` that supports the following operations: 1. `Push(int x)`: Add element x to the top of t...
codefeedback
You are tasked with implementing a class that manages access policies for a vault in Azure Active Directory. The class should handle input validation and provide a way to store and retrieve object IDs for users, service principals, or security groups. Your task is to create a method that adds a new access policy to the...
codefeedback
You are tasked with creating a Python script that simulates a simple banking system. The script should allow users to create accounts, deposit and withdraw funds, and check their balance. The script should also handle cases where users attempt to withdraw more funds than they have in their account. Your task is to imp...
codefeedback
You are tasked with creating a Python function that merges the messages from a source Catalog into a .po file at the specified target location. The source Catalog is a dictionary where the keys are message identifiers and the values are the corresponding message strings. The .po file format is commonly used for storing...
codefeedback
You are tasked with implementing a Python class to represent a frequency scale for musical tones. The class should provide methods to calculate the frequency range, the number of cents per value, and to convert frequencies to cents. You are given the following code snippet as a starting point: ```python piano_min = 2...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit money, withdraw money, and check their balance. The program should also handle multiple accounts and ensure that each user can only access their own account. You are provided with t...
codefeedback
You are tasked with implementing a Python class that represents a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should keep track of the account holder's name and account number. Your task is to complete the implemen...
codefeedback
You are tasked with creating a middleware function for a web framework that enforces trusted hosts for incoming requests. The middleware should only allow requests from specified hosts and reject requests from untrusted hosts. Your goal is to implement the `trusted_hosts_middleware` function and ensure that it correctl...
codefeedback
You are tasked with implementing a function to draw a set of line hypotheses for a batch of images. The function `draw_hyps` takes in three parameters: `labels`, `scores`, and an optional parameter `data`. The `labels` parameter represents the line parameters and is an array of shape (NxMx2), where N is the number of ...
codefeedback
You are tasked with creating a Python class that simulates a simple platformer game character. The class should handle movement, gravity, and collision detection with platforms. Your task is to implement the missing methods and attributes of the class based on the given code snippet and requirements. The provided code...
codefeedback
You are tasked with implementing an HTTP encoding interface in Java. The interface, `Encoding`, represents an arbitrary HTTP encoding and can be used for request encoding in a client API or for handling encoded requests in a server API. An implementation of this interface should provide the ability to wrap an `OutputSt...
codefeedback
You are tasked with implementing a simplified version of a CPU opcode handler for the ARMv6 architecture. The provided code snippet is a Python class `UbfxT1` that inherits from `Ubfx` and `Opcode`. The `Ubfx` class represents the "Unsigned Bit Field Extract" operation, and the `Opcode` class represents a generic CPU o...
codefeedback
You are tasked with implementing a function to generate a SHA-1 hash of a given input string using the Boost C++ library. The SHA-1 algorithm produces a 160-bit (20-byte) hash value known as a message digest. Your task is to create a C++ function that takes a string as input and returns its SHA-1 hash as a hexadecimal ...
codefeedback
You are tasked with creating a function that extracts the IP address and port from a given `CLUSTER_ADDR` string based on the provided code snippet. The `CLUSTER_ADDR` can be in one of two formats: IPv6 or IPv4 with a port number. The IPv6 format is enclosed in square brackets, while the IPv4 format is a standard dotte...
codefeedback
You are working on a data analysis project related to quasars (QSOs) and need to write a function to analyze the restframe ranges of wavelengths for a given QSO dataset. The code snippet provided is a part of the function that performs this analysis. Your task is to complete the function by implementing the logic to ca...
codefeedback
You are given a list of differences `diffs` containing tuples of integers `(o, s)`. Additionally, you are given an integer `N`. The code snippet provided initializes a list `out` with `N+1` elements, where the first element is 1 and the rest are 0. Then, it iterates through the elements of `diffs` and updates the eleme...
codefeedback
You are tasked with creating a Python package for a scientific research project. The package, named "naima," will contain various modules and data files. Your goal is to set up the package configuration using the `setuptools` library to ensure that the package is properly structured and can be easily installed by other...
codefeedback
You are tasked with implementing a function to remove a member from a group in a social networking application. The application uses a client-side API to manage users and groups. The code snippet provided is a part of the test suite for this functionality. The `client` object is used to interact with the API and perfor...
codefeedback
You are tasked with creating a script to automate the deployment and testing process for a web application. The script should perform the following tasks in sequence: 1. Change the directory to `/home/wwwroot/aos`. 2. Run the command `/usr/local/bin/composer install --no-interaction` to install the necessary dependenc...
codefeedback
You are tasked with creating a Python function that processes a serialized data structure stored in a file and performs specific operations on the deserialized data. The function should handle potential file I/O errors and ensure the proper handling of the deserialized data. You are given the following code snippet as...
codefeedback
You are given a code snippet that involves the usage of a custom data type `Fp` and its extension `Fp2`. The code snippet also includes assertions to test the behavior of the `sgn0` method of the `Fp2` type. Your task is to understand the behavior of the `sgn0` method and implement it in the `Fp2` type. The `Fp` type ...
codefeedback
You are given a 2D boolean array `table` of size `xSize` by `ySize`. The array represents a table with cells that can be either true (1) or false (0). Your task is to implement a function that creates a new 2D boolean array `toReturn` of the same size, where each cell is the logical OR of the corresponding cells from t...
codefeedback
You are tasked with implementing a frame source management system for a video processing application. The system should support two types of frame sources: video files and camera input. The provided code snippet includes a partial implementation of the frame source management system using OpenCV's super resolution modu...
codefeedback
You are working for a data analysis company that specializes in visualizing crime data. Your task is to create a program that generates a line plot to visualize the monthly counts of crime victims based on victim types. The data is provided in a CSV file named "crime_data.csv", which contains the following columns: "da...
codefeedback
You are tasked with creating a Python program that utilizes the `multiprocessing` module to spawn multiple processes to perform a specific task. Your program should create a number of processes, each of which will execute a function called `work`. The `work` function takes an identifier as an argument and prints a mess...
codefeedback
You are working on a file management system and need to automate certain tasks using shell scripting. Your task is to write a shell script that performs the following operations: 1. Delete all empty files in the current directory and its subdirectories. 2. Delete all empty directories in the current directory and its ...
codefeedback
You are tasked with creating a Rust function that processes and sends internal metrics. The function receives a `ticker` that generates events, a `recorder` that captures metrics, and an `output` channel to send the captured metrics. The function should continuously process the incoming events, capture metrics, and sen...
codefeedback
You are tasked with implementing a Python class for the Makwa cryptographic hash function. Makwa is a cryptographic hash function designed for password hashing and key derivation. It is based on the RSA trapdoor permutation and is resistant to quantum attacks. Your task is to implement the `_digest` method of the `Makw...
codefeedback
You are tasked with implementing a method to parse a JSON string representing multiple seasons of a TV show and create a collection of Season objects. Each Season object should contain information about the season number, episode count, and average rating of the season. The JSON string is in the following format: ```js...
codefeedback
You are tasked with implementing a function that extracts the package name from a given code snippet written in Japanese. The package name is enclosed within double quotes and is followed by the comment "のテストコード群パッケージです。" (which translates to "test code package for View(WebAPI)"). Your task is to write a function that ...
codefeedback
You are tasked with implementing a command-line argument parser for a home automation web server. The provided code snippet includes a partial routing configuration for the web server and a function for parsing command-line arguments using the `argparse` module. Your task is to extend the command-line argument parser ...
codefeedback
You are given a C++ code snippet that performs some operations on an array `div` and prints the result to the standard error output. Your task is to understand the code and implement a function that replicates the same operations on an input array and returns the modified array. The given code snippet performs the fol...
codefeedback
You are tasked with creating a function that processes a file upload and updates the details of a ministry. The function should handle different scenarios and provide appropriate messages based on the outcome of the file upload and ministry details update. You are given a code snippet from a PHP class method that hand...
codefeedback