instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Java program that utilizes reflection to analyze and print the properties of a given object. Reflection is a powerful feature in Java that allows the examination of classes, interfaces, fields, and methods at runtime. In this problem, you are required to implement a method that takes an o... | codefeedback |
You are tasked with creating a Python function that reads a CSV file containing data and generates a correlation matrix plot to visualize the relationships between variables. The function should take the file path as an argument and display the correlation matrix plot using a popular visualization library such as Matpl... | codefeedback |
You are tasked with implementing a custom `loadImage` method for a `featuredButton` in a `ButtonImageTableViewCell` class. The `loadImage` method should asynchronously load an image from a given URL and set it as the background or foreground image for the button, based on the provided parameters. You are also required ... | codefeedback |
You are tasked with implementing a Python class that can perform matrix factorization using a technique called Field-aware Factorization Machines (FFM). FFM is a supervised learning algorithm that can be used for classification, regression, and ranking tasks. The code snippet provided includes the names of three classe... | codefeedback |
You are tasked with creating a function that extracts the content within a specific HTML tag from a given string. The function should take two parameters: the HTML tag name and the input string. The function should return the content within the specified tag.
For example, given the input string:
```
<div style="border... | codefeedback |
You are tasked with implementing a simple instruction processor for a hypothetical computer architecture. The processor is capable of executing a set of predefined instructions, each represented by a unique opcode. Your goal is to write a function that processes these instructions and generates the corresponding assemb... | 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 are given the following code snippet as a starting point:
```php
foreach($raw... | codefeedback |
You are tasked with implementing a function to encode a CoAP (Constrained Application Protocol) extended error using the given code snippet as a reference. CoAP is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. The provided code snippet is a part o... | codefeedback |
You are tasked with creating a simple command-line tool to manage a list of tasks. The tool should allow users to add tasks, mark tasks as completed, list all tasks, and remove tasks. The tool should be implemented using Python and should provide a simple and intuitive interface for users to interact with their tasks.
... | codefeedback |
You are tasked with implementing a task scheduler for a mobile application. The scheduler should allow the user to schedule tasks to be executed when the application transitions between different states, such as entering the foreground, becoming active, or terminating. Each task is represented by a closure (a block of ... | codefeedback |
You are tasked with implementing a binary tree data structure in Rust. The tree should have the following functionalities:
1. Insert a new node into the tree.
2. Search for a specific value in the tree.
3. Traverse the tree in-order and return the values in a vector.
4. Get the value of the node at a specific index, wh... | codefeedback |
You are tasked with creating a web application that manages user data and roles. The given code snippet is a part of a Laravel controller for handling user-related operations. The `add_users` function is responsible for adding new users to the system. The `if` condition checks if the session contains data for existing ... | codefeedback |
You are tasked with creating a program that analyzes and manipulates Rust code snippets. Your program needs to implement a function that processes a given Rust code snippet and extracts specific information from it.
The function should take a Rust code snippet as input and return a tuple containing three elements:
1. ... | codefeedback |
You are working for a tech company that wants to identify the most popular features mentioned in customer feedback. Your task is to implement a function `popularNFeatures` that takes in the following parameters:
- `numFeatures`: an integer representing the number of features in the company's database.
- `topFeatures`: ... | codefeedback |
You are tasked with implementing a function to find the starting index of a substring (needle) in a string (haystack). If the needle is not found in the haystack, the function should return -1. You are not allowed to use any built-in string search functions.
Write a function `strStr(haystack, needle)` that takes in tw... | codefeedback |
You are tasked with creating a Python program that simulates a simple banking system. The program should allow users to create a new bank account, deposit money, withdraw money, and check their balance. The program should display a welcome message when it is run.
Your task is to write a Python program that fulfills th... | codefeedback |
You are tasked with creating a script that monitors the execution of a set of commands and records their exit statuses. Your script should take a list of commands as input and execute each command, capturing its exit status. The exit statuses should be written to a file named `test-exit-status` in the user's home direc... | codefeedback |
You are tasked with creating a program that interacts with a YouTube downloader library to search for and download a video based on a given name. The code snippet provided is a part of an asynchronous function that uses the `ytdl` function to search for a video on YouTube based on the provided name.
Your task is to im... | codefeedback |
You are tasked with implementing a function to process CIM (Common Information Model) files and convert them to MATPOWER format. The CIM files contain information about the power system, including generators, loads, and transmission lines. The function `CIM2Matpower.cim_to_mpc` takes two arguments: `cimfiles`, a list o... | codefeedback |
You are tasked with implementing a class that serves as a data access object (DAO) for managing authors in a library management system. The provided code snippet outlines the interface `AuthorMapper`, which defines methods for interacting with the underlying data store. Your task is to create a concrete implementation ... | codefeedback |
You are tasked with creating a program to manage a music library by relating songs to their respective artists. Your program should allow users to add new songs and artists, associate songs with artists, and retrieve a list of songs by a specific artist. To achieve this, you need to implement a class-based solution usi... | codefeedback |
You are given a 2D grid representing a game board with cells that can be either empty or occupied by obstacles. The game board is represented by a 2D array of characters, where 'E' represents an empty cell and 'O' represents an obstacle. Your task is to write a function that checks if there exists a path from the top-l... | codefeedback |
You are tasked with implementing a custom hash map data structure in Python. The hash map should support the following operations:
1. `put(key, value)`: Insert a key-value pair into the hash map. If the key already exists, update the value.
2. `get(key)`: Return the value associated with the given key. If the key does ... | codefeedback |
You are tasked with creating a Python function to retrieve annotations from the Hypothes.is platform for a given URI. The function should take the URI and an API key as input and return a sequence of mappings representing the annotations. Your task is to implement the `get_annotations` function and ensure that it retri... | codefeedback |
You are tasked with creating a custom widget for a web form using Python's Zope framework. The widget should be an image button that can be used as a form input element. Your task is to implement the `ImageWidget` class that extends the functionality of the `ButtonWidget` class and adheres to the `IImageWidget` interfa... | codefeedback |
You are given a file named "day8.input" containing a list of instructions for a handheld game console. Each instruction consists of an operation (acc, jmp, or nop) and an argument (a signed integer). The console has a single accumulator that starts at 0. The instructions are executed sequentially, and the program termi... | codefeedback |
You are given a dataset containing 2D points represented as (x, y) coordinates. Your task is to implement a function that rotates the dataset by a specified angle in degrees around the origin (0, 0). The dataset is represented as a list of tuples, where each tuple contains the x and y coordinates of a point. The rotati... | codefeedback |
You are tasked with implementing a function that processes a given React component and returns a modified version of it. The input component is a higher-order component (HOC) that wraps another component and provides additional functionality. Your task is to extract the children of the wrapped component and modify them... | codefeedback |
You are tasked with creating a script to automate the setup and cleanup of a headless environment for running Godot game engine with a dummy sound device. The script should start the dummy sound device using PulseAudio, run Godot with X11 display using xvfb-run, and perform necessary cleanup after Godot execution.
You... | codefeedback |
You are tasked with creating a script that takes a version number as input and increments the last segment of the version number by 1. For example, given the input "1.2.3", the script should output "1.2.4".
Write a bash script that takes a version number as a command-line argument and increments the last segment of th... | codefeedback |
You are tasked with creating a program that simulates a simplified version of a version control system. The program should be able to handle different types of version bumps based on user input.
Your program should accept a single string input representing the type of version bump to perform. The input can be one of t... | codefeedback |
You are tasked with creating a TypeScript class that manages a collection of unit attributes and attribute groups. The class should provide methods to retrieve specific attributes and attribute groups from the collection.
You are given a partial code snippet that defines two getter methods, `attribute` and `attributeG... | codefeedback |
You are tasked with implementing a serverless Azure Function to handle HTTP POST requests for creating new artist entries in a database. The function is named `NewArtist_post` and is triggered by an HTTP POST request to the `/artists` route. The function takes in an `Artist` object in the request body and a `HttpReques... | codefeedback |
You are tasked with creating a Rust program that utilizes the `build_helper` crate to perform a series of build operations. The `build_helper` crate provides various utilities for building and managing projects in Rust. Your program should demonstrate the usage of the `build_helper` crate to perform the following tasks... | codefeedback |
You are given two 32-bit numbers, N and M, and two integer indices, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that there are enough bits to fit M into N, i.e., if M = 10011, you can assume that there are at least 5 bits between j and i. You would not, for e... | codefeedback |
You are tasked with implementing a Merkle tree data structure in TypeScript. A Merkle tree is a fundamental data structure used in cryptography and computer science. It is a binary tree in which each non-leaf node is the hash of the concatenation of its child nodes. The Merkle tree is used to efficiently verify the int... | codefeedback |
You are working on a parallel computing project using the ARMCI (Aggregate Remote Memory Copy Interface) library, which provides one-sided communication and remote memory access operations. Your task is to implement a specific remote memory write (RMW) operation based on the given code snippet.
The code snippet provid... | codefeedback |
You are tasked with implementing a simple dependency injection framework in Java. The framework should provide the ability to define beans and their dependencies, and then retrieve fully constructed beans from the application context.
You are given the following code snippet as a starting point:
```java
import com.my... | codefeedback |
You are tasked with implementing a Python decorator that takes a list of keywords as input and modifies the behavior of a function. The decorator should check if any of the input keywords are present in the arguments of the decorated function. If any keyword is found, the function should print a warning message and ret... | codefeedback |
You are tasked with creating a script to automate the compilation and execution of a C++ program using the Clang++ compiler. The script should handle the inclusion of necessary libraries and flags, as well as the execution of the compiled program.
Given the code snippet provided, you need to write a Bash script that a... | codefeedback |
You are tasked with implementing a class method that parses a custom HTTP request header and extracts the header fields and their values. The HTTP request header is represented as a string `self.reqhdrs`, where each header field is encoded as a series of characters. The format of the header is as follows:
- The header ... | codefeedback |
You are tasked with implementing a function that can determine the depth of nested HTML div elements in a given string. The depth of a div element is defined as the number of its parent div elements. For example, a div element directly inside the body tag has a depth of 1, while a div element inside another div element... | codefeedback |
You are tasked with creating a Python function that processes accuracy data from a directory structure and extracts the accuracy value for a given round ID. The function should take the directory path and round ID as input and return the accuracy value if it exists, or "Accuracy data not found" if the round ID or accur... | codefeedback |
You are tasked with creating a custom decorator in Python for a web application framework. The decorator should handle input validation for API endpoints by utilizing the `UseInterceptors`, `UsePipes`, and `ValidationPipe` features provided by the framework.
Your task is to implement a `@validate_input` decorator that... | codefeedback |
You are tasked with creating a program that simulates the behavior of the `mkdir` command in a Unix-like operating system. The `mkdir` command is used to create directories, and the `-p` option allows for the creation of parent directories as needed. Your program should take a list of directory paths as input and creat... | codefeedback |
You are tasked with creating a Python function that simulates a simple text-based adventure game. The game will involve the player navigating through different rooms, making choices, and encountering various challenges. The game will be text-based, and the player's progress will be determined by their choices.
Your ta... | codefeedback |
You are tasked with implementing a dataset management system for a machine learning framework. The system should support the creation and retrieval of various datasets based on user-defined hyperparameters. Your task is to implement a class-based dataset management system that adheres to the given specifications.
You ... | codefeedback |
You are given a list of integers from 0 to 7, and you are required to perform a specific set of operations on this list. Your task is to implement a function that takes this list as input and returns a modified list based on the following rules:
1. Remove all odd numbers from the list.
2. Square each remaining number ... | codefeedback |
You are tasked with creating a script to manage a directory structure. Your script should take a list of directory names as input and perform the following operations for each directory:
1. If the directory already exists, it should be removed.
2. A new directory with the same name should be created.
Your script shou... | codefeedback |
You are working on a file management system that involves creating directories based on certain criteria. Your task is to write a Python function that takes a list of directory paths as input and creates the directories if they do not already exist. Each directory path is a string representing the directory structure.
... | codefeedback |
You are working on a system that manages remote commands and their execution. The given code snippet is a simplified representation of a class that handles a specific command called "stat" for a file specified by the `filename` attribute. The `__init__` method initializes the class with the filename, and the `__call__`... | codefeedback |
You are tasked with implementing a function that processes a jagged array and returns a modified version of the array based on certain conditions. The input consists of a jagged array represented by `slicestarts`, `slicestops`, `slicecontent`, and `tail`. The function should handle the following cases:
1. If the `cont... | codefeedback |
You are tasked with creating a food ordering system for a restaurant. The system should display a popup window with the available food items when the `showFoodPopupWindow()` function is called. The popup window should allow the user to select the desired food items and specify the quantity for each item. Once the user ... | codefeedback |
You are tasked with implementing a simplified version of a reactive system using Swift. The system consists of a function that takes an initial state, a reducer function, and an array of feedback loops, and returns a Driver representing the state of the system.
The `system` function signature is as follows:
```swift
f... | codefeedback |
You are tasked with implementing a Python class method that processes German words to extract their stems for pun compound creation. The method should remove the schwa sound from the end of a noun, if present. The schwa sound is a neutral vowel sound often represented by the letter "e" in German.
You are provided with... | codefeedback |
You are tasked with creating a script to automate the compilation of Octave plugins for the PsychToolbox library on macOS. The provided code snippet shows two commands using the `osx2oct` tool to build Octave plugins for the `WaitSecs` and `Screen` modules. The commands include various flags, input file paths, and verb... | codefeedback |
You are tasked with implementing a plugin system for a software application. The plugin system should allow plugins to update their data based on the input provided. Each plugin has a unique identifier and a set of data objects to be updated.
You are given a Java code snippet that iterates through a map of plugins and... | codefeedback |
You are tasked with implementing a custom array data structure in Rust. The array should support basic operations such as creating a new array, adding elements, accessing elements by index, and removing elements. Additionally, you need to define methods for finding the minimum and maximum elements in the array.
Your t... | codefeedback |
You are tasked with creating a program that generates a specific pattern based on the given description. The pattern will be created by manipulating the characters in the given description string. The manipulation involves shifting each character by a certain number of positions in the alphabet, wrapping around if nece... | codefeedback |
You are tasked with implementing a class that determines whether a given target node is within a specified maximum distance from the original end point of a path. You are provided with a code snippet that includes a class `EndingConditionProximity` and its method `TargetFound`. Your task is to create a similar class an... | codefeedback |
You are tasked with implementing a 3D vector class in Rust to perform various operations. The class should support vector addition, subtraction, scalar multiplication, dot product, cross product, and normalization.
Your task is to complete the implementation of the `Vec3` struct and its associated methods. The `Vec3` ... | codefeedback |
You are tasked with creating a simple task management system using Django REST framework. Your goal is to implement a viewset for tasks and set up the necessary URL patterns to access the task-related endpoints.
You have been provided with a code snippet that sets up a simple router and registers a `TaskViewSet` for t... | codefeedback |
You are tasked with creating a memory monitoring system for a Python application using the `pikos` library. The `pikos` library provides a set of monitoring tools for Python programs to track and analyze resource usage, such as memory and CPU usage. In this problem, you will focus on implementing a memory monitoring sy... | codefeedback |
You are tasked with implementing a shopping cart feature for an e-commerce application using object-oriented programming principles. The shopping cart should be able to store items with their respective product data, including the product ID, price, and quantity.
You are provided with a `CartItemProductData` class, wh... | codefeedback |
You are tasked with implementing a function that calculates the area of a polygon defined by a set of vertices in a 2D plane. The polygon is represented by a list of points, where each point is defined by its latitude and longitude coordinates. You are required to use the Haversine formula to calculate the area of the ... | codefeedback |
You are given a code snippet that uses the Visualization Toolkit (VTK) library to create a 2D circular shape using polar coordinates. The code snippet initializes a vtkPolyData object, creates points and lines to form the circular shape, and inserts them into the vtkPolyData object. Your task is to complete the code by... | codefeedback |
You are tasked with creating a function that parses HTML code to extract the URLs from anchor tags. Given an HTML snippet as input, you need to write a function that returns a list of all the URLs present in the anchor tags.
For example, given the following HTML snippet:
```html
<p><a href="<?=base_url('/home/member')... | codefeedback |
You are given a function `cutBarDFS(m, n, now)` that simulates the process of cutting a bar of length `n` into smaller pieces using a specific cutting rule. The function takes three parameters:
- `m`: an integer representing the minimum length of a piece that can be cut off at once.
- `n`: an integer representing the i... | codefeedback |
You are tasked with implementing a custom weight initialization method for a neural network using PyTorch. The goal is to create a custom weight initialization function similar to the Xavier uniform initialization method provided by PyTorch's `torch.nn.init.xavier_uniform_` function.
Your custom weight initialization... | codefeedback |
You are tasked with implementing a pagination feature for a banking application. The application has a method `getBankList()` that retrieves a list of banks from a remote server. Additionally, there is a method `dataSearch()` that is called when the user performs a search operation. This method resets the pagination to... | codefeedback |
You are tasked with creating a Python module that simulates a simple text-based game. The game involves a player navigating through a series of rooms, each with its own set of challenges and rewards. To accomplish this, you will need to implement various classes and methods to manage the game's state and interactions.
... | codefeedback |
You are tasked with creating a Python unit test for a class that represents a simple calculator. The class has methods for addition, subtraction, multiplication, and division. You need to write a test case that ensures the setup method is called before each test method to initialize the calculator.
Your task is to imp... | codefeedback |
You are tasked with creating a function that parses HTML code and extracts the classes of all the div elements with a specific class prefix. Your function should take in the HTML code and the class prefix as input and return a list of all the classes that match the prefix.
Write a function `extractClasses(html, prefix... | codefeedback |
You are tasked with implementing a module for Groth16 zero-knowledge proof system in Rust. The Groth16 module is used for generating and verifying zero-knowledge proofs, which are cryptographic protocols that allow one party (the prover) to prove to another party (the verifier) that a statement is true, without reveali... | codefeedback |
You are tasked with implementing a custom layout for a collection view in an iOS app. The goal is to create a grid layout where the size of each item is dynamically calculated based on the available width and a specified number of items per row.
You are given the following code snippet from the `StartViewController` c... | codefeedback |
You are tasked with implementing a custom hook in React that manages the state of a URL and synchronizes it with the browser's localStorage. The hook should update the localStorage whenever the URL changes and vice versa. You are provided with a code snippet that demonstrates the usage of the hook and its integration w... | codefeedback |
You are tasked with creating a validation function for a specific entity in a software system. The system uses a custom validation framework where entities have to implement their own validation rules. The provided code snippet is a part of the validation framework and demonstrates the validation function for a specifi... | codefeedback |
You are tasked with creating a Python script that parses command-line arguments using the `argparse` module. Your script should accept two optional arguments: `--input` for specifying the input file and `--output` for specifying the output file. If the `--input` argument is not provided, the script should default to re... | codefeedback |
You are tasked with implementing an algorithm to detect drowsiness in a person's eyes using the Eye Aspect Ratio (EAR) technique. The EAR is a measure used in facial recognition to determine the openness of an eye. The algorithm will analyze a series of frames from a video feed and determine if the person's eyes have b... | codefeedback |
You are working on a medical imaging project and need to implement a binary thresholding algorithm using the Insight Segmentation and Registration Toolkit (ITK) library in C++. The given code snippet sets up the binary thresholding filter and defines the input and output image types. Your task is to complete the implem... | codefeedback |
You are tasked with implementing a function that checks whether a given string is a valid 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... | codefeedback |
You are tasked with implementing a command-line argument parser for a program that displays a spectrum. The provided code snippet contains a function `main` and conditional logic for returning a parser. Your task is to complete the implementation of the argument parser and ensure that the `main` function can be used to... | codefeedback |
You are tasked with implementing a type deduction algorithm for comparing two values of different types in C++. The goal is to determine the common type of the two values and then perform a comparison operation between them. The common type is the type that both values can be converted to without loss of information. T... | codefeedback |
You are tasked with creating a Bash script to automate the process of checking for updates on a Linux system. The script should perform the following tasks:
1. Check if the system is connected to the internet.
2. If connected, check for updates using the package manager (apt-get for Debian-based systems or yum for Red... | codefeedback |
You are tasked with creating a Python function that processes a directory containing commit files and returns a list of the most recent commit files in the directory. Each commit file is named with a timestamp and has a ".zip" extension. The function should sort the commit files based on their modification time and ret... | codefeedback |
You are given a code snippet that contains a while loop and some conditional statements. Your task is to analyze the code and determine the output that will be printed when the code is executed.
The code snippet is as follows:
```python
i = 0
while(True):
if i+1<5:
i = i + 1
continue
print(i+... | codefeedback |
You are tasked with implementing a function to calculate the actual frame correction needed to reach the root cause of an error in a software system. The function takes in the message of the error, the amount of frames to skip, and the exception information tuple. Your task is to write a function that calculates the ac... | codefeedback |
You are tasked with implementing a custom attribute validation system for a C# application. The system should allow developers to define input parameters for methods or properties using custom attributes, and then validate the input based on the defined rules. Your task is to create a class that can parse and validate ... | codefeedback |
You are tasked with implementing a simple Android application that involves managing the lifecycle of fragments. In Android development, the lifecycle of a fragment is crucial for managing its state and behavior. The provided code snippet is a base fragment class that implements the `LifecycleRegistryOwner` interface a... | codefeedback |
You are given an array of integers representing the scores of a game. Your task is to find the length of the longest increasing subsequence (LIS) in the array. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. An i... | codefeedback |
You are tasked with implementing a typed quadtree data structure in Rust. A quadtree is a tree data structure in which each internal node has exactly four children. It is commonly used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions. In this problem, you will create a t... | codefeedback |
You are tasked with implementing a text difference visualizer that highlights the changes between two versions of a text. The provided code snippet is a part of the visualizer's logic, which uses the `ChangeTag` enum to determine the type of change (delete, insert, or equal) and then prints the corresponding visual rep... | codefeedback |
You are tasked with implementing a command-line tool called `PyAsciiArt.py` that processes image files and converts them into ASCII art. The tool should accept one or more image files as input and provide various options for adjusting the output, such as contrast, resizing, and output file specification.
The command-l... | codefeedback |
You are tasked with implementing a function to determine whether a given line segment intersects with a quadrangle in a 2D plane. The quadrangle is defined by a list of four points, and the line segment is defined by its start and end positions. The intersection test should consider the line segment as part of the inte... | codefeedback |
You are tasked with creating a command-line interface (CLI) for a simple task management system. The CLI should accept commands to add tasks, list tasks, and set the verbosity level for task output. Your goal is to implement the CLI using Python's `argparse` module and ensure that it functions as expected.
Your task i... | codefeedback |
You are given a string `spill` representing a spill of parameters and their values. The spill is formatted as follows: the first element is an integer `n_par` representing the number of parameters, followed by `n_par` parameter names, and then `n_par`^2 parameter values. For example, if `spill` is "2,a,b,1,2,3,4", it r... | codefeedback |
You are tasked with implementing a function that can determine the number of namespaces in a given C# source code file. A namespace in C# is a way to organize code elements and prevent name collisions. It is defined using the `namespace` keyword followed by the namespace name and a code block containing the namespace's... | codefeedback |
You are tasked with creating a password validation function for a web application. The function should take a password as input and return a boolean value indicating whether the password meets the specified criteria.
The criteria for a valid password are as follows:
1. The password must be at least 8 characters long.
... | codefeedback |
You are working on a software project and need to generate code coverage reports for the project's test suite. The project is written in Rust, and you are using the `grcov` tool to generate HTML code coverage reports. The code snippet provided is a command that uses `grcov` to generate the coverage report.
Your task i... | codefeedback |
You are tasked with implementing a custom Swift enum that represents the result of an operation, either a success with a value or a failure with an error. Additionally, you need to provide computed properties to access the success value and the failure error.
Your enum should be named `Result` and should have two case... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.