instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are given a directed graph represented by a collection of nodes and their connections. Each node has a unique identifier and a list of neighboring nodes it is connected to. The graph is not necessarily acyclic and may contain cycles. Your task is to implement a function that finds all possible paths from a given st... | codefeedback |
You are tasked with creating a program to manage dependencies for a modular system. The system consists of modules, each represented by a directory on the file system. Your program needs to handle the reloading of dependencies when changes occur in the module directories.
You are given a Java code snippet that include... | codefeedback |
You are tasked with creating a script to automate the testing process for a web application using Grunt and Selenium. The given code snippet is a command that utilizes Grunt to run tests in parallel on the Travis CI platform, using the Chrome browser as the testing environment. Your task is to write a Grunt configurati... | codefeedback |
You are tasked with implementing a Python decorator that adds caching functionality to a view method in a web application. The decorator should handle caching of responses based on the ETag and Last-Modified headers. The provided code snippet shows the skeleton of the decorator function, but it lacks the complete imple... | codefeedback |
You are tasked with creating a Python function that processes a given directory and its subdirectories to find all Python files containing specific import statements. Your function should return a list of tuples, where each tuple contains the file path and the specific import statement found in that file.
Your functio... | codefeedback |
You are tasked with implementing a custom networking framework in Swift. The framework should support making GET requests with the ability to set acceptable content types and report progress.
Your task is to create a class `CustomNetworking` with the following requirements:
- A method `setAcceptableContentTypes` that ... | codefeedback |
You are tasked with implementing a simple gradient descent algorithm for optimizing a linear regression model. The algorithm will be used to minimize the mean squared error (MSE) loss function. You are given a Python class `LinearRegression` with an incomplete `fit` method that needs to be implemented. The class has an... | codefeedback |
You are tasked with implementing a function that processes a series of code snippets and returns the total count of specific patterns found within the snippets. Each code snippet is represented as a tuple containing a code string and an optional content string. The function should count the occurrences of the specific ... | codefeedback |
You are given the coordinates and radii of two circles in a 2D plane. Your task is to determine the relationship between the two circles based on their positions and radii. The relationship can be one of the following:
- "None": The circles do not intersect at all.
- "More": The circles are identical and completely ove... | codefeedback |
You are tasked with implementing a function to calculate the final position of an object affected by gravity and a constant force. The object's position is represented by a 3D vector, and the force applied is a product of the gravitational force, the object's mass, and a constant factor. Your task is to write a functio... | codefeedback |
You are tasked with implementing a game management system for a casino. The system should be able to handle different types of games and manage the number of players for each game. To achieve this, you need to create a class hierarchy for different types of games and implement the necessary functionality to manage the ... | codefeedback |
You are given a list of rules that describe which bags can contain other bags. Each rule is formatted as follows: "light red bags contain 1 bright white bag, 2 muted yellow bags." This rule indicates that a "light red" bag can contain 1 "bright white" bag and 2 "muted yellow" bags.
You need to write a program to deter... | codefeedback |
You are tasked with implementing a Python function that processes a dictionary of configuration settings and generates a formatted string representing the settings. Each setting consists of a key-value pair, and the function should handle the following cases:
- If a setting has a default value and the `show_default` fl... | codefeedback |
You are tasked with implementing a function that consumes and validates the types of values in a dictionary. The function should recursively traverse the dictionary and ensure that the types of values for each key are of a specified type. If a value is not of the expected type, an error should be thrown. You are provid... | codefeedback |
You are tasked with implementing a function to calculate the maximum TPDU (Transport Protocol Data Unit) size based on a given size parameter. The TPDU size is calculated using the formula 2^(maxTPDUSizeParam).
Write a function `calculateMaxTPDUSize` that takes an integer `maxTPDUSizeParam` as input and returns the ma... | codefeedback |
You are tasked with parsing and extracting data from a binary file that contains structured event logs. The file contains events related to USB hub devices, and each event is structured according to a specific format. The provided code snippet is a partial representation of the structure used to define the format of th... | codefeedback |
You are tasked with creating a Python function that simulates a simplified version of a library management system. The system should allow users to borrow and return books, as well as display the current inventory of books available. The function should be able to handle multiple users and keep track of the books borro... | codefeedback |
You are tasked with implementing a function that extracts version numbers from a given string and returns them in a specific format. The version numbers are expected to follow the semantic versioning format (major.minor.patch), and the function should extract the version numbers from the input string and return them in... | codefeedback |
You are tasked with implementing a user authentication system using LDAP (Lightweight Directory Access Protocol) in a Java Spring application. The given code snippet is a part of the configuration for setting up the LDAP context source. Your task is to complete the implementation of the user authentication process usin... | codefeedback |
You are tasked with implementing a caching mechanism for a storage system. The system has a configuration with two parameters: `saveToFS`, a boolean indicating whether to save data to the file system, and `maxCacheSize`, an integer representing the maximum size of the cache.
You need to create a class `StorageCache` t... | codefeedback |
You are tasked with implementing a collection parser that can handle parsing different types of collections from a list of string values. The `ICollectionParser` interface defines a method `Parse` that takes in the name of the argument and a read-only list of string values and returns the parsed collection as an object... | codefeedback |
You are given a snippet of code that appears to be incomplete. Your task is to complete the code by implementing a function that calculates the sum of all even numbers in a given array. The function should take an array of integers as input and return the sum of all even numbers in the array.
The function signature is... | codefeedback |
You are tasked with creating a script to automate the installation and setup of a security tool called BlackEyeSecurity on a Linux system. The script should perform the following steps:
1. Copy the BlackEyeSecurity directory and its contents to the /usr/share/ directory using the command `sudo cp -ar ./BlackEyeSecurit... | codefeedback |
You are tasked with implementing a function to calculate 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 task is to write a function that efficiently computes the nth Fibonacci number using dynamic programmi... | codefeedback |
You are tasked with simulating a fake asynchronous environment for testing purposes. Your goal is to write a function that simulates the behavior of asynchronous code execution and time manipulation.
Write a function `SimulateAsyncExecution` that takes in a time duration in days and a callback function representing an... | codefeedback |
You are tasked with creating a program that simulates a simplified build system. The build system takes a list of tasks and executes them concurrently using a specified number of threads. Each task represents a job that needs to be completed, and the build system should ensure that all dependencies for a task are compl... | codefeedback |
You are tasked with implementing a function that performs a specific transformation on a given input array. The function should take an input array of shape (batch_size, N, N, 2) and return a complex-valued array of shape (batch_size, N, N, 1). The transformation involves combining the real and imaginary parts of the i... | codefeedback |
You are tasked with implementing a custom predictor class for a 3D U-Net model used in medical image segmentation. The provided code snippet is a part of a larger system for predicting segmentations of medical images using a 3D U-Net model. Your task is to create a custom predictor class that can take the trained U-Net... | codefeedback |
You are tasked with creating a program that generates a set of arithmetic problems for students to solve. Each problem will consist of two randomly generated numbers and an arithmetic operation. The program should display five such problems in a formatted manner, and the student should provide the correct answer for ea... | codefeedback |
You are tasked with implementing a function to calculate the precision at k for a recommendation system. The function takes in predicted ratings, true ratings, and item prices, and returns the precision at the top k recommendations.
You are given the following code snippet as a starting point:
```python
def money_pre... | codefeedback |
You are tasked with creating a program that extracts the repository name and the quote from a given code snippet. The repository name is located between the angle brackets `< >`, and the quote is enclosed within double forward slashes `//` and `—`. Your program should be able to handle multiple occurrences of the repos... | codefeedback |
You are tasked with implementing a Python function that makes an asynchronous HTTP GET request using the `aiohttp` library. The function should have the following signature:
```python
async def get(url: str, proxy: Optional[str] = None, headers: Optional[Dict[str, str]] = None, byte: Optional[bytes] = None, timeout: i... | codefeedback |
You are tasked with creating a Python class that interacts with a SQL Server database using the `muttlib.dbconn.SqlServerClient` module. Your class should provide methods to perform basic CRUD (Create, Read, Update, Delete) operations on a specific table in the database. The table schema consists of three columns: `id`... | codefeedback |
You are tasked with implementing a function that processes data streams to determine whether certain buttons should be displayed based on the category of a current test. The code snippet provided is a part of a larger Angular application using RxJS for reactive programming.
The `currentTest$` is an observable that emi... | codefeedback |
You are tasked with creating a Python function that processes a pandas DataFrame to update a specified column containing date or time data. Your function should take the column name and any additional keyword arguments that can be passed to the `pd.to_datetime` function. The function should then return the modified Dat... | codefeedback |
You are tasked with implementing a custom comparison function for a specific data structure. The data structure is a class representing a geometric point in 2D space, with x and y coordinates. The comparison function should compare two points based on their distance from the origin (0, 0). The comparison function shoul... | codefeedback |
You are given a Python function `ridges_detection` that takes in a 2D array `cwt2d` and a 1D array `vec`. The function is intended to detect ridges in the 2D array and return the peaks and ridges found. The function uses several helper functions such as `local_extreme` and `ridge_detection` to achieve this. Your task i... | codefeedback |
You are tasked with implementing a class for managing planets in a space-themed game. The provided code snippet is a partial implementation of the `Planets` class, which inherits from `PlayerUI`. The `Planets` class is responsible for handling various actions related to planets in the game. The `__init__` method initia... | codefeedback |
You are tasked with implementing a Python class method that processes a crystal structure and saves it to a specified folder. The method should handle different input types and ensure that the folder exists before saving the structure. Below is a skeleton of the class method:
```python
import os
from ase import Atoms
... | codefeedback |
You are tasked with creating a Python function that interacts with a Twitter API to retrieve the status of a given parent tweet. The function should handle potential exceptions and return the status of the tweet in a specific format.
Write a Python function `retrieve_tweet_status(api, parent_tweet_id)` that takes in t... | codefeedback |
You are tasked with implementing a command-line argument parser for a custom algorithm runner. The algorithm runner takes various parameters, and your task is to parse and process these parameters to execute the algorithm correctly.
You are given a code snippet that represents a part of the command-line arguments for ... | codefeedback |
You are tasked with creating a WebSocket-based pub/sub system using FastAPI and asyncio. Your goal is to implement a simple chat application where clients can connect to a WebSocket endpoint, subscribe to a specific topic, and receive messages published to that topic.
You are provided with a code snippet that sets up ... | codefeedback |
You are tasked with creating a program to automate the injection of a Metasploit payload into an Android application. The given code snippet is part of a larger script that performs this injection process. Your task is to implement the logic for injecting the Metasploit payload into the Android application's smali code... | codefeedback |
You are given a set of integers and are required to implement a class that supports two operations:
1. `addNumber(int num)`: Add a new integer to the set.
2. `getMedian()`: Return the median of the set of integers.
The median of a set of numbers is the middle number when the numbers are arranged in ascending order. I... | codefeedback |
You are tasked with implementing a logging system in Python that supports different log levels and corresponding colored output. The provided code snippet shows a partial implementation of a Logger class with methods for printing log messages at different levels (info, debug, and blue). Each method checks the log level... | codefeedback |
You are tasked with implementing a C++ class that simulates a simple bank account. The class should have the following functionalities:
1. Ability to set the account holder's name and initial balance.
2. Deposit funds into the account.
3. Withdraw funds from the account (if sufficient balance is available).
4. Get the ... | codefeedback |
You are tasked with implementing a Python class that manages authentication tokens for a Flask-based remote application. The class, `FlaskRemoteApp`, is responsible for handling request tokens and updating the authentication tokens. Your task is to complete the implementation of the `FlaskRemoteApp` class by adding the... | codefeedback |
You are tasked with implementing a function that calculates the area of a given polygon. The polygon is represented by a sequence of vertices in a 2D plane. Each vertex is defined by its x and y coordinates. The area of a polygon can be calculated using the shoelace formula, which states that the area is half the absol... | codefeedback |
You are tasked with creating a command-line tool to manage folder bookmarks in a Linux environment. The tool should allow users to bookmark their current working directory and later navigate to these bookmarked folders using fuzzy search.
Your task is to implement a Python script that provides the functionality descri... | codefeedback |
You are given a class with a method that processes a list of words and computes the best subset of similar words based on a comparison vector. The comparison vector is created by counting the occurrences of each word in the input list and then finding the most common count. Your task is to implement the method that com... | codefeedback |
You are tasked with implementing a memory game algorithm. In this game, players take turns modifying an array of integers according to specific rules. The game starts with a given array of integers and a specified number of turns. On each turn, the player performs the following steps:
1. If the array is empty, the game... | codefeedback |
You are tasked with creating a Python GUI application using the wxPython library. Your application should have a dialog window with several widgets, including a multiline text control, static text labels, and a choice control. Additionally, you need to bind an event to the choice control to handle user interactions.
Y... | codefeedback |
You are tasked with creating a program that manages the download URLs for various language models used in natural language processing. The program should allow users to add, retrieve, and remove model URLs, as well as provide a method to display all available model URLs.
Your task is to implement a class `ModelManager... | codefeedback |
You are given a code snippet that processes data using PyTorch. Your task is to write a function that performs similar data processing operations using Python and NumPy.
Write a Python function `data_processing` that takes the following inputs:
- `tbar`: a list of tuples, where each tuple contains the following elemen... | codefeedback |
You are tasked with implementing a method to remove a group invite from a social networking application. The method should take in the group ID and the user ID of the person who wants to remove the invite. The group invite should be removed only if the user is the one who sent the invite. If the user did not send the i... | codefeedback |
You are tasked with creating a Python function that processes a list of addresses and generates a list of corresponding links. The function should take a list of addresses as input and return a list of links formed by appending the addresses to a base URL.
The function should be named `generate_links` and should have ... | codefeedback |
You are tasked with implementing a Python function that performs a specific type of validation on a given set of loss records. The function should compare the loss records against a reference array using a specified relative tolerance (rtol) and absolute tolerance (atol). If the validation fails, an error message shoul... | codefeedback |
You are tasked with implementing a function that processes keyword arguments and uses them to create a package configuration for a build system. The function should handle default values for certain arguments and apply specific substitutions to the package configuration.
Write a function `create_package_config` that t... | codefeedback |
You are working on a project to implement a numerical optimization algorithm. As part of this project, you need to develop a function that updates a Hessian matrix and a vector based on the addition of new edges in a graph. The code snippet provided is a part of the function that performs these updates.
The function t... | codefeedback |
You are tasked with implementing a simplified version of a lambda calculus evaluator in Python. Lambda calculus is a formal system in mathematical logic and computer science for expressing computation based on function abstraction and application using variable binding and substitution. In this problem, you will create... | codefeedback |
You are tasked with implementing a function to transform an image to represent the flag of the Netherlands. The flag consists of three horizontal bands of color: red at the top, white in the middle, and blue at the bottom. You are given a code snippet that manipulates pixels in an image using a custom image processing ... | codefeedback |
You are tasked with implementing a Python class to represent colors in different formats. The class should provide methods to create color objects from strings, integers, and lists. The color can be represented in the following formats:
1. String: A string representing the color in hexadecimal format (e.g., "#RRGGBB" o... | codefeedback |
You are tasked with creating a web application that manages user data and allows users to perform various actions such as deleting, modifying, sending emails, and making payments. The provided code snippet is a part of the HTML template for displaying buttons that correspond to these actions for a specific user.
Your ... | codefeedback |
You are tasked with implementing a multithreaded program that simulates a simple traffic light system. The traffic light system consists of three lights: red, yellow, and green. Each light should be represented by a separate thread, and the system should cycle through the lights in the following sequence: green, yellow... | codefeedback |
You are tasked with creating a script to automate the deployment process for a web application. The application is built using Maven and is packaged as a JAR file. Your script should perform the following tasks:
1. Clean the project using Maven.
2. Build the project using Maven.
3. Run the application by executing the ... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a special rule for scoring where the score of each player is the sum of their scores from the previous two rounds. However, the first two rounds are exceptions and have fixed scores. Your task is to write a function to calculate the total ... | codefeedback |
You are tasked with implementing a DPC (Deferred Procedure Call) mechanism in C++ for handling asynchronous events. The DPC object should be able to call a supplied function with context when it fires. Your goal is to create a class that encapsulates this functionality and returns a handle to the DPC object.
Your task... | codefeedback |
You are tasked with creating a Python function that takes a file path as input and returns the absolute path of the directory containing the file. You should use the `os.path` module to achieve this.
Write a function called `get_directory_path` that takes a single parameter:
- `file_path` (string): A string representi... | codefeedback |
You are tasked with creating a Rust program that simulates a simple game of rock-paper-scissors. The game should allow a player to input their choice, randomly generate the computer's choice, determine the winner, and display the result.
Your program should consist of the following components:
1. A function to handle ... | codefeedback |
You are working on a project that involves integrating a third-party library into your application. The library provides a component with a complex type definition that includes various properties and classes. Your task is to understand and utilize this type definition to create an instance of the component with the co... | codefeedback |
You are tasked with implementing a function to calculate the maximum exponent array for a given precision. The maximum exponent array is used in the context of a Bancor formula, which is a mathematical formula used in the field of finance and economics. The function should take the maximum precision as input and return... | codefeedback |
You are given a string `num` that contains only digits and an integer `target`. Your task is to write a function that returns all possible ways to add the binary operators '+', '-', or '*' between the digits of `num` so that the resultant expression evaluates to the target value.
Write a function `addOperators` that t... | codefeedback |
You are working as a software developer for a version control system. Your task is to create a program that automates the process of updating the version number in a `composer.json` file and then committing and pushing the changes to a remote repository.
You are given the following information:
- The current version n... | codefeedback |
You are tasked with implementing a Python function to copy metadata from one GeoTIFF file to another. The metadata contains information about the geographic data, such as the coordinate system, projection, and other relevant details. The function should take two input file paths: the source GeoTIFF file from which the ... | codefeedback |
You are tasked with creating a Python function that generates an RSA key pair and then encrypts and decrypts a message using the generated keys. The function should take in a message as input and return the encrypted message and the decrypted message.
You are provided with a code snippet that imports the necessary mod... | codefeedback |
You are given a code snippet that uses OpenMP directives for parallelization. The code contains two parallel for loops, each with different OpenMP directives. Your task is to analyze the code and identify the issues related to the use of private and shared variables in the directives.
Identify and explain the errors i... | codefeedback |
You are tasked with implementing a data splitting function for a machine learning project. The function should take a dataset and split it into three parts: training set, validation set, and test set. The sizes of the training, validation, and test sets should be specified as percentages of the total dataset size. The ... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm for a robotic arm to learn how to grasp objects. The robotic arm's policy is trained using the Proximal Policy Optimization (PPO) algorithm, which involves choosing a loss function to optimize the policy. The loss function can be either the Secure Trip... | codefeedback |
You are tasked with implementing a memory management system for a custom JavaScript engine. The engine uses a custom JavaScript Core (JSC) library, and you need to define a finalizer for the `Navigator` class to handle memory deallocation when instances of `Navigator` are no longer needed.
The given code snippet shows... | codefeedback |
You are tasked with implementing a class that represents a person's name. The class should have the following requirements:
1. The class should be named `PersonName`.
2. It should have a private instance variable `nameAsString` of type `String` to store the person's name as a string.
3. The class should have a constru... | codefeedback |
You are tasked with implementing a web application that processes votes from users. The provided code snippet is a part of a web application using the webapp2 framework in Python. The `WSGIApplication` class is used to define the URL routes and their corresponding request handlers. In this case, the route `/worker/proc... | codefeedback |
You are tasked with implementing a JSON reporter class for a statistical benchmarking application. The JSON reporter is responsible for formatting and outputting benchmarking results in JSON format. The reporter should be able to handle various types of statistical data and produce a well-structured JSON output.
Your ... | codefeedback |
You are tasked with designing a multi-threaded file transfer system for a distributed computing environment. The system involves transferring files between different machines using SSH and running a central node to coordinate the file transfer process. Your task is to implement the `ssh_file_transfer` function and the ... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a special rule where if the current score is the same as the previous score, the current score is discounted. Your task is to write a function `calculate_final_score(scores)` that calculates the final score after applying this rule.
Funct... | codefeedback |
You are tasked with implementing a Python function that processes a list of strings representing file paths and returns a dictionary containing the count of files with each unique file extension. The file extension is defined as the substring following the last occurrence of the dot (.) in the file name. If a file has ... | codefeedback |
You are tasked with creating a program that can parse and extract data from HTML forms. Your program should be able to identify form elements and their attributes, and then output the relevant information in a structured format.
Write a function `parseHTMLForm(html)` that takes a string `html` representing an HTML for... | codefeedback |
You are tasked with creating a function that calculates the total number of React components in a given JavaScript file. The function should take a string representing the JavaScript file's content as input and return the count of React components present in the file. For the purpose of this problem, a React component ... | codefeedback |
You are tasked with implementing a function to save and load data in JSON format. The function should take a data structure, serialize it to JSON, save it to a file, then load the JSON from the file and deserialize it back into the original data structure. Your task is to complete the implementation of the `save_and_lo... | codefeedback |
You are working on a file management system that involves renaming files with a specific naming convention. The naming convention for the files is as follows: `5MCP19_YYYYMMDD.bin`, where `YYYY` represents the year, `MM` represents the month, and `DD` represents the day. Your task is to write a program that renames the... | codefeedback |
You are tasked with creating a web application that allows users to add parts to a shopping cart. The code snippet provided is a part of the HTML form used to add parts to the cart. The form contains hidden input fields for "partID" and "partname" which are populated using the PHP `$_GET` superglobal array. Additionall... | codefeedback |
You are tasked with creating a Python program that can parse a configuration file and extract specific information from it. The configuration file follows a specific format, where each line contains a key-value pair separated by an equal sign (=). Your program should be able to read this file and extract the values ass... | codefeedback |
You are tasked with implementing a custom `MapModel` class in Java that extends the `Serializable` interface. The `MapModel` class should have the functionality to store key-value pairs and provide methods to manipulate and retrieve data from the map.
Your task is to complete the implementation of the `MapModel` class... | codefeedback |
You are given an array `nums` of length `n` containing integers from 1 to n inclusive. There is exactly one integer that is duplicated in the array, and one integer that is missing from the array. Your task is to find the duplicated number and the missing number.
You need to implement a function `findErrorNums(nums)` ... | codefeedback |
You are tasked with creating a configuration parser for a Node.js application. The application's configuration is stored in a JavaScript object, and it needs to be parsed to extract specific information based on the environment. The configuration object contains key-value pairs, where the keys represent configuration o... | codefeedback |
You are tasked with creating a Python script to convert GnuCash financial data from its native format to a CSV file. GnuCash is a personal and small-business financial accounting software. The script should read a GnuCash file and export the data into a CSV file for further analysis or integration with other financial ... | codefeedback |
You are tasked with implementing a network management system for a QEMU virtualization environment. The system involves allocating and managing network interfaces, generating MAC addresses, and opening a QEMU Monitor Protocol (QMP) socket for communication with QEMU instances.
You are provided with the following funct... | codefeedback |
You are tasked with creating a program that utilizes the OpenCV library to detect and highlight faces in a given image. The program should take an input image, apply face detection using the Haar cascade classifier, and then display the original image with rectangles drawn around the detected faces. Additionally, the p... | codefeedback |
You are working on a distributed system that manages tablets and their leaders. The system consists of tablets, each identified by a tablet ID (tid), and leaders, each identified by a leader ID (lid). The system also maintains a query leader map that maps tablet session IDs (sid) to their corresponding leader IDs. Addi... | codefeedback |
You are tasked with implementing a Python function that processes a list of options and executes a command based on the selected template. The function should handle the execution of the command using the `subprocess` module and return the output of the command.
You are given the following code snippet as a starting p... | codefeedback |
You are tasked with implementing a function to parse a BitString from an ASN.1 Any value. ASN.1 (Abstract Syntax Notation One) is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way. The BitString type in ASN.1 represents an arbitrary nu... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.