instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a function that checks the validity of a given password based on the following criteria:
1. The password must be at least 8 characters long.
2. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character from the set {!, @, #, $, %... | codefeedback |
You are tasked with implementing a function to scale a given polygon to fit within a target size. The function should take a polygon represented by a list of points and a target size, and then scale the polygon's points to fit within the target size while maintaining the polygon's shape.
You are provided with a code s... | codefeedback |
You are tasked with creating a Python class that simulates a simple blockchain-based ERC20 token transfer system. The class should include methods for initializing the token contract, transferring tokens between accounts, and retrieving token balances. Additionally, you need to implement a method for indexing ERC20 eve... | codefeedback |
You are tasked with implementing a message decoding algorithm for a specific data structure. The data structure is represented by a Swift code snippet that includes a method `decodeMessage` and a private storage class `_StorageClass`. The `decodeMessage` method takes a decoder as input and decodes specific fields from ... | codefeedback |
You are tasked with implementing a custom collection class in Python that supports adding elements, removing elements, and checking if an element exists in the collection. The collection should also support iteration and provide the ability to retrieve the number of elements it contains.
Your task is to complete the i... | codefeedback |
You are working on a data processing module for a signal processing application. The module contains a class with several methods for processing channels of data. One of the methods, `process_channels`, takes a list of channel IDs and a window size as input and processes each channel using the `process_channel` method.... | codefeedback |
You are tasked with creating a Python program that reads a list of integers from a file, performs a specific operation on the list, and then writes the modified list back to the file. The program should handle file input and output, as well as the list manipulation.
Your program should perform the following steps:
1. ... | codefeedback |
You are tasked with implementing a class hierarchy for a stock trading system. The system should support different strategies for adapting weights of stocks in a portfolio. The code snippet provided is an import statement for a class called `AdapWeightsStrategy` from a module named `adapweightsstrategy`.
Your task is ... | codefeedback |
You are tasked with implementing a function that processes a list of text features and organizes them into a dictionary. The function should identify and handle duplicate text features, and then serialize the resulting dictionary into a list of examples.
You are given the following code snippet as a starting point:
`... | codefeedback |
You are tasked with implementing a function that validates user credentials for either login or registration. The provided code snippet gives a rough idea of the expected structure of the validation function. Your task is to create a function that takes in the type of validation required (either "LOGIN" or "REGISTER") ... | codefeedback |
You are tasked with implementing a simple JSON parser in C++. Your task is to create a class `Json` that can parse a JSON string and provide methods to access the parsed data. The JSON format will be limited to objects (key-value pairs) and arrays (lists of values). The parser should be able to handle nested objects an... | codefeedback |
You are tasked with creating a Django model for a chat application that includes a "Room" model. The "Room" model should have fields for the room's ID, slug, name, access type, activity status, and a black list of professionals who are forbidden from accessing the room. The "access" field should allow for either "Publi... | codefeedback |
You are tasked with implementing a shopping cart system in Swift. The system should be able to handle adding, removing, and updating items in the cart, as well as calculating the total cost of the items in the cart.
You are given the `TransactionItem` struct, which represents an item that can be added to the shopping ... | codefeedback |
You are tasked with implementing a custom namespace management system in C++. The system should allow for the creation, retrieval, and deletion of namespaces, as well as the addition and retrieval of variables within these namespaces. Each namespace can also have sub-namespaces, forming a hierarchical structure.
Your ... | codefeedback |
You are given a code snippet that performs a hash function on a 32-bit integer `h`. The hash function involves two operations: multiplication and bitwise XOR.
The first operation multiplies the current value of `h` by a constant value `0x85ebca6b` and then performs a bitwise AND with `0xFFFFFFFF` to ensure the result ... | codefeedback |
You are tasked with implementing a program that processes JSON data and handles potential exceptions that may arise during the parsing process. Your program should read a JSON string from the standard input, parse it, and then print the value associated with a specific key. If any exception occurs during the parsing or... | codefeedback |
You are tasked with creating a program that processes a given input string to extract information about GitHub repositories and their stars. The input string will consist of multiple lines, each containing information about a GitHub repository in the format `<repository_name><tab><stars_range>`. The `<repository_name>`... | codefeedback |
You are tasked with optimizing the allocation of sunlight to different beds in a garden over a period of multiple years. Each bed has specific sunlight requirements, and the goal is to efficiently distribute sunlight to meet these requirements while considering the time dimension.
You are given the following informati... | codefeedback |
You are tasked with creating a parallel processing function for applying a given function to a pandas DataFrame. The function should take the DataFrame, the function to be applied, a word parameter, and the number of cores to parallelize the function. The function should split the DataFrame into chunks, apply the given... | codefeedback |
You are tasked with implementing a custom exception handling mechanism for a Python application. Your goal is to create a new exception class that represents a timeout for an outbound request. The new exception class should be a subclass of the `SynapseError` class from the `synapse.api.errors` module. Additionally, yo... | codefeedback |
You are tasked with implementing a simplified version of a URL mounting system in Python. The goal is to create a class that can register and retrieve adapter objects for specific URL prefixes.
You need to implement a class `URLMounter` with the following methods:
- `__init__(self)`: Initializes the URLMounter with an... | codefeedback |
You are tasked with implementing a flood warning system for a river using Python. The system will monitor the water level of the river and issue warnings if the water level exceeds a certain threshold. The system should be able to handle multiple monitoring stations along the river.
You are provided with a partial cod... | codefeedback |
You are working as a DevOps engineer for a company that uses Kubernetes for managing its applications. As part of the deployment process, you need to ensure that certain Kubernetes resources are deleted in a specific order to avoid any disruptions. You have been given a set of Kubernetes resource files and a sequence o... | codefeedback |
You are tasked with implementing a simplified version of a blockchain node's block cleanup request handling logic. The node receives block cleanup requests and enqueues messages to request witness data from active blockchain connections. Your goal is to write a function that simulates this process.
You are given the f... | codefeedback |
You are tasked with implementing a Swift property for a networking component that constructs an endpoint URL based on the environment and asset ID. The environment has an `apiUrl` property representing the base URL, and the asset ID is a unique identifier for a specific asset. Your task is to create a computed property... | codefeedback |
You are tasked with implementing a function that parses a JSON object and extracts specific information from it. The JSON object is represented using a custom `JSON` data type, which has a property `arrayValue` that returns an array of `JSON` objects. Your task is to implement a function that extracts and returns all t... | codefeedback |
You are tasked with writing a program to determine the most frequently occurring name from a list of names. Your program should take an integer N as input, representing the number of names in the list, followed by N lines of input, each containing a name. The program should then output the name that occurs most frequen... | codefeedback |
You are tasked with implementing a Python class that extends a superclass and overrides a method. The superclass, `OpFeatures`, contains a method `execute` that takes four parameters: `slot`, `subindex`, `roi`, and `result`. Your task is to create a subclass called `CustomOp` that inherits from `OpFeatures` and overrid... | codefeedback |
You are tasked with implementing a function to build a catalog of images for a machine learning project. The function should take a directory path as input and return the catalog path, label paths, and image paths.
The function signature is as follows:
```python
def build_catalog(directory_path: str, nb_labels: int) -... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The system should be able to create bank accounts, deposit and withdraw funds, and provide an account summary.
Create a class `BankAccount` with the following specifications:
- A constructor that takes the account holder's name and initiali... | codefeedback |
You are tasked with implementing a Python module loader that can dynamically import modules based on a given list of allowed module names. Your module loader should only allow importing modules that are explicitly listed in the `__all__` attribute of the module. If a module is not listed in `__all__`, the loader should... | codefeedback |
You are tasked with implementing a doubly linked list in Rust. Your task is to complete the implementation of the `clone_and_detach` function, which takes a mutable reference to a node in the doubly linked list and clones the next node, detaching it from the original list.
The `Node` struct is defined as follows:
```r... | codefeedback |
You are tasked with implementing a simple text scanning and parsing functionality. Your goal is to create a class that can tokenize and parse a given input string based on a predefined grammar. The grammar is defined using a `CoreGrammar` class, and the parsing is performed by invoking a specific rule from the grammar ... | codefeedback |
You are tasked with creating a custom TensorFlow operation to zero out specific elements of a tensor based on a given condition. Your task is to implement the custom TensorFlow operation and use it to zero out elements of a tensor according to a specified condition.
Your custom operation, named `zero_out_op`, should t... | codefeedback |
You are tasked with implementing a chatbot system called EmoCourseChat that integrates emotion detection and course recommendation functionalities. The chatbot system is designed to interact with users, understand their emotions, and recommend suitable courses based on their emotional state. The system is built using P... | codefeedback |
You are working on a user authentication system for a web application. The system uses an object-oriented approach, and you are tasked with implementing a method to set and save a user's password. The code snippet below demonstrates the usage of the `password` method and the `save` method on an object `$x` to set and s... | codefeedback |
You are tasked with implementing a function that calculates the total space occupied by a UIStackView based on its arranged subviews and layout margins. The UIStackView is defined with the following properties:
- `axis`: The orientation of the stack view (vertical or horizontal).
- `layoutMargins`: The margins around t... | codefeedback |
You are tasked with implementing a simplified version of a function that binds attributes to a shader program in a graphics rendering system. The function `BindAttrib` takes two parameters: the attribute index and the attribute name. The attribute index is an integer representing the location of the attribute in the sh... | codefeedback |
You are tasked with implementing a custom sorting algorithm for a specific data structure. The data structure represents a collection of objects, and the sorting algorithm should compare the objects based on their string representations.
You are given a class `CustomObject` with a method `CompareTo` that compares the ... | codefeedback |
You are tasked with creating a Python function that processes a series of network data files and constructs a directed graph from the data. The function should read each file, create a directed graph using the NetworkX library, and then store the graph in a dictionary with a unique identifier. The function should retur... | codefeedback |
You are given a string representing a floating-point number. Your task is to write a function to round the number to the nearest integer and return the result as a string.
Write a function `solution` that takes in a string `line` representing the floating-point number and returns a string representing the rounded inte... | codefeedback |
You are given a set of inputs and a set of weights and biases for a neural network layer. Your task is to implement the forward pass of this neural network layer using the given inputs, weights, and biases.
The inputs are represented as a 2D array, where each row corresponds to a single input sample, and each column c... | codefeedback |
You are tasked with implementing a TypeScript decorator that validates the configuration settings for different kinds of file attachments in an application. The `FileAttachmentConfig` class represents the configuration settings for file attachments, and the decorator `@ConfigReader` is used to validate and read these s... | codefeedback |
You are tasked with implementing a program that enhances the performance of a convolutional neural network (CNN) for image classification. The given code snippet provides a starting point for improving the CNN model. Your task is to address the TODO items mentioned in the code snippet and further optimize the model for... | codefeedback |
You are tasked with implementing a data upload system for a company's internal data management platform. The `_upload_data` function is responsible for handling the data upload process. The function should take data from various sources, perform necessary validations, and then upload the data to the company's database.... | codefeedback |
You are given a class `Solution` with a method `firstBadVersion` that takes an integer `n` as input. The method is designed to find the first bad version in a list of versions from 1 to `n`. The `isBadVersion` API is already defined for you, which takes an integer `version` as input and returns a boolean indicating whe... | codefeedback |
You are tasked with creating a Python class to manage the control and monitoring of a chopper device used in a scientific experiment. The chopper device has various commands and settings that need to be accessed and manipulated. Your task is to implement a Python class that encapsulates the functionality of the chopper... | codefeedback |
You are tasked with implementing a caching mechanism for a key-value store. The cache should have a maximum capacity and support two operations: `get(key)` and `put(key, value)`. When a key is accessed using `get(key)`, the cache should return the corresponding value if it exists, or a special "UNKNOWN" message if the ... | codefeedback |
You are tasked with creating a Python function that can parse a Django project's `ROOT_URLCONF` setting and extract the names of all the URL patterns defined within it. The `ROOT_URLCONF` setting in Django specifies the Python module where the project's URL patterns are defined.
You need to implement a function `extra... | codefeedback |
You are tasked with creating a Java application that utilizes a native library for a specific platform. The application is executed using a command-line interface, and the native library is located in a subdirectory relative to the application's JAR file. Your goal is to ensure that the application can successfully loa... | codefeedback |
You are tasked with implementing a function `any_of` that takes a vector of integers and a target integer as input and returns true if the target integer is present in the vector, and false otherwise. You need to write the `any_of` function and ensure that it passes the given test cases.
The function signature is:
```... | codefeedback |
You are working on a machine learning project and need to implement a k-nearest neighbors (KNN) algorithm for classification. The KNN algorithm classifies a data point based on how its neighbors are classified. You have been given a code snippet that includes a part of the KNN algorithm implementation. Your task is to ... | codefeedback |
You are tasked with creating a class that handles the configuration installation for a software project. The `ConfigInstallation` class is responsible for loading and displaying the configuration settings from a specified file path. Your goal is to implement the `ConfigInstallation` class and its associated methods to ... | codefeedback |
You are tasked with implementing a simple program to toggle between two modes for rendering polygons using OpenGL. The program should allow the user to switch between filling the polygons and rendering only their outlines.
You are given a code snippet that handles the key input for toggling between the two rendering m... | codefeedback |
You are tasked with creating a program that extracts and organizes documentation comments from Lua and XML files to generate a comprehensive readme for extensions. The program should be able to parse Lua block comments and XML comments and then combine them to create a well-structured readme file.
Your task is to impl... | codefeedback |
You are tasked with implementing a Python class that handles HTTP requests and responses. The class should include methods for making HTTP requests, parsing the responses, and handling any potential errors.
Your task is to complete the implementation of the `_request_parse` method in the given Python class. The `_requ... | codefeedback |
You are tasked with creating a Python function that automates the process of creating an AWS IAM role with specific permissions using the `boto3` library. The function should take in the role name and a list of policies as input and create the IAM role with the specified policies attached.
You are provided with a code... | codefeedback |
You are tasked with implementing a simple calculator program that takes user input for mathematical expressions and evaluates them. The program should continuously prompt the user for input, evaluate the expression, and print the result. The input expressions can include basic arithmetic operations (+, -, *, /) and par... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of a user interacting with a software application using the `oHelper` object. The `oHelper` object provides methods for interacting with the application's user interface. Your task is to implement a function that performs a series of actions usi... | codefeedback |
You are tasked with creating a script to automate the initialization process for a Magento e-commerce platform. The script should redirect the standard output and standard error streams to specific log files and then start a cron job with specific settings.
Your script should perform the following actions:
1. Execute ... | codefeedback |
You are working on a statistical analysis tool for comparing control and treatment groups in an experiment. The code snippet provided is a part of a class that calculates and displays various statistical measures for the control and treatment groups. The `calc_var` method is used to calculate the variance for both grou... | codefeedback |
You are tasked with creating a custom pagination class for a web application using Python and Django's REST framework. The custom pagination class should extend the `PageNumberPagination` class provided by the REST framework and be designed to paginate a list of users. The pagination should have the following propertie... | codefeedback |
You are given a Python code snippet that involves a function `cum_minmax_compare(op, x, cummax_output, axis, data_type)`. Your task is to understand the function's behavior and implement it in a different programming language, specifically in Java.
The `cum_minmax_compare` function takes five parameters:
- `op`: A str... | codefeedback |
You are tasked with creating a Python class that manages keyboard layouts for different languages. The provided code snippet includes a function `get_layout` that takes a `layout_name` as input and retrieves the corresponding keyboard layout from a YAML file. The `LayoutName` enum is used to ensure type safety for the ... | codefeedback |
You are tasked with implementing a Python function that calculates the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequen... | codefeedback |
You are tasked with creating a Python function that processes a setup file for a Python package and extracts specific information from it. The setup file is in the form of a Python script and contains metadata about the package, such as its name, version, license, and description. Your function should read the setup fi... | codefeedback |
You are given a Python function that takes in a normal boundary map, along with the coordinates of the center point of a box. The function is intended to return the coordinates of the upper-left (UL) and bottom-right (BR) corners of the box. The normal boundary map is represented as a 2D array of 0s and 1s, where 1s in... | codefeedback |
You are tasked with implementing a function that takes an array of integers as input and returns the maximum sum of a contiguous subarray within the input array. The function should efficiently handle both positive and negative numbers.
You need to implement the following function:
```php
/**
* Find the maximum sum ... | codefeedback |
You are tasked with implementing a custom SwiftUI view called `ItemStatus` that displays the status of an item. The `ItemStatus` view takes an instance of `UIModelDataValue` as its input, which contains various properties related to the status.
The `UIModelDataValue` struct has the following properties:
- `value`: A s... | codefeedback |
You are given a code snippet that appears to be a mix of Swift programming language syntax and random characters. Your task is to analyze the code and identify the correct syntax and structure based on Swift language rules. Once you have deciphered the code, you need to determine the correct classes, enums, and variabl... | codefeedback |
You are tasked with implementing a simple class that manages a list of tasks. The class should allow adding tasks, marking tasks as completed, and retrieving the list of incomplete tasks. You are provided with a partial implementation of the `TaskManager` class in C#:
```csharp
using System;
using System.Collections.G... | codefeedback |
You are tasked with creating a Python function that parses and validates lambda expressions using a custom Lispyc parser. The parser takes lambda expressions in the form of strings and converts them into a structured representation. The structured representation consists of parameters, return types, and the body of the... | codefeedback |
You are tasked with creating a Python class that simulates a character in a role-playing game. The class should have attributes such as race, gender, name, peacefulness, honor, archetype, and upbringing. Additionally, the class should have a method to set the ban state end time. Your task is to implement the class with... | codefeedback |
You are tasked with implementing a fingerprinting algorithm to compare the similarity of different data structures. The fingerprinting algorithm takes in various data types and produces a unique fingerprint for each input. Your goal is to create a Python class that can fingerprint lists and files using the OptionsFinge... | codefeedback |
You are tasked with implementing a custom attribute in C# that will be used to mark classes for a specific purpose. The attribute should enforce that the marked classes can only be applied to a specific type of collection. Your task is to create the custom attribute and apply it to a class, ensuring that it can only be... | codefeedback |
You are given a list of integers. Your task is to implement a function `mysteryAlgorithm` that takes a list of integers as input and returns a modified list based on the following algorithm:
- For each pair of adjacent elements in the input list, if the first element is greater than the second element, swap their posit... | codefeedback |
You are tasked with creating a simple game using the Pygame library in Python. The game is a variation of the classic "Pong" game, where a ball bounces between two paddles. The game should have the following features:
1. The game window should have a title "Pygame壁球" and an icon.
2. The ball image should be loaded fro... | codefeedback |
You are tasked with creating a Python function that processes a Django serializer instance and extracts information about its fields and relationships. The function should take the serializer instance as input and return two dictionaries: one containing information about the fields and another containing information ab... | codefeedback |
You are tasked with implementing a Python class that serves as a registry for machine learning models. The class should be able to store and retrieve different types of classifiers, and it should provide methods for fitting and predicting with these classifiers. Your task is to complete the implementation of the `Class... | codefeedback |
You are tasked with creating a Python function that processes time zone information and extracts the manual hour informed in an event. The function should handle invalid time zone strings and raise a ValueError with an appropriate message.
You are given the following code snippet as a starting point:
```python
logge... | codefeedback |
You are tasked with implementing a Python function that simulates the behavior of the `setns` function from the `butter.clone` module. The `setns` function is used to associate the calling process with the namespaces of another process. The function takes an integer file descriptor `fd` as its argument.
Your task is t... | codefeedback |
You are tasked with creating a program to analyze and manipulate a given string representing a localized description of a technology trainer. The description contains information about the trainer's expertise and skills. Your task is to extract specific details from the description and perform certain operations on the... | codefeedback |
You are tasked with creating a function that takes in a blog object and generates HTML code for displaying the tags associated with the blog. The function should produce a string of HTML anchor tags, each linking to a URL based on the tag's name. If there are multiple tags, they should be separated by commas, with the ... | codefeedback |
You are tasked with implementing a custom convolutional neural network (CNN) layer in Python using the PyTorch library. Your task is to create a class that includes the necessary components for a CNN layer, such as input size, kernel size, and stride, and then define the convolutional and activation operations.
Your c... | codefeedback |
You are tasked with implementing a routing system for a service level agreement (SLA) management application. The routing system will be responsible for directing incoming requests to the appropriate SLA handler based on the type of request and the specified SLA rules.
You are provided with two Rust modules: `routing`... | codefeedback |
You are tasked with creating a program to simulate a simple message queue system using the RabbitMQ messaging broker. Your program should consist of a producer and a consumer, where the producer sends messages to a queue and the consumer receives and processes these messages.
The provided code snippet is a part of the... | codefeedback |
You are working on a machine learning project and need to implement a method for updating model parameters and random effect realizations. The code snippet provided is a part of a Python class that handles these operations. Your task is to create a function that updates the model and random effect realization attribute... | codefeedback |
You are tasked with simulating a simple traffic light control system using Python. The system consists of two stations, station 5 and station 6, which are responsible for controlling the traffic lights at a junction. Station 5 is responsible for the red light, while station 6 is responsible for the green light. The sta... | codefeedback |
You are working on a remote sensing application that processes satellite imagery data. The code snippet provided is a part of a data processing module that retrieves metadata values for different bands of the satellite imagery. The metadata contains various calibration and quantization parameters for each band. The cod... | codefeedback |
You are tasked with implementing a function to calculate the ratio of minor to major elements in an image. The image is represented as a two-dimensional array, where each element corresponds to a pixel value. The minor elements are defined as the pixels with values less than a specified threshold, while the major eleme... | codefeedback |
You are tasked with implementing a program that reads a sequence of integers from the user until a non-integer input is encountered. The program should then calculate and display the sum of all the integers entered.
Your task is to write a Python function `calculate_sum_of_integers()` that takes no arguments. This fun... | codefeedback |
You are tasked with creating a Rust module that manages various aspects of a virtual machine. The module is split into several sub-modules, each serving a specific purpose. Your goal is to design and implement the structure of the module and its sub-modules based on the given code snippet.
Your task is to create the f... | codefeedback |
You are tasked with implementing a generic base service for managing OAuth client details in a Java application. The `OauthClientDetailsService` interface is provided as a starting point, and you need to extend this interface to create a concrete service that can handle CRUD (Create, Read, Update, Delete) operations fo... | codefeedback |
You are tasked with creating a web application that allows users to update their account status. The provided code snippet is a part of the HTML and PHP code for the form used to update the account status. The form includes a dropdown menu for selecting the account status and displays an error message if the status fie... | codefeedback |
You are tasked with implementing a Minecraft mod that introduces a new enchantment called "ActuallyUnbreaking." This enchantment will modify the behavior of items in the game, making them truly unbreakable. When an item with this enchantment is used, it will not lose durability, effectively making it last indefinitely.... | codefeedback |
You are tasked with implementing a function that processes a buffer containing a series of lines. The buffer contains three sections separated by a special separator line. The first section contains a single line representing a positive integer `height`. The second section contains `height` number of lines, each repres... | codefeedback |
You are tasked with implementing a Python function that processes a given text file to extract and count the occurrences of specific license information. The text file contains license information in the form of comments, and your function should identify and count the occurrences of different license types.
You need ... | codefeedback |
You are given a code snippet that represents a simple ASCII art of a "thumbs up" gesture. Your task is to write a program that takes this ASCII art as input and outputs the number of fingers represented by the gesture.
The ASCII art consists of the following characters:
- `)` represents the base of the thumb
- ` ` (sp... | codefeedback |
You are tasked with implementing a function to calculate the Kullback-Leibler (KL) divergence between two probability distributions. The KL divergence measures how one probability distribution diverges from a second, expected probability distribution. It is often used in statistics and machine learning to compare two p... | codefeedback |
You are tasked with creating a Python class that manages various configuration settings for a software build system. The class, named `BuildConfig`, contains several attributes representing different configuration settings. Your goal is to implement a method that prints out the values of these attributes in a specific ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.