instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program to validate passwords based on a given policy. The input consists of a list of passwords and their corresponding policies. Each policy indicates the minimum and maximum occurrences of a specific character within the password. Your task is to count the number of valid passwords acc...
codefeedback
You are tasked with implementing a method to parse a configuration file in a specific format and extract key-value pairs. The configuration file is in a custom format where each line contains a key-value pair separated by an equal sign (=). However, some lines may be commented out with a leading hash symbol (#). Your t...
codefeedback
You are tasked with implementing a custom tuple class in Python that has the following features: 1. The class should be named `CustomTuple`. 2. It should have a constructor that takes a variable number of arguments and stores them as elements of the tuple. 3. The `CustomTuple` class should override the `__repr__` metho...
codefeedback
You are working on a file encryption application that uses the AES encryption algorithm to secure data. The code snippet provided shows a part of the encryption process and the serialization of the encrypted data to a JSON format. Your task is to implement a method to deserialize the JSON data back into its original fo...
codefeedback
You are tasked with creating a Python class that represents a geometric shape. The class should have methods to calculate the area and perimeter of the shape. To achieve this, you will need to implement different methods for various geometric shapes such as Point, LineString, Polygon, MultiPoint, MultiLineString, Multi...
codefeedback
You are tasked with creating a Python program to manage a database of people's information. The program should be able to connect to different database files based on certain conditions and perform basic operations such as adding, updating, and retrieving records. Your program should include the following functionalit...
codefeedback
You are tasked with creating a Python decorator that enforces a specific naming convention for class attributes within a given class. The decorator should ensure that all attributes within the class adhere to a specific naming pattern defined by a regular expression. Your task is to implement the `enforce_naming_conven...
codefeedback
You are working on a machine learning project and have been tasked with implementing a prediction aggregation algorithm. The algorithm takes in predictions from multiple models and computes the average prediction for each item. The predictions are stored in a list of dictionaries, where each dictionary represents an it...
codefeedback
You are tasked with implementing a file access control system for a web application. The system should restrict unauthorized users from viewing certain files uploaded by users. The system uses a URI-based approach to access files, and it employs a client-server architecture. Your task is to implement a function or met...
codefeedback
You are tasked with implementing a Python function that simulates a random walk in a 2D grid. The function should take in the maximum number of steps for the walk, the probability of overshooting the maximum number of steps, and a timeout value. Additionally, the function should raise a RunTimeError if the walk exceeds...
codefeedback
You are tasked with implementing a program that processes a list of file paths and extracts the file extensions from each path. The file extension is defined as the substring following the last occurrence of the dot (.) character in the file path. If the file path does not contain a dot or the dot is the last character...
codefeedback
You are tasked with creating an Ansible module to manage Foreman location resources. Foreman is an open-source tool for provisioning, configuring, and monitoring physical and virtual servers. Locations in Foreman represent physical or logical groupings of resources, such as data centers, server rooms, or cloud regions....
codefeedback
You are tasked with implementing a file-saving mechanism for a binary entity pack in C++. The `BinaryEntityPack` class has a method `saveToFile` that takes a file path as input and is responsible for writing the binary data of the entity pack to the specified file. The `saveToFile` method should open the file, write th...
codefeedback
You are tasked with implementing a memory management system for a server infrastructure. The system needs to allocate memory for various server processes while adhering to certain constraints. The memory management system should support the following functionalities: 1. Set the output capacity for the memory managemen...
codefeedback
You are tasked with creating a Python class that simulates a simple progress bar. Your class should have methods to update the progress, retrieve the current progress, and reset the progress to zero. Additionally, the class should have a method to return a string representation of the progress bar, which visually displ...
codefeedback
You are tasked with creating a Python program that interacts with an external command-line tool to process JSON data. The program should read a JSON file, modify its contents, and then pass the modified JSON data to the external tool for further processing. Your task is to implement the Python program to achieve this f...
codefeedback
You are tasked with implementing a template loader interface for a meta generator tool. The `ITemplateLoader` interface provides methods for loading templates by name. Your goal is to create a class that implements this interface and loads templates from a predefined source. The `ITemplateLoader` interface has the fol...
codefeedback
You are working on a library for geometric computations in a 3D space. One of the functionalities you are implementing is parallel transport of vectors along a curve on a manifold. Parallel transport is a concept from differential geometry, where a vector is transported along a curve while keeping it parallel to itself...
codefeedback
You are tasked with creating a Python package for image classification using the popular ImageNet dataset. The package will be named "imagenet" and will provide various functionalities for working with image data and pre-trained models for classification. Your task is to define the necessary configuration and metadata...
codefeedback
You are tasked with implementing a function to filter and transform date ranges based on certain criteria. The function takes two parameters: `range` representing a date range and `filter` representing the filtering criteria. The `range` object has the following structure: ```javascript { start: Date, // Start date ...
codefeedback
You are tasked with creating a program to manage a list of users in a system. Each user is represented by the `User` struct, which has two properties: `email` and `names`. The `email` property stores the user's email address, and the `names` property stores the user's full name. Your program should provide functionalit...
codefeedback
You are working on a payment processing system that involves creating new payment instances. The system uses a Python library called `enroute` for handling asynchronous communication between different components. The code snippet provided is a part of a class that defines a method for creating a new payment. The method...
codefeedback
You are tasked with implementing a simple database management system for a social club. The system should allow the addition of new members and the retrieval of member information. You are provided with a partial code snippet for the database management system, which includes a method to add a new member. Your task is ...
codefeedback
You are tasked with creating a web application that allows users to navigate between different pages using form submissions. Your goal is to implement a feature that enables users to submit a form and trigger a specific handler on the server side. The provided code snippet is a part of the HTML form in the web applicat...
codefeedback
You are given a string containing a series of commands for a robot to move on a grid. The robot starts at the origin (0, 0) and can move in four directions: up, down, left, and right. Each command is represented by a single character: 'U' for up, 'D' for down, 'L' for left, and 'R' for right. The robot's path is determ...
codefeedback
You are given a text file containing a software license agreement. Your task is to write a Python program to count the occurrences of each unique word in the license agreement and then display the top N most frequently occurring words. Your program should perform the following steps: 1. Read the text file containing t...
codefeedback
You are tasked with implementing an input function for a machine learning model that will be used to classify videos into one of 4716 different classes. The input function should read and process training and validation data and then provide the results to the Estimator API for model training and evaluation. Your task...
codefeedback
You are tasked with creating a command-line tool to send messages between two locations using a relay system. The relay system is implemented in Rust and the tool is invoked with the following command: ```bash RUST_LOG=runtime=trace,substrate-relay=trace,bridge=trace \ ./target/debug/substrate-relay send-message <rout...
codefeedback
You are tasked with creating a simple HTTP request routing system for a web framework. Your goal is to implement a function that maps incoming HTTP requests to resource methods based on the request path. The function should take the request path as input and return the corresponding resource method. You are provided w...
codefeedback
You are tasked with creating a Python class to represent a patient's personal and medical information. The class should have attributes for the patient's phone number, address, city, zipcode, state, health card number, birthday, blood group, and organ. Additionally, you need to implement a method to display the patient...
codefeedback
You are given a value representing a point on a spiral grid. The grid starts at the center with value 1 and spirals outward in a counter-clockwise direction, with each layer of the spiral increasing by 4 in width. The goal is to determine the distance of the given value from the nearest perfect square on the spiral. W...
codefeedback
You are tasked with implementing a database abstraction layer in PHP. The provided code snippet outlines a set of methods that need to be implemented for interacting with a database. Your task is to create a class that includes these methods and provides functionality for basic database operations. You are required to...
codefeedback
You are given a code snippet from a Java file that contains comments with author information, date, and version details. Your task is to write a program that extracts and displays this metadata information in a structured format. Write a Java program that takes the code snippet as input and extracts the following info...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should be able to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry. The program should also be able to handle multiple accounts and perform operations on a specific account based ...
codefeedback
You are tasked with implementing a simplified version of a dependency injection container in TypeScript. A dependency injection container is a design pattern used to manage the dependencies of objects. In this problem, you will create a simple container that can be used to register and resolve dependencies. Your task ...
codefeedback
You are tasked with implementing a neural network model for a natural language processing task. The model architecture consists of a combination of linear layers and a Gated Recurrent Unit (GRU) layer. The model is designed to process input states and produce an output representing the negative log likelihood (nll) of ...
codefeedback
You are tasked with implementing a Python class for generating PDF documents. The class should have a method `generate_pdf` that takes three optional boolean parameters: `clean`, `clean_tex`, and `silent`. The `clean` parameter specifies whether to clean up temporary files after PDF generation, the `clean_tex` paramete...
codefeedback
You are given a list of tuples, where each tuple contains an integer and a pair of integers. The first integer represents an ID, and the pair of integers represents a numerator and a denominator. Your task is to write a function to calculate the average of the fractions represented by the pairs of integers and return t...
codefeedback
You are given a Python code snippet that calculates the sum of unique numbers within a specific range. Your task is to understand the code and implement a function that achieves the same result. You need to write a Python function that takes two parameters: - `all_abund_numbers`: a list of abundant numbers - `end`: an...
codefeedback
You are tasked with creating a program that simulates a simple template engine. The program should take a template string as input and replace any placeholders in the template with corresponding values provided as environment variables. Your program should read the template string and replace any placeholders of the f...
codefeedback
You are tasked with implementing a Python class that manages user permissions for accessing resources. The class, `ResourceService`, is responsible for handling user permissions for a given resource. The class has a method, `users_for_perm`, which retrieves the users who have a specific permission for a given resource....
codefeedback
You are given a code snippet that processes file names and extracts information from them using regular expressions and file I/O operations. Your task is to implement a program that performs similar file processing and information extraction based on the given requirements. You need to write a program that reads a dir...
codefeedback
You are tasked with implementing a simple RSA encryption and decryption algorithm. The RSA algorithm involves generating public and private keys, encrypting a message using the public key, and decrypting the message using the private key. Your task is to write a Python program that performs RSA encryption and decryptio...
codefeedback
You are working on a system that manages user permissions using bit manipulation. The system has four types of permissions: Operator, Host, Automation, and Admin, represented by the constants `PERMISSION_OPERATOR`, `PERMISSION_HOST`, `PERMISSION_AUTOMATION`, and `PERMISSION_ADMIN` respectively. Additionally, there is a...
codefeedback
You are tasked with implementing a custom JSON serializer for a specific class in a C# application. The class `TestBase` contains a method `JsonSerializerFormatted` that serializes an object into a JSON string using the `JsonConvert.SerializeObject` method from the Newtonsoft.Json library. The `_serializerSettings` fie...
codefeedback
You are tasked with implementing a function to generate an inverted index for a collection of documents from the Reuters21578 dataset. The dataset is retrieved using the `reuters.ReutersCorpus()` class, and the function `reuters_corpus.retrieveDocuments()` returns a list of documents. Your task is to preprocess these d...
codefeedback
You are tasked with implementing a class for managing OpenGL program pipelines. The provided code snippet is a constructor for the `ProgramPipeline` class, which takes a `ShaderProgram` as a parameter and sets up the program pipeline using OpenGL functions. Your task is to complete the implementation of the `ProgramPi...
codefeedback
You are tasked with implementing a custom `substring` method for the `String` type in Swift. The method should take an `NSRange` as input and return the corresponding `Substring` of the string, or `nil` if the range is invalid. Your task is to complete the implementation of the `substring` method within the `String` e...
codefeedback
You are tasked with implementing a function that applies shift negative correction (SNC) to a graph based on specific node matchers. The graph represents a computational graph used in deep learning frameworks, and the SNC aims to correct negative activations in the graph. The function takes as input the graph, core con...
codefeedback
You are tasked with implementing a higher-order function called `manageState` in TypeScript. The function takes a single argument, `SelectComponent`, which is a component type of any kind. The `manageState` function returns a `StateManager` that is parameterized by any type. Your goal is to create the `manageState` fun...
codefeedback
You are tasked with creating a notification service in an Angular application. The notification service should be encapsulated within a module and should provide a component for displaying notifications. The provided code snippet is a part of the implementation of the notification module. Your task is to complete the ...
codefeedback
You are tasked with implementing a stack-based virtual machine for executing bytecode instructions. The virtual machine operates on a stack of operands and a runtime constant pool containing various constants required for execution. Your goal is to implement the `Frame` struct, which represents a single frame in the vi...
codefeedback
You are tasked with implementing a custom UIControl subclass in Swift that manages the background color for different control states. The provided code snippet is part of the implementation and includes a private method `backgroundColor(for state: UIControl.State) -> UIColor?` that retrieves the background color for a ...
codefeedback
You are tasked with implementing a function that checks whether a given expression is properly formatted with parentheses and single quotes. The function should return True if the expression is valid and False if it is not. The expression is considered valid if: 1. It ends with three consecutive closing parentheses `)...
codefeedback
You are tasked with implementing a function that sets the title and color of a navigation item in a mobile application. The function `setNavigationItemTitle` takes a title string as its parameter and sets the navigation item's title to the provided string with a default color. The second function `setNavigationItemTitl...
codefeedback
You are tasked with creating a Django migration for a new field in a model. The field to be added is called "chart_position" and is of type CharField with a maximum length of 100. The field should have a verbose name of "Chart Position" and should allow blank values. You need to write the migration code to add this fie...
codefeedback
You are tasked with creating a program that processes multiple language files and extracts unique words from each file. The program should then output the unique words from each file in a specific format. You are given a code snippet that opens and processes language files. The `files` variable is a list of file objec...
codefeedback
You are tasked with implementing a class that represents a simple bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. Additionally, the class should keep track of the total number of transactions (deposits and withdrawals) made on the account. Your task is to co...
codefeedback
You are tasked with creating a program that processes a list of students' scores and outputs the top 5 scores for each student. The input to the program will be the rank and size of the subset of scores to be considered for each student. Your task is to implement a Python program that takes two command-line arguments:...
codefeedback
You are tasked with creating a program that simulates the process of building a static library. The program should handle the downloading of source files, compilation, and creation of the static library. Your program should consist of the following steps: 1. Download the source files from a given URL. 2. Compile the ...
codefeedback
You are tasked with creating a Python class that simulates a website administration panel. The class should have the ability to set and retrieve the site title and site header. Additionally, it should provide a method to reset the site title and header to their default values if needed. Your task is to implement the `A...
codefeedback
You are working on a web application that displays specimen data, including geographical information. The code snippet provided is part of a TypeScript component that sets the title of the page and retrieves specimen data from a service. It also handles the geographical coordinates and sets up a base map layer using Op...
codefeedback
You are tasked with creating a program to simulate a simplified version of a distributed computing system. The program will utilize multithreading to calculate the abundance distribution of a given set of numbers. The abundance of a number is defined as the sum of its proper divisors (excluding itself) compared to the ...
codefeedback
You are given an array of integers representing the weights of candies and two pointers, `alice_pos` and `bob_pos`, initially pointing to the start and end of the array, respectively. The goal is to find the total number of candies that can be equally divided between Alice and Bob by moving the pointers and adding the ...
codefeedback
You are tasked with implementing a class that simulates a simple database producer for a fictional database system called CastorDB. The database producer class, `CastorDbProducer`, is responsible for generating and providing data to the CastorDB system. Additionally, the class should utilize a set of hard-coded calibra...
codefeedback
You are tasked with implementing a loss function for the Faster R-CNN object detection model. The loss function is used to train the model to accurately predict object bounding boxes and class labels. The model also supports Feature Pyramid Network (FPN) for multi-scale object detection. Your task is to implement the ...
codefeedback
You are tasked with implementing a class that represents a viewport within a window for a graphics application. The class should provide a method to convert coordinates from the viewport space to the screen space. The provided code snippet outlines the private members and a method declaration for the viewport class. Y...
codefeedback
You are tasked with implementing a login functionality for a web application using Java Enterprise Edition (Java EE) technologies. The given code snippet is a partial implementation of a managed bean for user login. Your task is to complete the implementation of the login functionality by validating the user's credenti...
codefeedback
You are tasked with implementing a custom view inspection feature for a Swift UI testing framework. The provided code snippet is a part of a Swift extension that aims to enable the inspection of a specific type of view within a hierarchy of views. The `InspectableView` protocol is extended with a method `hStack(_:)` th...
codefeedback
You are tasked with implementing an Access Control List (ACL) system for a Python class. The ACL system should allow or deny access to specific resources based on the permissions granted to different user groups. The ACL system should support different modes of access, such as read, write, and execute. You are given a...
codefeedback
You are tasked with creating a Python program that simulates a simple command-line calculator. The program should accept command-line arguments for performing basic arithmetic operations and display the result. To achieve this, you will need to utilize the `argparse` module and create a custom argument parser that prin...
codefeedback
You are given a string `s` consisting of lowercase English letters and curly braces. The string may contain nested curly braces. Your task is to determine if the string is properly nested, meaning that for every opening curly brace there is a corresponding closing curly brace, and they are properly nested within each o...
codefeedback
You are tasked with implementing a Python class that manages a binary search tree (BST). The class should have methods to insert a new node, delete a node, and perform an in-order traversal of the BST. Additionally, the class should include a method to fix any inconsistencies in the BST after a deletion operation. You...
codefeedback
You are tasked with implementing a windowing pipeline for processing time-series data. The pipeline will generate sliding windows over a specified time range and perform computations on the data within each window. Your task is to write a Python function that takes in the necessary parameters and executes the windowing...
codefeedback
You are tasked with creating an AWS Step Functions state machine that handles error handling and fallback mechanisms. The state machine should include a custom error handling state that invokes a Lambda function to handle specific errors and a fallback state to handle any unanticipated errors. The code snippet provide...
codefeedback
You are given a Python code snippet that appears to be part of a program to find the minimum value of a function using the golden section search method. The code snippet includes a function call `main(-3,-1,-2.2)` and some logic for finding the minimum value of a function. Your task is to complete the program by implem...
codefeedback
You are tasked with implementing a multiresolution analysis algorithm to measure the acoustic diversity of a given audio signal. The algorithm should be able to analyze the audio signal at different resolutions and provide a measure of the diversity of acoustic features present in the signal. You are given a Python co...
codefeedback
You are tasked with creating a script that automates the process of building conda packages for different Python versions. Conda is a popular package management and environment management system that runs on Windows, macOS, and Linux. The provided code snippet is a shell script that takes a folder name as an argument a...
codefeedback
You are tasked with implementing a custom UICollectionView in a Swift application. The collection view should display a list of countries with a custom cell and section header view. The collection view should have its vertical and horizontal scroll indicators disabled and a specific background color set. Additionally, ...
codefeedback
You are tasked with creating a script to automate the testing of a program using a set of input files and comparing the output against expected results. Your script should execute the program with each input file and then calculate the MD5 hash of the generated output files to ensure consistency. You are provided with...
codefeedback
You are tasked with implementing a Python class method for making a PATCH request to an API endpoint. The method should handle the construction of the request URL, formatting the data payload, and appending necessary headers before making the request. Your task is to complete the implementation of the `patch_data` meth...
codefeedback
You are tasked with implementing a rate limiter class in Python. A rate limiter is a system that limits the number of events or actions that can occur within a specified time window. Your task is to complete the implementation of the `RateLimiter` class by filling in the missing code for the `allow_request` method. Th...
codefeedback
You are tasked with creating a Python class that simulates a simple bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. Additionally, the class should have a method to transfer funds to another account. You need to implement the transfer method and write a test c...
codefeedback
You are tasked with designing a database schema for a multiplayer online game. The game has various entities such as data seeds, accounts, logins, login attempts, and characters. Your task is to create an appropriate database schema using the Entity Framework Core (EF Core) code-first approach based on the given code s...
codefeedback
You are tasked with creating a script that processes a directory structure and performs specific actions on the files within it. The script should be designed to handle errors and enable globstar functionality. Your task is to implement a Bash script that accomplishes the following: 1. Sets the script to exit immediat...
codefeedback
You are tasked with creating a command-line tool that processes a YAML file to determine the fate of a hero in a fictional world. The tool is executed using the following commands: ```bash stack clean && stack build && stack exec maybe-hero-exe world.yml ``` The `stack clean` command removes any previously built arti...
codefeedback
You are tasked with implementing a function that takes in a string representing a file path and returns the name of the file without the file extension. The file path may contain multiple directories and the file name may contain multiple periods. You need to extract the file name from the given path and return it. Wr...
codefeedback
You are tasked with designing a memory address decoder for a memory module. The memory module has a total address space of 32KB and is organized as a 32x8 memory array. The memory module has three address inputs: `page_address`, `column_address`, and `address`. Each address input is an 8-bit signal. The memory address ...
codefeedback
You are tasked with implementing a data structure to manage font properties for a text rendering engine. The font properties include rights and default kerning. The rights property represents the spacing for specific characters, while the default_kerning property represents the default spacing for any character not in ...
codefeedback
You are working on a solar panel simulation software and need to implement a feature to calculate the land area required for a solar panel installation based on various parameters. The code snippet provided is a part of the software and contains some initial setup and calculations. Your task is to write a function that...
codefeedback
You are tasked with implementing a custom class in Python that represents a point in a 2D Cartesian coordinate system. The class should support comparison operations and be optimized for memory usage. Your task is to complete the implementation of the `P2` class, which is a subclass of `Cartesian2`. The `P2` class sho...
codefeedback
You are tasked with creating a function that processes a list of historical orders and returns the total quantity of a specific item ordered by a given customer. The historical orders are represented as a list of tuples, where each tuple contains the customer ID, item ID, and quantity ordered. The function should take ...
codefeedback
You are given a Python code snippet that uses the pandas library to visualize scatter plots based on data from a DataFrame. The DataFrame `df3` contains information about genetic mutations, including mutation rates and types. The code snippet uses the `plot.scatter` method to create two scatter plots and color the data...
codefeedback
You are tasked with implementing a method to handle the launch mode of fragments in an Android application. The method should take in the fragment manager, the fragment to be launched, its tag, and the launch mode as parameters. The launch mode can be one of the following: `SupportFragment.STANDARD`, `SupportFragment.S...
codefeedback
You are tasked with creating a simple routing system for a web application using PHP. The application should have routes for the homepage, contact page, posting messages, and region-specific pages. You need to implement the routing logic using PHP and demonstrate the ability to handle different types of HTTP requests. ...
codefeedback
You are tasked with implementing a simplified version of a graph format converter in Java. The provided code snippet includes the declaration of a `GraphMLFormat` class that extends a `Format` class. Your goal is to complete the implementation of the `GraphMLFormat` class by adding necessary methods and fields to suppo...
codefeedback
You are given a PHP code snippet from a class method. The method `match` takes a parameter `$binaryOp` and returns an instance of `\Rector\Php80\ValueObject\StrStartsWith` or `null`. Your task is to understand the logic within the `match` method and write a function that mimics its behavior. The `match` method checks ...
codefeedback
You are tasked with implementing a function that indexes a list of objects based on a specified key field. The function should return a dictionary with keys based on the values of the specified key field of the objects in the input list. You are given the following function signature: ```python def index_objects( ...
codefeedback
You are tasked with implementing a custom file resource manager and culture-specific string localizer in C#. The `FileResourceManagerWithCultureStringLocalizer` class is designed to manage resources for different cultures and provide localized strings based on the specified culture. The class has the following constru...
codefeedback
You are tasked with creating a Bash script that automates the process of cloning a Git repository. The script should take the email address of the user, the repository name, and the destination directory as input parameters. Additionally, the script should handle errors gracefully using the `set -e` option. Write a Ba...
codefeedback