instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a custom validation rule for a Laravel application. The goal is to ensure that a given attribute's value is unique among records where a specific condition is met. In this case, you need to create a custom validation rule to check the uniqueness of a "name" attribute in the "customers" tabl...
codefeedback
You are given an array of strings representing words. Your task is to write a function to sort the array of strings in lexicographical order, ignoring the case of the letters. If two words are the same except for the case, they should be sorted in the order they appear in the input array. The function should return the...
codefeedback
You are working on a music player plugin for a Flutter application. The plugin is written in Swift and is responsible for handling various music playback operations. The code snippet provided includes the registration of the plugin and the setup of delegate methods for handling music playback. Your task is to implemen...
codefeedback
You are tasked with implementing a Depth-First Search (DFS) algorithm to traverse a tree structure representing categories in an e-commerce platform. The tree is represented as an array of objects, where each object contains information about a category and its subcategories. Your goal is to write a function that perfo...
codefeedback
You are tasked with implementing a module for handling input events in a game development framework. The provided code snippet is a part of the input handling module and includes the use of various input-related structs and enums. Your task is to create a function that processes input events and performs corresponding...
codefeedback
You are tasked with implementing a function that calculates the total distance traveled by a moving object based on its geographical coordinates. The function takes a list of geographical coordinates as input and returns the total distance traveled. Each geographical coordinate is represented as a tuple of latitude and...
codefeedback
You are tasked with creating a Python function that interacts with a REST API to retrieve and parse data. The function should make an asynchronous HTTP GET request to a specified endpoint, handle query parameters, and validate the response. Write a Python async function `fetch_and_parse_data` that takes in the followi...
codefeedback
You are tasked with implementing a hash table data structure in C++ to store key-value pairs. The provided code snippet includes a set of member functions for manipulating the hash table, along with some member variables. Your task is to implement the missing parts of the hash table class, including the hash function ...
codefeedback
You are working on a Django project that uses a SQLite database and the Django REST framework for API development. Your task is to create a custom renderer class for the REST framework that will render data in a specific format. The custom renderer class should be able to render data in a new format called "CustomForma...
codefeedback
You are tasked with implementing a TypeScript class for managing fields in a receipt advice document. The class should handle various field metadata such as name, description, cardinality, type, and other relevant information. Your task is to create the class and its associated metadata fields based on the given code s...
codefeedback
You are tasked with implementing a function that simulates a simple asynchronous task queue in Swift. The queue should be able to handle multiple tasks and execute them in a sequential manner, ensuring that each task is completed before the next one begins. You are provided with a code snippet that includes the declara...
codefeedback
You are tasked with implementing a custom JSON encoder and decoder for a special model named `SpecialModelName`. This model has a single property named `specialPropertyName` of type `Int64?`. The challenge is to correctly encode and decode this property using a non-standard JSON key format. Your task is to create a cu...
codefeedback
You are tasked with implementing a JavaScript closure that simulates a simple counter with the following requirements: Create a function called `counter` that takes no parameters and returns an inner function. The inner function, when invoked, should increment a counter variable by 1 and return the updated value. The ...
codefeedback
You are tasked with implementing a waypoint mapping system for a robot's navigation module. The robot has a set of waypoints represented as vertices in a graph, and each waypoint is associated with a unique identifier. The robot also has a set of odometry vertices, and the waypoint identifiers are to be mapped to names...
codefeedback
You are tasked with creating a Python GUI application for managing a library's collection of books. The application should allow users to add, delete, and view books. You have been provided with a code snippet from the application's GUI implementation, which uses the PyQt library for creating the user interface. The c...
codefeedback
You are tasked with implementing a program to extract the content within HTML section tags. Given a string containing HTML code, you need to write a function that returns a list of content within all the section tags present in the HTML. For example, given the following HTML code snippet: ```html <section> <h1>Wel...
codefeedback
You are tasked with simulating a scenario involving multiple threads in a Python program. The given code snippet demonstrates a multi-threaded program that involves two functions, `coding` and `drawing`, each executed by a separate thread. Your task is to extend this program to include a third function and ensure that ...
codefeedback
You are tasked with implementing a testing framework for a hub-based system. The hub is responsible for managing various components, including formations. A formation represents a specific configuration of components and requires testing to ensure its proper initialization. The provided code snippet demonstrates a test...
codefeedback
You are tasked with implementing a search algorithm for a simple agent-based system. The system consists of agents moving between locations to achieve specific goals. Your goal is to implement the search method that will find a sequence of actions for the agent to reach its goal. You are given a code snippet that show...
codefeedback
You are tasked with implementing a Swift function that can determine the type of a given keypath. A keypath is a way to reference properties of a type in a type-safe manner. The function should take a keypath as input and return the type of the property it references. Write a Swift function `getPropertyType` that take...
codefeedback
You are tasked with creating a Python decorator that logs the execution time of a given function. The decorator should be able to handle functions with any number of positional and keyword arguments. Your task is to implement the `log_execution_time` decorator and apply it to the `zmq_sub` function provided below. ```...
codefeedback
You are tasked with implementing a Python class that performs data validation and manipulation for a social media platform. The class, named `DataProcessor`, should have methods to validate and process user data before it is stored in a database. Your task is to implement the `DataProcessor` class with the following re...
codefeedback
You are given a list of pairs representing connections between nodes in a graph. Each pair represents an undirected edge between two nodes. Your task is to implement a function that determines whether the given graph is a valid tree. Write a function `is_valid_tree` that takes in the list of pairs and returns `true` i...
codefeedback
You are given a snippet of Java code that contains a method call and a block of code. Your task is to identify the missing parts of the code and complete the method implementation. The method `someMethod` takes two parameters: `argument_list` of type `List<String>` and `name` of type `String`. It is expected to perfor...
codefeedback
You are tasked with creating a program that parses and extracts specific information from a Slurm job submission script. Slurm is an open-source job scheduler used in high-performance computing clusters. The script contains directives and commands that specify the requirements and parameters for a job to be executed on...
codefeedback
You are tasked with creating a script to automate the deployment of a web application using Gunicorn and Django. Gunicorn is a Python WSGI HTTP server for Unix, and Django is a high-level Python web framework. The script should change the directory to /opt/graphite/webapp, execute the Gunicorn Django server with specif...
codefeedback
You are tasked with creating a Python function that processes a given list of integers and performs a specific operation on each element. The operation involves checking if the integer is even or odd and then applying a transformation based on its parity. Additionally, the function should utilize TensorFlow to perform ...
codefeedback
You are tasked with implementing a function to efficiently determine the large polygon in which each small polygon lies. The function will take as input a GeoDataFrame (gdf) of small polygons (e.g., parcels) and a gdf of large polygons (e.g., municipal boundaries). The function should be able to handle spatial indexing...
codefeedback
You are tasked with implementing a simplified version of a blockchain network using Rust. In this problem, you will focus on creating a module for managing connectivity between nodes in the network. The code snippet provided is a part of the configuration process for the connectivity manager. Your task is to implement...
codefeedback
You are tasked with implementing a custom Angular route guard for a project management application. The application has a `ScrumboardComponent` that displays the project's scrum board, and you need to restrict access to this component based on the user's role. The application uses Angular's routing module for navigatio...
codefeedback
You are tasked with implementing a policy management system in Rust. The system should allow the creation of policy proxies that can handle different types of settings based on the provided policy handler. The policy handler is responsible for enforcing the policy rules associated with the settings. You need to define...
codefeedback
You are tasked with implementing a generic parser for various types of tags in a markup language. The provided code snippet shows a Rust implementation of the `From` trait for converting a type `T` into a boxed trait object `Box<dyn ParseTag>`. The `ParseTag` trait represents a tag that can be parsed in the markup lang...
codefeedback
You are tasked with creating a C# class that represents a geometric shape and provides methods to calculate its area and perimeter. The shape can be a rectangle, circle, or triangle. The class should have appropriate properties and methods for each shape, and it should be able to handle both default and custom shapes. ...
codefeedback
You are tasked with implementing a class that manages the status of agents in a continuous integration system. The class should provide methods to check the status of the agents and make decisions based on their status. You are given a partial code snippet for the class: ```python class AgentManager: def __init__...
codefeedback
You are tasked with creating a program that rasterizes a given character using the RustType library. RustType is a pure Rust alternative to libraries like FreeType. The code snippet provided initializes a font from a byte array, sets up a benchmark group for rasterizing a specific character, and configures the measurem...
codefeedback
You are working on a robotics project that involves sensor measurements, mapping, and trajectory tracking. The given code snippet is a part of the data logging process in the project. The `sensor` object is used to reset the pose and take measurements at each step. The measurements are stored in a 2D array `measurement...
codefeedback
You are tasked with implementing a function that calculates the nth Fibonacci number using dynamic programming. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. Your function should efficiently compute the nth Fibonacci number for large values of n. You are provid...
codefeedback
You are working on a robotics project that involves processing images and localizing goals within the environment. The code snippet provided is a part of the image processing and goal localization module. The snippet shows the conversion of an image to a message format and the creation of a goal localization object. Y...
codefeedback
You are tasked with creating a class that calculates the distance between two positions on a field for a robotics competition. The field is represented as a grid, and the positions are defined using the `Position` class, which contains the x and y coordinates, as well as the orientation. The goal is to implement a meth...
codefeedback
You are tasked with implementing a custom message box class in Python that mimics the behavior of the `QMessageBox` class in PyQt. The `QMessageBox` class provides various button roles and standard buttons that can be used to create different types of message boxes. Your task is to create a custom `MessageBox` class wi...
codefeedback
You are tasked with creating a dynamic dropdown menu for selecting locations in a web application. The locations are organized hierarchically into divisions, districts, and upazilas. The divisions are preloaded, and when a division is selected, the corresponding districts should be fetched via an AJAX call and populate...
codefeedback
You are given a snippet of HTML code representing the end of a web page. Your task is to write a program that can identify and count the number of HTML tags present in the given snippet. The HTML tags are defined by the angle brackets `<` and `>`. Each tag consists of a tag name followed by optional attributes. Tags c...
codefeedback
You are tasked with creating a Python program that reads a configuration file, modifies its contents, and then writes the updated configuration back to the file. The configuration file is in JSON format and contains key-value pairs representing various settings. Your program should be able to update existing settings o...
codefeedback
You are tasked with creating a program that simulates a simple package manager for a programming language. The package manager should be able to handle dependencies, resolve conflicts, and generate a list of packages to be installed. You are given a code snippet representing a Swift package manifest file (`Package.swi...
codefeedback
You are tasked with implementing a custom Nearest Centroid classifier using Python. The Nearest Centroid classifier is a simple and efficient algorithm for classifying data points based on their proximity to the centroids of the classes they belong to. Your task is to create a class `CustomNearestCentroid` that mimics ...
codefeedback
You are tasked with implementing a simplified version of a convolutional neural network (CNN) model for image classification. The provided code snippet outlines the structure of the model, which is based on the ResNet architecture. Your goal is to complete the implementation of the `create_imagenet_model_basic` functio...
codefeedback
You are given a list of integers `qs` representing queries, and two lists of strings `mot` and `sat` representing words. Additionally, you are given an integer `k`. Your task is to generate a list `res` such that each element at index `i` in `res` is the concatenation of the `mot` and `sat` strings at indices `i` and `...
codefeedback
You are tasked with implementing a circular dependency detection algorithm for a system that uses shared pointers. Circular dependencies occur when two or more objects have references to each other, directly or indirectly, creating a loop in the reference graph. Your task is to write a function that detects circular de...
codefeedback
You are given a list of 3D vertex coordinates in the format "VRTX id x y z", where id is the vertex identifier and x, y, z are the coordinates. Each line represents a single vertex. Your task is to write a program to calculate the Euclidean distance between each pair of vertices and find the pair with the shortest dist...
codefeedback
You are tasked with creating a Python class that models a music library using SQLAlchemy for database interaction. Your class should provide methods for adding and retrieving music albums, artists, music tracks, and user information. Additionally, you need to implement a method for retrieving a list of music tracks bas...
codefeedback
You are tasked with creating a program to manage a database of customer complaints. The program should allow users to add new complaints, view existing complaints, and delete complaints from the database. You are provided with a partial code snippet from a Laravel migration file, which is used to manage the database sc...
codefeedback
You are tasked with implementing a function that evaluates the performance of a machine learning model using the COCO (Common Objects in Context) evaluation metric. The COCO evaluation metric is commonly used in object detection and instance segmentation tasks. Your goal is to write a Python function that takes a set o...
codefeedback
You are tasked with implementing a class `JaroDist` that calculates the Jaro distance between two strings. The Jaro distance is a measure of similarity between two strings and is calculated based on the number of matching characters and transpositions. The Jaro distance is defined as follows: - Let `m` be the number o...
codefeedback
You are tasked with implementing a debounce function in Python. A debounce function is a utility used to limit the rate at which a function is called. It ensures that a function is not called more often than a specified time interval, even if it is triggered multiple times within that interval. You are given a code sn...
codefeedback
You are working on a computer vision project that involves processing images and their associated annotations. The project directory structure includes several Python modules for handling different aspects of the data. The code snippet provided gives an example of importing modules related to image processing. Your ta...
codefeedback
You are tasked with creating a Python function that simulates a simplified version of the Django admin.autodiscover() functionality. The admin.autodiscover() function is used in Django to automatically discover and register admin modules for models in an application. Your task is to implement a function that takes a li...
codefeedback
You are tasked with implementing a RANSAC (Random Sample Consensus) algorithm to robustly fit a line to a set of 3D coordinates. The given code snippet provides a starting point by generating coordinates of a line, adding Gaussian noise to the coordinates, and then applying the RANSAC algorithm to fit the line using in...
codefeedback
You are tasked with implementing a simplified version of a stack data structure in Java. Your stack should support the following operations: 1. `push(int val)`: Add an element to the top of the stack. 2. `pop()`: Remove the element from the top of the stack and return its value. 3. `peek()`: Return the value of the ele...
codefeedback
You are tasked with implementing a custom inspector for a Unity script called `Comments`. The `Comments` script likely represents an object in a game or application that allows users to leave comments or feedback. Your goal is to create a custom editor for this script that provides a specialized interface for editing a...
codefeedback
You are tasked with implementing a Python module version checker. Your goal is to create a function that takes a module name as input and returns its version number. The version number can be found in the module's `_version` attribute, and if the attribute is not found, the function should return "unknown". Additionall...
codefeedback
You are tasked with creating a Python package for managing and analyzing data. The package should include a module for data manipulation, a module for statistical analysis, and a module for visualization. Your task is to write a `setup.py` script using the `setuptools` library to properly configure the package for dist...
codefeedback
You are working on a script to automate file transfers using FTP (File Transfer Protocol). The script needs to connect to an FTP server, retrieve the hash value of a remote file, and then download the file to the local directory. The code snippet provided is a part of the script and shows the sequence of commands to be...
codefeedback
You are working on a game development project and need to implement a function to manage the spawning of mobs in a game world. The game world is represented as a grid, and mobs are spawned at specific coordinates on this grid. Each mob has a unique identifier and a set of coordinates where it should be spawned. Your ta...
codefeedback
You are tasked with implementing a function to draw a triangle on a 64x64 pixel grid using the `embedded-graphics` library in Rust. The function should take three points as input, along with stroke and fill color options, and then render the triangle on the grid. Your task is to implement the `draw_triangle` function,...
codefeedback
You are tasked with implementing a Python class method that processes an input image using OpenCV library. The method should resize the image to a specified height and width, and then perform a channel manipulation operation. The class has an attribute `input_shape` which is a tuple containing the number of channels, h...
codefeedback
You are tasked with implementing a function that calculates the total distance traveled by a particle moving along a straight line. The particle starts at the origin (position 0) and moves to various positions specified in a list. Each position in the list represents the distance traveled from the previous position. Fo...
codefeedback
You are tasked with creating a program that checks for the usage of a specific package in a set of Go files, excluding a known special case. Your program should search for occurrences of the package "ioutil" in the Go files within a given directory, but it should exclude a file named "stdlib.go" from the search. If any...
codefeedback
You are tasked with implementing a Python class that evaluates a machine learning model using a specific evaluation method. The class should provide a method to retrieve the model function and an evaluator method with a specified number of iteration steps. Your task is to complete the implementation of the `BertEvalua...
codefeedback
You are tasked with implementing a DNA sequence manipulation program. The program should read DNA sequences in FASTA format from standard input, process the sequences, and then output the results. The input DNA sequences are represented as a header and a sequence of nucleotides. The program should perform the following...
codefeedback
You are tasked with implementing a Python class that manages ownership relationships between objects. The class should allow objects to be owned by other objects, and it should provide a method to update the ownership relationship recursively. Your task is to implement the `OwnershipManager` class with the following ...
codefeedback
You are tasked with optimizing a function that performs a series of transformations on a collection of elements. The function is currently being benchmarked using the `criterion` crate in Rust. Your goal is to improve the performance of the function by optimizing the code and reducing the time it takes to execute. The...
codefeedback
You are tasked with implementing a function to simulate a cellular automaton. A cellular automaton is a discrete model studied in automata theory and computer science. It consists of a grid of cells, each in one of a finite number of states. The grid can be in any finite number of dimensions. For this problem, we will ...
codefeedback
You are tasked with creating a middleware function for a Node.js application that handles token refresh for authenticated users. The application uses the NestJS framework, which leverages TypeScript and decorators for defining routes and middleware. Your task is to implement the `refresh` function, which is a POST end...
codefeedback
You are tasked with creating a Python class that represents a restaurant's cuisine. The class should have attributes for the cuisine type and platform type. Additionally, you need to implement a method to check if the platform type is not None. Create a class `RestaurantCuisine` with the following specifications: - Th...
codefeedback
You are tasked with implementing a function to calculate the checksum of a given array of bytes using the CRC-16-CCITT algorithm. The CRC-16-CCITT algorithm is a widely used cyclic redundancy check (CRC) algorithm that produces a 16-bit checksum. The algorithm uses a polynomial of 0x1021 and an initial value of 0xFFFF....
codefeedback
You are tasked with implementing a custom text field in Swift that handles phone number input and country selection. The text field should conform to the `FPNTextFieldDelegate` protocol, which includes the following methods: 1. `fpnDidSelectCountry(name: String, dialCode: String, code: String)`: An optional method that...
codefeedback
You are tasked with optimizing the sorting algorithm used in a custom Python application. The application currently imports three sorting algorithms from separate modules: Bubble_sort, Insertion_sort, and Get_duration_execution_time. The Get_duration_execution_time module provides a function to measure the execution ti...
codefeedback
You are tasked with implementing a script to automate the testing process for a software project. The script needs to handle the execution of different test suites based on certain conditions. The script should also support coverage analysis and the ability to rerun tests with non-default configurations if specific con...
codefeedback
You are tasked with implementing a data loading and interpolation system for a flight simulation program. The program needs to load data from a file and interpolate the values for various flight parameters. The provided code snippet initializes variables for yaw, pitch, roll, north, east, and down interpolation, and de...
codefeedback
You are tasked with implementing a memory cache system for storing and retrieving images in a mobile application. The provided code snippet is part of a method responsible for caching and forwarding new image results to a consumer. The method checks certain conditions before caching and forwarding the new result. Your...
codefeedback
You are tasked with implementing a function to create a meme generator in Swift. The `Meme` struct provided represents a meme, containing the top and bottom strings for text, the original image, and the memed image. Your task is to implement a function `generateMeme` that takes in the top and bottom strings, as well as...
codefeedback
You are tasked with implementing a custom `CardObjectIdentifierType` protocol in Swift for identifying different types of card objects. The protocol should provide a way to represent the identifier as `Data`, validate the identifier, and conform to the `Equatable` and `ExpressibleByStringLiteral` protocols. Your task ...
codefeedback
You are tasked with implementing a function to calculate the distance from a set of points to a 3D mesh using different engines. The function `distance_to_mesh(mesh, pts, engine)` takes in a 3D mesh, a set of points, and an engine type as input and returns the squared distances, face indices, and closest points for eac...
codefeedback
You are tasked with implementing a class that simulates a game called "Token Removal." In this game, players take turns removing tokens from a sequence. The class should provide methods to remove tokens from the start of the sequence and to retrieve the current sequence of tokens. You are given a code snippet that dec...
codefeedback
You are tasked with implementing a Python function that calculates the softmax loss and its gradient with respect to the input scores. The softmax function is commonly used in machine learning for multi-class classification problems. The function takes as input the scores for each class and the correct labels, and retu...
codefeedback
You are tasked with implementing a simple database system for storing and retrieving projections. A projection is a representation of an object in a different form, such as a transformation of data from one format to another. Your goal is to create a data structure and methods to store and retrieve projections efficien...
codefeedback
You are tasked with implementing a test suite for a TSK partition directory. The TSK (The Sleuth Kit) is a library and collection of command-line digital forensic tools. Your goal is to create a test suite that sets up the necessary objects for testing the TSK partition directory functionality. Your task is to impleme...
codefeedback
You are tasked with implementing a simplified version of an onboarding flow manager in Swift. The provided code snippet contains two functions within a class that are responsible for creating different types of onboarding flows. Each onboarding flow is represented by an instance of the `OnboardingFlow` class, which is ...
codefeedback
You are tasked with implementing a graph data structure to represent Pinterest users and their boards. The given code snippet is part of a Python class method that processes data from the Pinterest API to create nodes and edges in the graph. The `result` variable contains data retrieved from the API, and the code itera...
codefeedback
You are tasked with creating a script to automate the versioning and building of a Docker image for a Django application. The provided code snippet is a part of the script, which is responsible for incrementing the build number, tagging the Docker images, and updating the build number in a file. The script reads the c...
codefeedback
You are tasked with creating a program to retrieve and store tweets from a specified topic for a list of unique users. The program will need to handle the selection of the topic, retrieval of user information from a CSV file, and the use of an API to retrieve and store tweets for the selected topic and users. You are ...
codefeedback
You are working on a warehouse management system that involves updating inventory details and handling transactions. The code snippet provided is a part of a larger system that manages inventory updates and transaction handling. The code snippet is written in PHP and uses Yii framework functions for database transactio...
codefeedback
You are working on an image processing project and need to implement a function to adjust the intensity of an input image based on certain percentile values. The function takes an input image `img` and a percentile value `p`. It then calculates the intensity range based on the given percentile and rescales the intensit...
codefeedback
You are tasked with implementing a function that determines whether a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. You need to create a function `isPalindrome` that t...
codefeedback
You are tasked with creating a simple assembly program that calculates the product of two numbers. The program should be written in NASM (Netwide Assembler) and should be compatible with the multiboot specification for bootloading. Your task is to write an assembly program that takes two integers as input and calculat...
codefeedback
You are given a Python code snippet that defines a function `f` and a class `BoundedLinear`. Your task is to implement a new method within the `BoundedLinear` class and use it to solve a specific problem. Your task is to implement a method `find_minimum_point()` within the `BoundedLinear` class. The method should find...
codefeedback
You are tasked with creating a Python class for handling astronomical data from brown dwarfs. Brown dwarfs are substellar objects that are too massive to be considered planets, yet are not massive enough to sustain nuclear fusion of hydrogen in their cores, which is a defining characteristic of stars. Your task is to i...
codefeedback
You are tasked with implementing a class that generates feedback profiles for a quiz application. The `QuizFeedbackProfile` class should have the following functionalities: 1. It should have a method `GenerateProfile` that takes in a list of quiz scores and returns a feedback profile based on the scores. 2. The feedba...
codefeedback
You are tasked with creating a command-line tool to manage aliases for various commands. The tool should allow users to add, remove, and list aliases, as well as execute the commands associated with the aliases. Your task is to implement a Python program that provides the following functionalities: 1. Add an alias: Us...
codefeedback
You are tasked with creating a program that processes user input to generate a personalized greeting message with various formatting options. The program should prompt the user for their name and then output the greeting message with different alignment and fill characters. Write a Python program that accomplishes the...
codefeedback