instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a program that simulates a simple game of dice. The game consists of rolling two six-sided dice and calculating the sum of the two dice values. The game continues until the user decides to stop playing. At each turn, the program should display the sum of the dice values and ask the user...
codefeedback
You are tasked with implementing a simple banking system using Python. Your goal is to create a class `BankAccount` that allows users to withdraw and deposit funds into their account. The class should have methods `withdraw` and `deposit` to handle these operations. Additionally, you need to implement a feature that al...
codefeedback
You are tasked with implementing a state machine to manage the sending of SMS messages in a messaging application. The state machine should handle the process of sending restored messages after a system failure. The state machine has a method `SendSMS` that takes a `restored_message` as a parameter and sends the messag...
codefeedback
You are working for a cloud infrastructure company that provides domain management services. Your task is to create a program that generates a unique domain name and then uses an API to create the domain in the system. The code snippet provided is a part of the script that accomplishes this task. Your program should p...
codefeedback
You are tasked with creating a C# program that utilizes the System.Management.Automation namespace to execute PowerShell commands and retrieve the output. Your program should prompt the user to input a PowerShell command, execute the command using C#, and then display the output of the executed command. Your program s...
codefeedback
You are tasked with creating a script to deploy a CloudFormation stack using the AWS Command Line Interface (CLI). The script should take in various parameters and execute the deployment in a specific AWS region. You need to write a Bash script that takes the following parameters: - `STACK_NAME`: The name of the Cloud...
codefeedback
You are given a Python code snippet that involves the use of NumPy and some custom functions. Your task is to create a problem related to computational geometry and NumPy manipulation based on the given code snippet. Write a function that takes a set of 2D points as input and calculates the area of the convex hull for...
codefeedback
You are tasked with creating a middleware function for an API in a Node.js application using the NestJS framework. The middleware should enforce authentication for all requests to the "Assets" endpoint. The provided code snippet is a starting point, indicating that the "Assets" endpoint is tagged with "Assets" and that...
codefeedback
You are tasked with implementing a Python function that processes a given matrix and performs a specific operation on it. The function should handle numerical errors and utilize the `numpy` library for matrix operations. Write a function `process_matrix(A, B)` that takes in two parameters: - `A`: a 2D numpy array repr...
codefeedback
You are tasked with implementing a Python function that takes a list of URLs as input and returns a dictionary containing the unique domain names as keys and the count of occurrences as values. The domain name should be extracted from the URLs, and any subdomains or paths should be ignored when counting occurrences. F...
codefeedback
You are tasked with implementing a function to perform rejection of outliers in a given array of data. The function should utilize the "sigclip" method for rejection, which involves iteratively clipping outliers based on a specified number of standard deviations from the mean. Additionally, the function should allow fo...
codefeedback
You are working on a bioinformatics project and need to manipulate data from RNA and DNA sequencing experiments using the R programming language. The given code snippet is a part of the data preprocessing step, where data is read from files, manipulated, and stored in variables for further analysis. Your task is to wr...
codefeedback
You are tasked with implementing a Range class in Python that enables the use of the `<>` operators to match a numeric range. The Range class should support the following functionalities: - Constructing a Range object with a start and end value. - Checking if a given value falls within the range using the `<>` operator...
codefeedback
You are tasked with implementing a command-line utility for locking student assignments in a school management system. The utility should accept various command-line arguments to specify the assignment to lock, the section to lock, the student whose assignment needs locking, and whether to perform a dry run. Your task...
codefeedback
You are tasked with implementing a function that updates a message in a cloud database and handles potential errors. The function `updateMessage` takes in a `Message` object, a new title for the message, and a completion handler. It updates the title of the message and then uses a CloudKit operation to save the changes...
codefeedback
You are tasked with implementing a function that manipulates a Pml3 struct in a virtual memory system. The Pml3 struct represents the Page Map Level 3 table used in x86-64 architecture for virtual memory management. Your goal is to complete the function `PrintToTerminal` which takes a `DebugTerminal` and a `val` as inp...
codefeedback
You are tasked with creating a Python class for processing time series data. The class, `XShardsTSDataset`, is designed to handle time series data stored in multiple shards. Each shard contains a subset of the time series data, and the class is responsible for consolidating and processing this data. The class should h...
codefeedback
You are tasked with simulating a simplified version of a multi-threaded client-server system. The provided code snippet is part of the client-side code, where a certain number of client threads are being spawned to establish connections with the server. Each client thread will perform a specific task, and the main goal...
codefeedback
You are tasked with implementing a function that processes a list of complex fractal types and returns a modified list based on certain criteria. Each complex fractal type is represented as a string and the list of complex fractal types is provided as an array of strings. The function should filter out the fractal type...
codefeedback
You are tasked with creating a TypeScript function that validates the structure of an HTTP request object in a web application. The provided code snippet is a part of a TypeScript declaration file for an Express.js application. The `SudooExpressExtendRequest` interface represents the extended request object in the appl...
codefeedback
You are tasked with implementing a bubble sort algorithm to sort an array of Civilization objects based on their population. Each Civilization object has a name and a population. The Bubble class contains a method called BubbleSort that takes an array of Civilization objects and the number of civilizations as input and...
codefeedback
You are given a list of integers representing the prices of a stock on different days. You need to find the maximum profit that can be obtained by buying and selling the stock at most twice. However, you cannot engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again). For e...
codefeedback
You are tasked with creating a script to automate the configuration of a VPP (Vector Packet Processing) instance. VPP is an open-source networking platform that provides fast packet processing for network functions virtualization (NFV) and software-defined networking (SDN) applications. The given code snippet demonstra...
codefeedback
You are working on a build automation script for a software project. The script is responsible for compiling the project for different architectures and creating release packages. The provided code snippet is a part of this build automation script. Your task is to write a function that simulates the actions performed b...
codefeedback
You are tasked with creating a Python function that will parse a dictionary containing network management configuration parameters and return a formatted string representing the configuration in a specific format. The function should handle different types of configuration parameters and ensure that sensitive informati...
codefeedback
You are tasked with implementing a custom file wrapper class in Python that provides a progress bar for reading a file. The class should wrap around a standard file object and use the `tqdm` library to display a progress bar while reading the file. The class should also mimic the behavior of a standard file object, all...
codefeedback
You are working on a natural language processing (NLP) project and need to implement a function to create minibatches of data for training a neural network. The provided code snippet contains part of the implementation for this task. Your task is to complete the implementation of the `minibatches` function. The `minib...
codefeedback
You are tasked with writing a program to process images and create a multi-page PDF document. The program needs to calculate the height of each page in the PDF based on the aspect ratio of the images and a given width. Additionally, the program should create a directory to store the PDF and then iterate through a speci...
codefeedback
You are tasked with implementing a class method that creates a new target object. The method `new_target` takes in the following parameters: - `self`: The instance of the class. - `name`: A string representing the name of the target. - `tid`: An integer representing the target ID. - `**kwargs`: Additional keyword argum...
codefeedback
You are tasked with implementing a function that determines the frequency of characters in a given string. Your function should take a string as input and return a dictionary where the keys are the unique characters in the input string, and the values are the frequencies of those characters. For example, given the inp...
codefeedback
You are tasked with implementing a function to calculate the volume of a 3D sphere given an array of objects containing their centers and radii. The function should take an array of objects as input, where each object represents a sphere with properties `center` (an array of three coordinates) and `radius`. The functio...
codefeedback
You are tasked with implementing a numbering function for a document conversion tool. The function should take in source text, a numbering style, an output format, and any additional options, and return the appropriately numbered text in the specified format. The numbering style is defined by a prefix and a starting nu...
codefeedback
You are tasked with implementing a Java class that utilizes XML parsing and validation. Your goal is to create a class that can parse an XML document using a specified schema and retrieve the root node of the parsed XML. Your task is to complete the implementation of the `UseXML` class by providing the necessary code ...
codefeedback
You are tasked with implementing a function to convert a given integer into its Roman numeral representation. Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M, which correspond to the decimal values 1, 5, 10, 50, 100, 500, and 1000, respectively. The numeral is formed by combining symb...
codefeedback
You are given a code snippet that contains test cases for the `vfmsub132pd` instruction in x86 assembly language. Your task is to understand the code snippet and write a function that parses the mnemonic, operands, and other relevant information from the given test cases. Write a function `parse_instruction_tests` tha...
codefeedback
You are tasked with implementing a custom exception class and using it within a function. The custom exception class, `NothingFoundError`, should be raised when a specific condition is met within the function. Your task is to complete the function `search_and_throw` which takes a list of integers and a target integer a...
codefeedback
You are given a string `s` consisting of lowercase and uppercase letters. Your task is to write a function `replace_letters` that replaces all occurrences of a lowercase letter with its corresponding uppercase letter in the string, without using the `replace` method. The function should return the modified string. The...
codefeedback
You are tasked with creating a function that reverses an integer. The function should take an integer as input and return its reverse. If the reversed integer overflows (exceeds the 32-bit signed integer range), the function should return 0. Write a function `reverseInteger` that takes an integer `num` as input and re...
codefeedback
You are tasked with implementing a simple routing system for a web framework. The routing system should be able to handle different types of routes, including parameterized routes and subdomain-specific routes. Your task is to create a class that can define routes and match incoming requests to the appropriate route ha...
codefeedback
You are tasked with implementing a function that takes an array of integers and returns the maximum sum of a subarray within the input array. A subarray is defined as a contiguous block of elements within the array. The function should return 0 if the input array is empty or contains only negative numbers. You need to...
codefeedback
You are tasked with implementing a function that determines the largest continent in a world map represented by a 2D grid. Each cell in the grid represents a piece of land, and the value in each cell indicates the continent to which it belongs. A continent is a connected region of land cells with the same value. Your t...
codefeedback
You are working on a human resources management system that involves handling employee and department data. The system uses Python and the pandas library for data manipulation. The code snippet provided initializes a namespace dictionary with an "employee" key, which holds an empty DataFrame with columns for employee I...
codefeedback
You are tasked with implementing a function to calculate the Exponential Moving Average (EMA) of a given input data series. The EMA is a type of moving average that places a greater weight and significance on the most recent data points. The formula for calculating EMA is as follows: \[ EMA_t = \alpha \times data_t + (...
codefeedback
You are tasked with creating a web page that displays the import status of different management systems. The page should include the following components: - A heading with the text "Import Status" in an `<h3>` tag. - A description of the import jobs for the different managements. - An unordered list (`<ul>`) containing...
codefeedback
You are tasked with creating a Python class that parses a specific file format and extracts relevant information from it. The file format is called "IMD" and contains metadata about a song. The class should be able to read the IMD file, extract the version, song file name, and song name, and provide methods to access t...
codefeedback
You are tasked with implementing a Python class that fixes paths obtained from a Tango device. The class, `SdmPathFixer`, is designed to work with a specific device represented by `sdm_device`. The class has an attribute `TRIALS` set to 10 and a `cache` attribute initialized to `None`. Additionally, the class has a pro...
codefeedback
You are tasked with implementing a cache management system for a file system. The cache system should support read and write operations, and it should handle cache configuration and error handling. You are given a partial code snippet for the cache management system, which includes a debug error message and a cache co...
codefeedback
You are tasked with implementing a custom condition semaphore class in C++. A condition semaphore is a synchronization primitive that allows threads to wait until a certain condition is met before proceeding. Your task is to complete the implementation of the condition_semaphore class by adding the necessary methods to...
codefeedback
You are tasked with creating a Python function that calculates the cross-correlation between two given time series. The cross-correlation function measures the similarity between two time series as a function of the displacement of one relative to the other. The function should take two input arrays representing the ti...
codefeedback
You are tasked with implementing a Swift protocol for parsing and decoding SQL expressions from a Swift Portable Object Notation (SPON) stream. The protocol, `ADSQLExpression`, defines a method for decoding the expression from an instance dictionary. Your task is to create a concrete implementation of the `ADSQLExpres...
codefeedback
You are given the definition of a singly linked list node and a Python class `Solution` with a method `reverseList` that takes the head of a linked list as input. Your task is to complete the `reverseList` method to reverse the linked list in place and return the new head of the reversed list. The definition of the Li...
codefeedback
You are working on a Django web application that includes a model for news articles. The model has a field named `published_date` to store the date and time when an article is published. However, there is a migration script that needs to be modified to ensure that the `published_date` field defaults to the current date...
codefeedback
You are tasked with implementing a function that processes a given array of integers and returns the count of pairs of elements that sum up to a specific target value. You need to write a function `countPairs` that takes in an array of integers and a target sum, and returns the count of pairs that sum up to the target....
codefeedback
You are working on a software development team that uses a custom event-driven framework for managing pull requests on GitHub. The framework includes the following code snippet as part of its event handling system: ```python """A pull request is being created.""" template: github.Repository template_branch: str proje...
codefeedback
You are tasked with creating a Java program that simulates a simple multi-client server using sockets. The server will be able to handle multiple client connections and communicate with them using a basic protocol. The provided code snippet initializes a `ServerSocket` object, which is used to listen for incoming clien...
codefeedback
You are tasked with implementing a Python class that extends a given `DataSet` class to provide visualization capabilities. The `Visualization` class should inherit from the `DataSet` class and include methods for visualizing the data contained within the dataset. Your task is to implement the `Visualization` class wi...
codefeedback
You are tasked with implementing a command-line utility to demux an MP4 file into its elementary streams. The utility should take input from the user for the input MP4 file and the desired output file name without the extension. The demuxed elementary streams should be saved with the specified output file name and appr...
codefeedback
You are tasked with implementing a pseudo-random number generator using a custom algorithm. The given code snippet demonstrates part of the algorithm, where a seed is manipulated to produce a random number. Your task is to complete the implementation of the pseudo-random number generator by writing a function that take...
codefeedback
You are tasked with implementing a command pattern in Java to remove a word from the favorites list in a Word of the Day (WOTD) application. The code snippet provided includes the beginning of a `RemoveFavoriteCommand` class that implements the `Command` interface for a specific type `Word`. The `RemoveFavoriteCommand`...
codefeedback
You are tasked with creating a program to manage and record audio captures from various devices. The code snippet provided is a part of the program and is responsible for displaying the available capture devices and prompting the user to select a device for recording. Your task is to complete the program by implementin...
codefeedback
You are tasked with implementing a function to determine whether a given weapon can target a specific unit in a strategy game. The game has a variety of weapons, each with its own set of rules for targeting units. The provided code snippet shows the beginning of a function `canWeaponTargetUnit` that takes a weapon ID, ...
codefeedback
You are tasked with creating a Python function that generates fake certification data using the `factory` library. The function should take in parameters for the number of data entries to create, the display name for a single certification, the display name for multiple certifications, and an option to delete old data ...
codefeedback
You are tasked with creating a Python class that processes a file containing numerical values and provides various statistical information about the data. Your class should have the following functionalities: 1. Initialize the class with a file path and the number of values to be processed. 2. Read the specified numbe...
codefeedback
You are tasked with implementing a function that extracts the URL path from a given JavaScript function. The function should take the JavaScript code as input and return the URL path if found, or indicate that no URL path is present. Write a function `extractURLPath` that takes a string representing JavaScript code as...
codefeedback
You are working on a web application that generates a dynamic navigation menu based on a given data structure. The navigation menu is structured as an unordered list (`<ul>`) with list items (`<li>`) and potentially nested submenus. The PHP code snippet provided is a part of the navigation menu generation logic. Your t...
codefeedback
You are tasked with implementing a function to calculate the Root Mean Squared Error (RMSE) for two datasets. The RMSE is a measure of the differences between values predicted by a model or an estimator and the values observed. It is a popular measure of the differences between values predicted by a model or an estimat...
codefeedback
You are tasked with creating a script to automate the deployment of a MySQL database container using Docker. Your script should include the necessary commands to set environment variables for the MySQL user, password, and database name, as well as specify the Docker image to be used. Your script should be able to hand...
codefeedback
You are tasked with creating a Python program that retrieves the content of a text file from a given URL and performs specific operations on the text data. The program should accomplish the following tasks: 1. Retrieve the content of the text file from the URL "https://automatetheboringstuff.com/files/rj.txt" using the...
codefeedback
You are tasked with implementing a Python class that manages a calendar of holidays. The class should allow for the addition of holidays, with the option to mark certain holidays as observed on the nearest weekday if they fall on a weekend. You are provided with a code snippet that partially implements this functionali...
codefeedback
You are tasked with creating a Python function that interacts with different types of databases based on a specified database type. The function should connect to the database, execute a query, and return the results. The function should support two types of databases: "sqlite" and "mysql". For "sqlite" databases, the ...
codefeedback
You are tasked with implementing a function that takes a string as input and returns a new string with the characters reversed. You must also ensure that the original string remains unaltered. Additionally, you need to handle memory allocation and deallocation properly. You are given the following code snippet as a re...
codefeedback
You are given a grid representing a 2D area, where each cell in the grid can be either empty or occupied. The grid is represented as a 2D list of integers, where 0 represents an empty cell and 1 represents an occupied cell. You need to implement a function that calculates the size of the largest connected area of empty...
codefeedback
You are tasked with implementing a subclass of a `BaseCloudKitOperation` called `ModifyZonesOperation`. This subclass needs to include a property `shouldExecuteOperation` that determines whether the zone operation should be executed. Your task is to create the `ModifyZonesOperation` subclass and implement the `shouldEx...
codefeedback
You are tasked with implementing a simple HTTP filter system in Java. The provided code snippet is part of a class that represents an HTTP filter. The class has a method `setPhase` that takes an argument of type `HttpFilterType`. Your task is to define the `HttpFilterType` enum and complete the implementation of the `s...
codefeedback
You are tasked with creating a subscription management system for a software service. The system should allow users to subscribe to different plans and manage their subscriptions. To achieve this, you need to implement a class that uses reflection to dynamically get the correct subscription reference object based on th...
codefeedback
You are tasked with creating a Python script that monitors the CPU usage of a Google Cloud Platform (GCP) instance and takes specific actions based on the usage level. The script should run in the background as a daemon process. The script should continuously monitor the CPU usage and perform the following actions: - I...
codefeedback
You are tasked with implementing a more efficient version of the Fibonacci sequence calculation using tail recursion. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The goal is to create a tail-recursive function to calculate the n...
codefeedback
You are tasked with creating a program to encrypt and decrypt a file using a specific cipher algorithm. The algorithm involves using a key matrix to perform encryption and decryption operations on the input file. Your task is to implement the encryption and decryption functions based on the given code snippet and addit...
codefeedback
You are tasked with creating a SwiftUI view for a recipe app. The app should display a home screen with different recipe categories, and when a category is selected, it should navigate to a list of recipes within that category. You need to implement the `CategoryHome` view, which will display the categories and handle ...
codefeedback
You are tasked with creating a Python function that checks whether a given URL can return a tile with TIFF sources using the `large_image` library. The function should retrieve the image from the URL, verify that it is a TIFF tile source, and ensure that a tile can be obtained without raising an exception. The functio...
codefeedback
You are tasked with implementing a component layout algorithm for a graphical user interface. The algorithm should arrange components within a parent container, taking into account the available width, the presence of an overflow component, and the horizontal gap between components. You are given the following variabl...
codefeedback
You are tasked with creating a Python script to download files from a list of URLs. Your script should be able to handle various types of URLs and download the files to a specified directory. The script should also provide feedback on the download progress and handle any errors that may occur during the process. Your ...
codefeedback
You are tasked with implementing a custom data loader for a simplified version of the CIFAR-10 dataset using Python and PyTorch. The CIFAR-10 dataset consists of 60,000 32x32 color images in 10 classes, with 6,000 images per class. The dataset is divided into a training set and a test set, each with 50,000 and 10,000 i...
codefeedback
You are tasked with creating a TypeScript declaration file for importing SVG files in a React Native project. The `*.svg` module should be declared to import the `Svg` component from the `react-native-svg` library. Your task is to complete the declaration file by specifying the appropriate type definitions for the `Svg...
codefeedback
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The program should prompt the user to input their choice (rock, paper, or scissors), generate a random choice for the computer, determine the winner based on the choices, and display the result. Your program should follow these...
codefeedback
You are given a C++ function that is intended to find the maximum element in an array of integers. However, the function seems to be incomplete, and your task is to complete the function to achieve the desired functionality. The given code snippet is as follows: ```cpp #include <iostream> using namespace std; int fi...
codefeedback
You are given an array of integers `nums`, and a pair of indices `(i, j)` is called "good" if `nums[i] == nums[j]` and `i < j`. Your task is to write a function to count the number of good pairs in the array. Write a function `countGoodPairs` that takes in an array of integers `nums` and returns the number of good pai...
codefeedback
You are tasked with implementing a class method that manipulates a data structure and then performs a conditional check based on the result. The method `ResetMembers` is called on an object `this.Opl` with several parameters. The result of this method call is bitwise OR-ed with the variable `bReset`. Following this, a ...
codefeedback
You are tasked with creating a Python function to check the consistency of thermodynamic properties for a given fluid under specific conditions. The function should take into account the fluid's critical and minimum temperature, as well as its density in both liquid and vapor phases. Additionally, the function should h...
codefeedback
You are tasked with implementing a memory management system for a virtual memory architecture. The system is responsible for managing memory segments and ensuring that new segments are added within the appropriate address space. You are given a code snippet that represents a part of the memory management system. The s...
codefeedback
You are tasked with creating a Python program that simulates a simple game of dice rolling. The game will involve multiple players, each taking turns to roll a standard six-sided die. The program should use threading to handle the turns of each player concurrently. Additionally, the program should utilize the numpy lib...
codefeedback
You are tasked with simulating a multiplayer game server that handles incoming events from multiple players. The server uses the `select` module to efficiently manage incoming data from connected clients. The server receives game events in the form of pickled data and processes them accordingly. The game events include...
codefeedback
You are tasked with implementing a feature for a settings interface in a software application. The given code snippet is a part of the implementation for handling the visibility and enabling/disabling of certain UI elements based on the selected options in the settings. The code snippet shows a conditional block that ...
codefeedback
You are tasked with creating a Python program that reads necessary files and generates a report containing preferences and pre-assigned disciplines. The program should utilize a module called `funcoes_leitura` for file reading operations. Your task is to implement a function that reads the required files and generates ...
codefeedback
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. If there are fewer than two turns, the player's score is the sum of all the turns. Write a function `calculate_score(scores)` that takes in a list of integers `sc...
codefeedback
You are tasked with creating a program that parses and extracts information from HTML code containing badge images and their associated URLs. The badge images are represented as `<img>` tags with `src` attributes pointing to shields.io URLs, and the associated URLs are represented as `<a>` tags with `href` attributes. ...
codefeedback
You are tasked with implementing a custom LINQ extension method that filters a sequence of integers based on a given predicate. The method should return a new sequence containing only the elements that satisfy the predicate. You are provided with the following code snippet as a starting point: ```csharp using System; ...
codefeedback
You are tasked with creating a Python function that simulates the behavior of the `os.path.normpath` function. The `os.path.normpath` function normalizes a path, reducing redundant separators and up-level references. Your task is to implement a function `custom_normpath` that takes a string representing a file path as ...
codefeedback
You are tasked with designing a system to manage movement states in a game. The system will utilize a movement state facade to handle various movement-related functionalities. The movement state facade will be responsible for coordinating different movement states and providing a unified interface for interacting with ...
codefeedback
You are tasked with creating a Rust module that includes two sub-modules: `find` and `generator`. The `find` module should contain functions for finding specific elements, while the `generator` module should contain functions for generating data. Your task is to implement the necessary code to achieve this module struc...
codefeedback