instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a multi-objective optimization algorithm for a given set of non-dominated solutions. The algorithm should be able to handle different types of objectives and efficiently select the most effective solutions for a given menu size. You are given a Python function snippet that takes in th...
codefeedback
You are tasked with creating a script to convert Neuroimaging Informatics Technology Initiative (NIfTI) files to MINC (Medical Imaging NetCDF) format using a specific command-line tool. The script should take a directory path as an argument and convert all NIfTI files within that directory to MINC format using the prov...
codefeedback
You are tasked with implementing a function that calculates the resulting shape of a tensor operation. The function takes two input shapes, representing the dimensions of the left-hand side (LHS) and right-hand side (RHS) tensors, and returns the resulting shape after the operation. The input shapes are represented as...
codefeedback
You are tasked with implementing a function to perform a smoothing operation on a given list of numbers. The function `my_smooth(x, N)` takes two parameters: `x`, a list of numbers, and `N`, an integer representing the window size for smoothing. The smoothing operation involves replacing each element in the list with t...
codefeedback
You are tasked with implementing a Java class that validates ISBN-10 numbers using the Modulus 11 check digit calculation. An ISBN-10 number is a 10-digit numeric code, with the last digit being a check digit. The check digit is calculated based on the first 9 digits of the ISBN-10 number. The check digit is calculate...
codefeedback
You are tasked with implementing a Java program to manipulate and transform data using the Builder design pattern. The program should involve creating a builder for a specific data type and using it to modify an instance of that type. You are given a partial code snippet that involves using a builder to modify an inst...
codefeedback
You are working on a project management system that involves retrieving the status of work orders from a customer API. The provided code snippet is a part of a Python program that defines a `StatusCommand` class responsible for retrieving the work order status. The `setup` method sets up the command-line arguments for ...
codefeedback
You are working on a quantum computing simulation project and need to implement a function to calculate the excited state population of a qubit over time. The excited state population is given by the formula: \[ P(t) = 0.5 \times e^{-(0.00001 \times (decayRateSM + 1) \times 2 + 1j) \times 50 \times t} \] You are prov...
codefeedback
You are tasked with implementing a simplified version of a message-passing system using Rust. The system consists of a sender and a receiver, where the sender can send a message to the receiver. Additionally, the receiver can clone itself to create multiple receivers, and the sender can clone itself to create multiple ...
codefeedback
You are tasked with creating a Python class that can analyze the inheritance hierarchy of classes within a given module. Your class should provide a method to identify the subclass that has the highest level of inheritance from a specified base class. Create a Python class `ClassAnalyzer` with the following requiremen...
codefeedback
You are tasked with implementing a test suite for a file importer in the Magnum Trade library. The test suite includes a struct `StanfordImporterTest` that inherits from `TestSuite::Tester`. The struct contains several member functions for testing different aspects of the Stanford file importer. Your goal is to impleme...
codefeedback
You are tasked with creating a Python function that calculates the equilibrium speed of sound for a gas using the Cantera library. Cantera is an open-source suite of tools for problems involving chemical kinetics, thermodynamics, and transport processes. The function will take a Cantera `Solution` object representing t...
codefeedback
You are tasked with creating a Python class that represents a notification and a schema for serializing and deserializing notification objects using the Marshmallow library. Your task is to implement the `Notification` class and the `NotificationSchema` class using the Marshmallow library. The `Notification` class sho...
codefeedback
You are tasked with creating a Python class that manages the extraction of datasets from compressed files. Your class should provide a method to extract the dataset from a given URL and store it in a specified root directory. Additionally, the class should have a method to check the existence of the extracted dataset. ...
codefeedback
You are tasked with simulating a publishing proposal system for a test-taking platform. The system involves creating a proposal for publishing a test, which includes setting a passing score and proposing individual questions for inclusion in the published test. Additionally, the system involves user authentication and ...
codefeedback
You are tasked with creating a Python program that reads a list of student names and their corresponding scores from a file, calculates the average score for each student, and writes the results to a new file. The input file will contain the student names and their scores in the following format: ``` Alice 85 Bob 90 Ca...
codefeedback
You are tasked with implementing a custom page view controller in Swift. The page view controller consists of two main components: `PageContentView` and `PageTitleView`. The `PageContentView` is responsible for displaying the content of each page, while the `PageTitleView` displays the titles of the pages and allows th...
codefeedback
You are tasked with implementing a Python class to represent a checkerboard for a game. The class should have methods to initialize the board, place pieces on the board, move pieces, and check for a winner. The board should be represented as an 8x8 grid, and the pieces should be represented as 'X' for player 1 and 'O' ...
codefeedback
You are tasked with implementing a Java method that retrieves the values of an object's properties, including those inherited from its parent classes. The method should be able to handle any type of object and return a map containing the property names and their corresponding values. You are given the following code s...
codefeedback
You are tasked with creating a Python class that simulates a simple database management system. The class, named `SimpleDB`, should support basic operations such as creating a database, inserting data, querying data, and deleting data. The database will store key-value pairs, where the key is a string and the value is ...
codefeedback
You are tasked with creating a Minecraft mod that adds a new feature to the game. The mod should allow players to collect resources from specific locations and store them in a virtual inventory. To achieve this, you need to implement a custom event handler that listens for a server starting event and then processes the...
codefeedback
You are tasked with creating a program that simulates a simple dependency resolution system for a software project. The project consists of multiple targets, each with its own set of dependencies. The dependencies are represented as a directed acyclic graph (DAG), where each target can depend on zero or more other targ...
codefeedback
You are working on a metadata management system for a distributed messaging platform. The system uses a metadata node manager to handle various metadata records, such as partition records and broker records. The metadata is organized in a hierarchical structure, and the system uses a JSON format for serialization and d...
codefeedback
You are tasked with implementing a Java class that extends a base class and incorporates a scaled induction variable. An induction variable is a variable that increments by a constant amount in a loop. Your task is to complete the implementation of the `DerivedScaledInductionVariable` class by adding the necessary func...
codefeedback
You are given a list of candidate numbers `candidates` and a target number `target`. Write a function `combinationSum` to find all unique combinations of candidates where the candidate numbers sum to the target. Each number in `candidates` may only be used once in the combination. The function should return a list of...
codefeedback
You are given a list of units, each represented by a list containing three elements: the unit's name, its size, and its current position. The position is represented by an integer that ranges from 0 to the size of the unit minus 1. Your task is to implement a function that updates the position of each unit based on a g...
codefeedback
You are tasked with implementing a custom file handling system in Java. The system should include a class `ItemFile` that represents a file and provides methods for reading, writing, and manipulating the file's content. The `ItemFile` class should have the following functionalities: 1. A constructor that takes a file p...
codefeedback
You are tasked with implementing a Python function that extracts non-private, non-abstract attributes from an object's dictionary. The function should take an object as input and return a dictionary containing the non-private, non-abstract attributes of the object. You are provided with a code snippet that demonstrate...
codefeedback
You are tasked with implementing a class that manages the leasing of assets. The class, `LeaseManager`, should have a method to assign a lessee to an asset and another method to retrieve the lessee's ID for a given asset. You need to implement the following methods in the `LeaseManager` class: 1. `AssignLessee(long a...
codefeedback
You are tasked with implementing a dice rolling function in Rust. The function should take in a `DiceData` struct containing the number of dice and the sides of each die, and return the result of rolling those dice. The `DiceData` struct is defined as follows: ```rust pub struct DiceData<T> { pub num_dice: usize, ...
codefeedback
You are tasked with implementing a custom property wrapper in Swift that will monitor the number of tasks added to a list and notify when a threshold is reached. The property wrapper should also provide a subscription mechanism for external monitoring. Your task is to complete the implementation of the custom property...
codefeedback
You are tasked with implementing a custom list widget for a user interface. The provided code snippet is a part of a larger program that aims to create a graphical user interface (GUI) for an address frame. The `Ui_AddressFrame` class contains a method `setupUi` that initializes the graphical elements of the address fr...
codefeedback
You are tasked with implementing a function to process flight data for a travel agency. The flight data is represented as a series of headers and values, and the function needs to encode this data using a specific header table size and return the encoded data. You are given the following code snippet as a starting poi...
codefeedback
You are tasked with implementing a timer class that measures the execution time of specific operations within a larger program. The timer class should be able to start and stop the timer, and provide the elapsed time when stopped. Additionally, you need to create a function to assemble a Jacobian matrix using the timer...
codefeedback
You are tasked with creating a Python program that configures logging for a fictional application. The provided code snippet is a partial configuration for the Python logging module. Your task is to complete the configuration by adding a console handler and a custom formatter. Your program should achieve the following...
codefeedback
You are tasked with implementing a feature for a web application that allows an admin user to log in to their account using GitHub authentication. The application is built using the Laravel framework, and the authentication logic is handled by the `GithubLoginController` class, which extends the Laravel `Controller` cl...
codefeedback
You are tasked with creating a simple task manager program that can execute various tasks. The program should be able to handle multiple tasks and execute them in a sequential manner. Your task is to implement the `TaskManager` class with the following specifications: - The `TaskManager` class should have a method `ad...
codefeedback
You are tasked with implementing a function to parse a configuration file in a specific format. The configuration file contains sections marked with a special syntax, and each section may contain multiple key-value pairs. Your task is to write a function that can parse the configuration file and return the data in a st...
codefeedback
You are tasked with implementing a function to calculate the minimum radius for rounding the corners of a rectangle. The function should take the height and width of the rectangle as input and return the minimum radius required to round the corners such that the rounded corners do not exceed one-sixth of the rectangle'...
codefeedback
You are tasked with implementing a custom assertion library in TypeScript. Your library should provide a set of assertion functions for validating different types of conditions in a test suite. The `export = Assert;` statement at the beginning of the code snippet indicates that the entire module is being exported as a ...
codefeedback
You are tasked with creating a function that generates a rounded rectangle path for a given text container size, corner radius, border width, and specified corners. The function should use the provided code snippet as a reference to create a UIBezierPath object representing the rounded rectangle. The function signatur...
codefeedback
You are tasked with implementing a simple reactor management system for a nuclear power plant simulation. The system should allow for the addition, removal, and disposal of reactors. Reactors are represented by instances of the `Reactor` class, which has a unique identifier and a disposal method. Your task is to imple...
codefeedback
You are tasked with creating a Python function that takes a list of pandas Timestamp objects and a timezone as input and returns the count of days between each consecutive pair of timestamps, considering the time zone. The count of days should exclude weekends (Saturdays and Sundays). Assume that the input list is sort...
codefeedback
You are tasked with implementing a class in C++ to handle the Association Request (AAssociateRQ) in the context of DICOM (Digital Imaging and Communications in Medicine) communication protocol. The provided code snippet is a part of the class definition and includes member variables and methods related to the AAssociat...
codefeedback
You are tasked with implementing a version control system for a software development project. The system should support features such as saving backups of the current state, managing active/inactive status, and handling narrow specifications for version control. Your task is to create a Python class `VersionControlSys...
codefeedback
You are tasked with implementing a Java class for querying databases. The class, `VannoQuery`, is designed to handle querying a list of databases and performing either a regular query or a count query based on a boolean flag. Your task is to complete the implementation of the `VannoQuery` class by adding the necessary ...
codefeedback
You are tasked with implementing a method to calculate the total amount of an invoice based on the items and their quantities. The `InvoiceCommandResults` class contains a list of `InvoiceItem` objects, each representing an item on the invoice. Each `InvoiceItem` has a `Name` property representing the item's name and a...
codefeedback
You are tasked with implementing a file processing algorithm for a file system represented as a tree structure. The tree consists of nodes representing directories and files. Each directory node may contain subdirectories (subtrees) and files (blobs). Your task is to traverse the tree and process each file in the tree ...
codefeedback
You are tasked with creating a program that analyzes a given text to determine the frequency of each word. For the purpose of this problem, a word is defined as a sequence of non-whitespace characters. The program should ignore punctuation and consider words in a case-insensitive manner. The output should display each ...
codefeedback
You are working on a robotics project that involves parsing and processing sensor data from various sources. One of the data formats you encounter is a text-based configuration file that contains information about camera parameters, sensor noise, and stereo camera measurements. Your task is to write a parser function t...
codefeedback
You are tasked with creating a Python program that processes a text file to generate a word frequency dictionary. Your program should read a text file, clean the text by removing symbols and converting all words to lowercase, and then count the frequency of each word. Additionally, the program should be able to filter ...
codefeedback
You are tasked with implementing a custom filter function in Python for encoding URLs. The filter function should take a string as input and return the second last segment of the URL after splitting it by '/'. For example, if the input string is "https://www.example.com/blog/article", the filter function should return ...
codefeedback
You are working on a chatbot application that processes messages in a group chat. The chatbot is designed to detect when it is mentioned in a message and respond accordingly. Your task is to implement a function that processes incoming messages and modifies them if the chatbot is mentioned. You are given a code snippe...
codefeedback
You are tasked with implementing a custom string manipulation function that processes input strings based on a specific pattern. The function should identify and extract substrings that start with the sequence "!@[" and end with the sequence "]". The extracted substrings should then be concatenated together in the orde...
codefeedback
You are tasked with creating a program that can extract email addresses from a given text. Your program should take a string as input and return a list of unique email addresses found within the input string. An email address is defined as a string of the form "username@domain.com" where both the username and domain ca...
codefeedback
You are tasked with implementing a version comparison function that compares two software version numbers represented as strings. The version numbers are non-empty and contain only digits and the '.' character. The comparison should follow the standard lexicographical ordering, where a smaller version number comes befo...
codefeedback
You are tasked with creating a program that simulates a network packet processing system. The program should be able to handle various types of Internet Control Message Protocol version 6 (ICMPv6) packets and perform appropriate actions based on the packet type. The given code snippet includes multiple Rust files, eac...
codefeedback
You are tasked with implementing a class that manages a search operation and handles the cancellation of the search task. The class should utilize the Observer pattern to listen for a specific notification and cancel the ongoing search task when the notification is received. Your task is to complete the implementation...
codefeedback
You are tasked with implementing a class that represents the status and reason for a target. The class should have properties for the status, whether the status is specified, the reason, and whether the reason is specified. Additionally, the class should support XML serialization with specific attributes. Your task is...
codefeedback
You are tasked with implementing a function that formats a list of components and their quantities into a human-readable string. The function should take a map of component names (strings) to their quantities (integers) and return a formatted string representing the components and their quantities. The provided code s...
codefeedback
You are given a code snippet that contains a class, a struct, and a generic type constraint. Your task is to analyze the code and identify the potential issues or errors present in the code snippet. Based on your analysis, you need to explain the errors and propose the necessary corrections to make the code syntactical...
codefeedback
You are tasked with developing a Python script to process medical imaging data for a research project. The script should utilize command-line arguments to specify input and output folders, as well as additional parameters for image processing. The script should be able to handle the following command-line arguments: -...
codefeedback
You are tasked with creating a number guessing game where the computer attempts to guess a secret number chosen by the user. The computer will make educated guesses based on the user's responses. The user will provide feedback after each guess, guiding the computer to the correct number. The computer will use a binary ...
codefeedback
You are tasked with implementing a function to write a ClassAd (Classified Advertisement) to a file in the context of a job scheduling system. A ClassAd is a data structure used in the HTCondor job scheduler to represent job requirements, attributes, and constraints. The function should handle error checking and loggin...
codefeedback
You are tasked with implementing a data processing algorithm for a business intelligence application. The algorithm needs to parse and format unique names of data elements based on certain rules. The unique names are represented as strings and may contain special characters and placeholders. Additionally, the algorithm...
codefeedback
You are tasked with creating a Python function that facilitates the deployment of files to a remote server using SSH. The function `ssh_deploy` takes in several parameters and prints out deployment details. Your task is to implement the `ssh_deploy` function and ensure that it correctly handles the provided parameters....
codefeedback
You are tasked with implementing a notification system for a web application using Python's asyncio library. The provided code snippet is a part of a WebSocket consumer class that handles different types of notification events. The class contains two asynchronous methods: `notification_dismiss` and `notification_reset`...
codefeedback
You are tasked with implementing a simple message-passing system using Rust's enum and struct types. The system should allow sending and receiving messages between different components of a program. You are provided with a partial code snippet that defines a Rust enum `Msg` and a comment indicating the start of a new...
codefeedback
You are tasked with creating a Python program that processes command-line arguments for a file encryption utility. The program should accept two command-line arguments: one for the path to the file to be encrypted and another for the path to the log file. The program should then perform the encryption process and log t...
codefeedback
You are working on a web application that manages donations of goods. The code snippet provided is from a PHP controller file that retrieves data from a database and passes it to a view for display. The `$row` object contains information about a donation, including the donor's photo (`foto_donatur`) and the status of t...
codefeedback
You are tasked with creating a Python function that simulates a quantum circuit using the Qiskit framework. The function should take in a quantum circuit, number of shots, and optional parameters for memory, seed, and noise model. The quantum circuit is represented as a list of gates and measurements, and the function ...
codefeedback
You are tasked with implementing a Django view function that handles image uploads and resizing. The view function should accept an image file, validate its content type, and resize it if its width exceeds a certain limit. You are provided with the following code snippet as a starting point: ```python from django.conf...
codefeedback
You are given an associative array representing regions in Romania, where the keys are the region codes and the values are arrays containing the region name and level. The level can be either "county" or "city". Your task is to write a function that takes this array as input and returns an array of region names for all...
codefeedback
You are tasked with implementing a function that creates and saves tenant objects to a database. The function should accept a property ID and a list of staff IDs as input, and return a generator that yields a function for creating and saving tenant objects. The function should be designed to work within a larger syste...
codefeedback
You are tasked with implementing a custom serialization and deserialization mechanism for a simplified version of a Twitter-like application. The provided code snippet is a part of a Python class that represents a tweet object. The class uses a custom field system for managing tweet attributes and a nested object for t...
codefeedback
You are tasked with creating a script to manage experiment features for a machine learning model. The script will handle the creation and cleanup of necessary files and directories based on the status of the experiment. You are given a code snippet from the existing script, which includes variable assignments and cond...
codefeedback
You are tasked with creating a script to automate the process of updating a specific command within a file and then removing the backup file created during the update process. You are given a file named `main.go` containing various commands, and you need to update a specific command within it. The command to be update...
codefeedback
You are tasked with creating a Python unit test for a function that submits a feature categorical grid coverage (FCGC) using the pyGDP library. The function to be tested is part of a larger geospatial data processing application. Your task is to write a unit test that ensures the FCGC submission function behaves as exp...
codefeedback
You are tasked with creating a script to automate the process of updating a local Git repository to the latest state of the remote repository. Your script should perform the following steps: 1. Set the locale to "C" for consistent behavior across different systems. 2. Fetch all objects from the remote repository, conv...
codefeedback
You are tasked with creating a C++ program that utilizes the Boost.Process library to execute a command-line process and capture its output. Your program should take a command as input from the user, execute the command using Boost.Process, and then display the output of the command to the user. Your program should fo...
codefeedback
You are given a list of integers representing the daily stock prices of a company. You need to write a function `max_profit` 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. The function should take in the following parame...
codefeedback
You are tasked with creating a program that processes an image using the OpenCV library in Python. Your program should read an image file, convert it to grayscale, and then display both the original and grayscale images. Additionally, you need to calculate and display the average pixel intensity of the grayscale image....
codefeedback
You are given an array `a` of `n` integers. Your task is to determine whether it is possible to partition the array into two subsets such that the sum of elements in each subset is equal. If such a partition is possible, return `true`; otherwise, return `false`. You need to implement the following function: ```cpp bo...
codefeedback
You are tasked with creating a Python function that simulates a simplified version of a cycle loss calculation in a machine learning model. The provided code snippet is a part of a larger program that involves calculating cycle loss for two different sets of data, A and B. The cycle loss is calculated using a function ...
codefeedback
You are tasked with creating a Django web application for managing a blog platform. The provided code snippet is a part of the URL configuration in Django, which maps URL patterns to corresponding views. Your task is to implement the view functions for the blog-related URLs and handle the necessary operations. You nee...
codefeedback
You are tasked with implementing a simple 2D point class in C++. The class should have the following functionalities: 1. A constructor that takes two integer parameters x and y and initializes the point. 2. A method to calculate the distance between two points. 3. A method to calculate the distance from the point to th...
codefeedback
You are tasked with designing a message-passing system for a multiplayer game server. The server uses the Actix framework, a popular actor framework for Rust. Actix provides a message-passing mechanism for communication between actors. In this scenario, we have a `Player` actor that needs to send a message to the `serv...
codefeedback
You are tasked with implementing a secure configuration parser for a Python application. The `CryptoConfigParser` class is a subclass of the standard `ConfigParser` and is designed to handle encrypted configuration files. The class has an additional feature to decrypt values using a provided encryption key. Your task ...
codefeedback
You are tasked with implementing a function to parse and extract data from an HTML snippet. The HTML snippet contains a series of nested `<div>` elements, and your goal is to extract the number of nested `<div>` elements and the number of `<div>` elements with a specific class attribute. You are given the following HT...
codefeedback
You are tasked with creating a reinforcement learning agent to solve the classic "MountainCar" problem using the OpenAI Gym library. The "MountainCar" environment is a 2D continuous space where a car is tasked with reaching the top of a hill. However, due to gravity, the car is not powerful enough to reach the goal dir...
codefeedback
You are tasked with implementing a simple jQuery plugin that creates a customizable countdown timer. The plugin should allow users to specify the target date and time for the countdown, as well as customize the appearance and behavior of the timer. Your task is to create a jQuery plugin called `countdownTimer` that ca...
codefeedback
You are working on a machine learning pipeline for predicting customer churn in a telecom company. The pipeline consists of several stages: data cleaning, feature engineering, data preparation, and prediction. Each stage is performed by calling a function from a module called `pipeline`. The `get_prediction` function t...
codefeedback
You are tasked with implementing a custom asynchronous stream in Rust. The stream will produce a sequence of `Bytes` objects and will support both polling and cancellation. Your task is to implement the `CustomStream` struct, which will act as an asynchronous stream. The `CustomStream` should have the following method...
codefeedback
You are working on a project that involves generating and building databases for geospatial imagery processing. The `genewdatabase` command is used to generate a new database, and the `gebuild` command is used to build the generated databases. Each database is identified by a unique name and is associated with a specif...
codefeedback
You are tasked with implementing a function that retrieves the expiration time from a given context. The function takes in a pointer to the context and a boolean flag indicating whether to retrieve the expiration time. If the flag is set to TRUE, the function should return the expiration time; otherwise, it should retu...
codefeedback
You are given a positive integer `n`. Your task is to write a function `countDigitOnes(n)` that counts the number of digit ones in the decimal representation of `n`. For example, if `n = 11123`, the function should return `4` because there are four occurrences of the digit `1` in the number `11123`. Write a function ...
codefeedback
You are given a code snippet that seems to contain some encrypted messages. Your task is to decipher the messages and extract the meaningful information from the given data. The code snippet provided contains a series of characters and some placeholder text denoted by `<KEY>`. The encrypted messages are interspersed w...
codefeedback
You are tasked with creating a program that simulates a simplified version of a file compression algorithm. The algorithm will take a string as input and compress it by replacing consecutive repeated characters with a single instance of the character followed by the number of repetitions. For example, the string "aaabb...
codefeedback
You are tasked with implementing a Java class that handles the completion of frames in a network communication protocol. The provided code snippet is a part of a class that includes a private inner class `FrameCompletionHandler` implementing the `CompletionCheck` and `CompletionHandler` interfaces. The `FrameCompletion...
codefeedback
You are tasked with implementing a C++ class that manages socket connections. The class, named `SocketManager`, should have the following functionalities: 1. Create a Unix domain socket for local communication if the input parameter `isLocal` is true. 2. Create an Internet domain socket for network communication if the...
codefeedback