instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a Python class method that scans a directory tree and returns a dictionary containing information about the directory structure. The method should be able to handle both regular and demo mode, where the demo mode returns a subset of the directory information.
You are given a code snipp... | codefeedback |
You are tasked with creating a program that analyzes the distribution of characters in a given text file. Your program should read a text file and output the frequency of each character present in the file, sorted in descending order of frequency. For the purpose of this problem, consider only alphanumeric characters (... | codefeedback |
You are tasked with creating a Python function that simulates a simple migration system for a database. The function should take a list of migration classes as input and execute them in the correct order. Each migration class has a `name` attribute representing the migration name and a `execute` method to perform the m... | codefeedback |
You are working on a Python project that involves a logging system, file management, and helper functions. The project structure includes the following components:
1. `core.py`: This module contains the `Log` and `Folder` classes for logging and file management, respectively.
2. `helpers.py`: This module contains the ... | codefeedback |
You are tasked with creating a program that processes a list of URLs and extracts the domain names from each URL. The domain name should be extracted from the given URLs and then sorted in lexicographical order.
You are given a list of URLs in the following format:
```
urls = [
"https://github.com/ctlcltd/e2-sat-... | codefeedback |
You are tasked with implementing a Python function that processes a list of schema files and generates a report based on the schemas read from these files. The schemas are defined in JSON format and contain information about data structures, such as fields, data types, and constraints. Your function should read these s... | codefeedback |
You are tasked with creating a command-line tool to visualize the performance of experiments conducted on stator and rotor temperatures. The tool should accept command-line arguments for the stator ID and rotor ID, and then use these IDs to fetch and visualize the corresponding experiment data.
Write a Python program ... | codefeedback |
You are tasked with creating a script to manage the selection of devices for a home automation system. The script should allow users to select a device and store the selection in a temporary file. The script should also handle cases where the user does not provide any input.
Your task is to complete the script by impl... | codefeedback |
You are tasked with implementing a function to determine whether a frog can cross a river by jumping on stones. The river is represented as a sequence of stones, and the frog starts at the first stone. The frog can jump from one stone to another if the distance is within a certain range. The goal is to reach the last s... | codefeedback |
You are tasked with creating a Python decorator that logs the execution time of a function. The decorator should print the name of the function, its execution time, and the arguments passed to the function. You should also handle both positional and keyword arguments.
Create a decorator function called `log_execution_... | codefeedback |
You are tasked with implementing a Python decorator that performs type checking on the parameters and return value of a given function. The decorator should use the `beartype` library to enforce type annotations and raise an exception if the type checking fails.
Your task is to complete the implementation of the `bear... | codefeedback |
You are tasked with implementing a function that checks whether a given file path is valid or not. A valid file path should adhere to the following rules:
1. It should not contain any invalid characters such as <, >, :, ", /, \, |, ?, or *.
2. It should not end with a space or a period.
You need to implement the follo... | codefeedback |
You are tasked with implementing a custom progress bar for a long-running calculation. The progress bar should display the progress of the calculation and update in real-time as the calculation proceeds. You are given a `progress_bar` function that takes the following parameters:
- `range_val`: The range of the calcula... | codefeedback |
You are a security analyst investigating a potential security breach in a web application. You have intercepted a code snippet from a Python script used to interact with the application. Your task is to analyze the code and identify the potential security vulnerability it may exploit.
The code snippet is as follows:
... | codefeedback |
You are tasked with implementing a custom break statement in a programming language that does not natively support it. The custom break statement should allow for breaking out of nested loops, similar to the behavior of the native break statement in languages like Python or Java.
Your task is to create a function `cus... | codefeedback |
You are tasked with implementing a Python class that parses and extracts information from code comments. The class should be able to handle different types of code elements such as attributes, methods, and functions. Your task is to create a class `CodeParser` with the following functionalities:
1. A method `parse` th... | codefeedback |
You are given a set of data points representing the performance of a dynamic programming algorithm. The code snippet provided contains commented-out lines that display the values of the dynamic programming array `dp` and the best error `best_err`. Your task is to implement a program that processes this data and identif... | codefeedback |
You are tasked with creating a Python function to calculate the confidence interval for a population mean using the t-distribution. The t-distribution is a probability distribution that is used to estimate population parameters when the sample size is small or when the population standard deviation is unknown. The form... | codefeedback |
You are working on a project that involves creating a color interpolation function for a lighting system. The function takes a time parameter `t` and uses it to interpolate between two color values `rb[t0]` and `rb[t0+1]` to produce the final color values `r` and `g`. The interpolation is also affected by a brightness ... | codefeedback |
You are tasked with simulating a dice rolling game to achieve a target sum. The game involves rolling four six-sided dice multiple times to reach a specific target sum. Each roll of the dice produces a random number between 1 and 6, inclusive. The game continues until the target sum is met or exceeded.
Write a functi... | codefeedback |
You are tasked with creating a program to manage a library of photography models for Quinntyne Brown Photography. The program should allow the user to add new models, update existing models, and retrieve information about the models. Each model has a unique ID, a name, and a list of photos associated with them. The pro... | codefeedback |
You are tasked with implementing a Naive Bayes classifier for sentiment analysis. The given code snippet shows the training process and the resulting probability vectors for two classes. Your task is to complete the implementation of the Naive Bayes classifier and use it to classify new instances.
The `trainMat` varia... | codefeedback |
You are tasked with implementing a visitor pattern in Python for a graph traversal application. The visitor pattern allows for adding new operations to existing object structures without modifying those structures. In this case, the object structure is a graph, and the operations are defined by the `Visitor` interface.... | codefeedback |
You are tasked with implementing a custom iterator class in Python that iterates over a list of spices and returns the length of each spice's name in the iteration. Your custom iterator should stop iterating when the length of the spice's name is greater than 6 characters. If the length of the spice's name is exactly 6... | codefeedback |
You are tasked with creating a program to analyze musical chord probabilities from an API response. The API returns a list of chord objects, each containing a probability and a chord ID. Your program should make a series of API calls, process the responses, and then output the chord IDs with the highest probabilities.
... | codefeedback |
You are tasked with creating a custom annotation processor in Java. Your annotation, `ConstructorAnno`, is used to mark constructors in classes. The annotation takes a single optional parameter, `value`, which defaults to "default".
Your goal is to implement a processor that, when given a class with constructors annot... | codefeedback |
You are tasked with creating a program that can parse and extract information from HTML meta tags. The program should be able to identify and extract the attributes and their corresponding values from the meta tags in the given HTML code.
Write a function or method that takes the HTML code as input and returns a dicti... | codefeedback |
You are tasked with implementing a Python function that calculates the weighted sum of a given set of values using a sigmoid function as the weighting factor. The sigmoid function is defined as:
\[ \text{sigmoid}(x) = \frac{1}{2} \left( \tanh\left(1.5 \pi (x - 0.5)\right) + 1 \right) \]
You are provided with a set of... | codefeedback |
You are tasked with implementing a Java class that converts a collection of test case classes into a dictionary representation. The dictionary representation will be used for generating test cases. The provided code snippet initializes a JavaToDictionary class with a collection of test case classes.
Your task is to im... | codefeedback |
You are tasked with implementing a custom error handling system for a GraphQL API. The provided code snippet is a part of a schema definition for error handling in a GraphQL server. The schema uses a library with a custom type system, where `GT` represents the GraphQL type generator.
The code snippet defines a part of... | codefeedback |
You are tasked with creating a Java class that simulates a simple library management system. The library contains books, each identified by a unique ISBN (International Standard Book Number). Your class should provide functionality to add books to the library, remove books, and search for books by their ISBN.
Your tas... | codefeedback |
You are working on a project that involves loading pre-trained weights into a neural network model using TensorFlow. Your task is to implement a function that reads weights from a checkpoint file and sets these weights to the first layer of the model.
You are given a code snippet that partially demonstrates this proce... | codefeedback |
You are tasked with implementing a simplified version of the `touch` command in Rust. The `touch` command is used to create a new empty file if it does not exist, and updates the access and modification times of the file if it does exist. Your task is to create a function `touch` that takes a file path as input and cre... | codefeedback |
You are tasked with creating a Python function to calculate the cross section for the semihadronic, semileptonic process $pp \to t\overline{t} \; Z', Z' \to b\overline{b}$ at different masses of the hypothetical particle $Z'$.
Write a function `calculate_cross_section(mass)` that takes the mass of the $Z'$ particle as... | codefeedback |
You are working on a game development project and need to implement a new feature for character attacks. The game has a `Character` class with various methods for attacking, and you need to add a new method called `bomb` to handle character attacks with bombs.
The `Character` class has the following relevant attribute... | codefeedback |
You are tasked with implementing a class that manages snapshots of an organization's data. The class should support the following operations:
1. `takeSnapshot()`: Takes a snapshot of the current state of the organization's data and returns an identifier for the snapshot.
2. `getSnapshot(snapshotId)`: Retrieves the org... | codefeedback |
You are tasked with implementing a point cloud registration system using the RANSAC and fast global methods. Point cloud registration is the process of aligning two or more 3D point clouds to a common coordinate system. In this problem, you will be given two point clouds, `pcd0` and `pcd1`, along with their correspondi... | codefeedback |
You are tasked with implementing a Python class that represents a 2D point using tuples. The class should provide methods for calculating the distance between two points, as well as for checking if two points are equal. Additionally, you need to implement a method for creating a new point by adding the coordinates of t... | codefeedback |
You are tasked with creating a program to calculate the monthly cost of commuting to a university campus. The program should take into account the cost of driving, gas, and a parking pass. The cost of driving and gas is based on the number of days the individual commutes to campus per month. The parking pass cost is ca... | codefeedback |
You are tasked with creating a program to simulate a typing speed competition within a Discord server. The program should allow users to enter their typing speed in words per minute (WPM) and assign them a role based on their typing speed. The roles should be created dynamically based on the following criteria:
- 20-29... | codefeedback |
You are tasked with implementing a simplified version of the `tail` command-line utility in Python. The program should read input from a file or standard input and display a specified number of leading lines. Additionally, the program should handle certain quirks and unsurprising quirks as described in the code snippet... | codefeedback |
You are working on a machine learning project and need to implement a covariance-covariance (covCov) estimator using PyTorch. The covCov estimator is used to estimate the covariance matrix of the covariance matrix of a given input tensor. The input tensor `X` is a 3D tensor of shape `(batch_size, input_dim, input_dim)`... | codefeedback |
You are given a code snippet from a PowerPC assembly language program. Your task is to analyze the snippet and identify the purpose of the instructions.
Your goal is to interpret the code and explain the operations being performed by each instruction. You should also identify any conditional branches and their associ... | codefeedback |
You are tasked with implementing a function to calculate the average time taken to convert a series of RGB frames to YUV format. The given code snippet is part of a larger program that processes video frames. The `scoped_array` class is used to manage memory for a dynamically allocated array of `uint8` elements. The `T... | codefeedback |
You are tasked with creating a Python function that generates a plot based on a given suffix. The function should take in a list of strings and a suffix, and then plot the frequency of strings ending with the given suffix. If the suffix is not provided, the function should plot the frequency of all strings. You are req... | codefeedback |
You are tasked with implementing a function that validates an API key based on a given set of rules. The API key is represented as a string and must adhere to the following criteria:
1. The API key must be of type "apiKey".
2. The API key must be at least 10 characters long.
3. The API key must contain at least one upp... | codefeedback |
You are tasked with creating a Node.js script to send data to Google Cloud IoT Core using the Google Cloud IoT Core Node.js client library. Your script should utilize environment variables for configuration and command-line arguments for specifying additional parameters.
The following environment variables are availab... | codefeedback |
You are tasked with creating a program that generates Auto Layout constraints for a user interface. Auto Layout is a constraint-based layout system that allows developers to create a responsive and adaptive user interface for iOS and macOS applications.
Your task is to write a function that takes an array of strings r... | codefeedback |
You are tasked with designing a URL routing system for a web application using Django. The given code snippet shows a portion of the URL configuration for the application. Each path is associated with a specific view function that handles the corresponding HTTP request. Your task is to complete the URL configuration by... | codefeedback |
You are tasked with creating a script that sets up environment variables for a MongoDB deployment. The script should handle default values for the variables and ensure that the script exits with an error if any of the commands fail.
The script should set the following environment variables:
- `AUTH`: Defaults to "noau... | codefeedback |
You are tasked with implementing a Swift class that manages a collection of shields for a spaceship. The shields can have different styles and strengths, and the class should provide methods to manage and manipulate the shields.
You need to implement the `ShieldsManager` class with the following specifications:
- The ... | codefeedback |
You are tasked with implementing a cubic spline interpolant using Python. A cubic spline is a piecewise-defined function composed of cubic polynomials, which is commonly used for interpolation of data points. The goal is to construct a cubic spline interpolant and evaluate it at specific points.
To achieve this, you w... | codefeedback |
You are tasked with implementing a filtering mechanism for a collection of processes based on their messaging and processing steps' statuses. The statuses are represented by an enum called `Status`, and the processes are represented by a collection called `processes`. The filtering logic is defined by two code snippets... | codefeedback |
You are tasked with implementing a class that merges two sets of resolved property setters and handles any potential errors that may arise during the merging process.
You are given an interface `IAttributeValueMerger` with the following method signature:
```csharp
public interface IAttributeValueMerger
{
ResolvedP... | codefeedback |
You are tasked with creating a function that processes and logs incoming data from a web request. The function should take the request body, format it, and append it to a log file with a timestamp. Your task is to implement the function that performs these operations.
Function Signature:
```typescript
function process... | codefeedback |
You are tasked with creating a secure login system for a web application. The given code snippet is a part of the login authentication process in PHP. The code checks if the provided username and password match the credentials for the admin user. If the credentials are correct, the user's session is initialized with sp... | codefeedback |
You are tasked with implementing a custom synchronization mechanism for a parallel processing system. The system consists of multiple threads that need to coordinate their execution using a set of predefined synchronization events. Each event is represented by a unique integer value, and the system must ensure that the... | codefeedback |
You are working on a computer graphics project that involves rendering 3D scenes. As part of this project, you need to calculate the number of direct interactions between triangles in the observed scene and the source scene. Each observed triangle can potentially interact with each source triangle, resulting in a direc... | codefeedback |
You are tasked with implementing a function that calculates the total number of bytes used by a Python package based on its license information. The function should take the license text as input and return the total number of bytes used by the license.
The license text is formatted as a string, and the number of byte... | codefeedback |
You are working on a web application that uses the Laravel framework for routing. The code snippet provided includes a route definition using the `Route::get` method. Additionally, there is a commented-out route definition that uses a closure function and applies the `auth:api` middleware.
Your task is to create a mid... | codefeedback |
You are tasked with implementing a radar chart plotting algorithm for a data visualization library. The radar chart, also known as a spider chart or star plot, is a graphical method of displaying multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes startin... | codefeedback |
You are tasked with implementing a Python class for sharing a secret using Shamir's Secret Sharing algorithm. Shamir's Secret Sharing is a cryptographic algorithm that allows a secret to be divided into parts, called shares, in such a way that the original secret can only be reconstructed when a sufficient number of sh... | codefeedback |
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the account balance. Additionally, the class should keep track of the total number of transactions performed on all accounts.
Your task is to implement... | codefeedback |
You are tasked with implementing a thread-safe error reporting mechanism in Swift. The provided code snippet shows a method `reportError` that can be called from any thread to report errors of type `BgfxError` along with an error message. Your task is to implement the `reportError` method in a thread-safe manner, ensur... | codefeedback |
You are tasked with creating a Python program that processes geographic data encoded in the Sensor Model Language (SensorML) format. SensorML is an XML-based language used to describe processes and processing components in the domain of Earth and environmental observation. Your program needs to extract specific informa... | codefeedback |
You are tasked with implementing a custom logging system in Python. Your goal is to create a function that sets up a logger and redirects its output to a stream for further processing. You will need to use the `contextlib` module to redirect the standard output and standard error streams to a `StringIO` object. The log... | codefeedback |
You are tasked with creating a Rust library for performing various operations related to constants, environment variables, local variables, and memory management. The library will consist of four modules: `constant_ops`, `env_ops`, `local_ops`, and `mem_ops`. Each module will contain functions to perform specific opera... | codefeedback |
You are tasked with implementing a custom feature flag system for a software application. The feature flag system should allow enabling or disabling specific features based on the presence of a feature flag. Each feature flag can be associated with a specific feature or functionality within the application. Your task i... | codefeedback |
You are tasked with implementing a Python class that manages a set of structures and provides various operations for testing and manipulating these structures. The class should inherit from the `StructureSetTest` class and should be named `StructureSetStructuresTests`. Your implementation should include methods for add... | codefeedback |
You are tasked with implementing a custom interruptible thread join function in Python. The provided code snippet offers a starting point for this task. The `interruptible_join` function is intended to allow joining a thread while handling signal interrupts gracefully. Your goal is to complete the implementation of the... | codefeedback |
You are tasked with implementing a Python class that applies various image augmentation techniques to a given input image. The class should support a range of augmentation operations, such as rotation, flipping, scaling, and color manipulation. Your task is to complete the implementation of the `AugStyle` class by addi... | codefeedback |
You are tasked with creating a program that simulates a simple file system navigation using a command-line interface. Your program should support the following commands:
1. `cd <directory>`: Change the current directory to the specified directory. The `<directory>` parameter is a string representing the directory name... | codefeedback |
You are tasked with designing a layout generator for a custom integrated circuit (IC) using a Python-based layout generation tool. The tool provides functions for placing instances of predefined circuit components on a grid to create the overall IC layout. The code snippet provided is a part of the layout generation pr... | codefeedback |
You are tasked with implementing a generic function that calculates the average value of a collection of numeric elements. The function should be able to handle various types of numeric elements, including integers, floating-point numbers, and custom numeric types. Your task is to create a generic function that can cal... | codefeedback |
You are tasked with implementing a function to retrieve and format paper information from a database. The function should retrieve the newest papers from the database, limit the number of papers retrieved for speed, and gather information about the authors of each paper.
You are given a code snippet that partially imp... | codefeedback |
You are tasked with implementing a permutation generator for a given set of elements. A permutation is an arrangement of all the elements of a set in a specific order. For example, the permutations of the set {1, 2, 3} are {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, and {3, 2, 1}.
Your task is to write a fu... | codefeedback |
You are tasked with implementing a C++ template meta-programming problem that involves determining whether a given type is a pointer type. Your goal is to create a meta-function called `is_pointer` that takes a type as a template parameter and evaluates to `true` if the type is a pointer, and `false` otherwise.
Your t... | codefeedback |
You are tasked with implementing a simple Java program that utilizes Java Remote Method Invocation (RMI) to dynamically load classes from a remote server. RMI is a mechanism that allows an object to invoke methods on an object running in another Java virtual machine. The code snippet provided is an example of how to ru... | codefeedback |
You are tasked with creating a program that extracts and counts the occurrences of HTML class names from a given HTML code snippet. The program should take the HTML code as input and output a list of unique class names along with their respective counts.
For example, given the following HTML code snippet:
```html
<div... | codefeedback |
You are tasked with implementing a custom `unwrap` method for the `Optional` type in Swift. The `unwrap` method should return the wrapped value if it exists, or throw a custom `NilError` if the optional is `nil`.
Your task is to complete the implementation of the `unwrap` method within the `Optional` extension provide... | codefeedback |
You are tasked with creating a Python function to copy the weight map of a deformer from one object to another. The weight map represents the influence of the deformer on the vertices of the object. The function should be able to handle deformers of different types and copy the weight map accurately.
Your function sho... | codefeedback |
You are given an array `prices` where `prices[i]` represents the price of a given stock on the `i`-th day. You need to write a function to find the maximum profit you can achieve from buying and selling a stock at most once.
For example, given the input `prices = [7, 1, 5, 3, 6, 4]`, the function should return `5`, as... | codefeedback |
You are tasked with implementing a function to build a map that associates file extensions with programming language IDs based on a given set of language extension definitions. The language extension definitions consist of an ID representing a programming language and an array of file extensions associated with that la... | codefeedback |
You are tasked with creating a Python function that identifies available serial ports on a given platform and updates a GUI component when the user selects a different port from a dropdown menu.
Write a function called `update_serial_ports` that takes in a list of available serial ports and a selected port as input. T... | codefeedback |
You are tasked with implementing a generic tree data structure in Rust. The tree nodes should be able to store any type that implements the `Display` trait. You need to define the `FormatTreeNode` struct and its associated methods to create and manipulate the tree nodes.
Your task is to complete the implementation of ... | codefeedback |
You are working on a project that involves integrating a C++ library into a C# application using P/Invoke. The C++ library provides functionality for managing topics and their quality of service (QoS) settings in a data distribution service. You need to create a C# wrapper for the `u_topicGetQos` function from the C++ ... | codefeedback |
You are tasked with implementing a class hierarchy to represent mathematical operations on complex numbers. The complex number is represented as `C(x)` where `x` is a real number, and the derivative of a complex number is represented as `D(c)` where `c` is a complex number. The following operations need to be supported... | codefeedback |
You are tasked with creating a Python program that interacts with the CUSE (Character Device in Userspace) library to implement a simple virtual device. The CUSE library allows users to create character devices in user space, enabling communication between user programs and the kernel. Your task is to create a virtual ... | codefeedback |
You are tasked with implementing a simple assembly language interpreter for x86-64 architecture. The interpreter should be able to handle conditional jumps based on comparison operators. Your task is to write a function that generates the appropriate assembly code for a conditional jump based on the comparison operator... | codefeedback |
You are working on a project to analyze mass spectrometry data. In mass spectrometry, a spectrum is a plot of the intensity of ions as a function of their mass-to-charge ratio (m/z). Your task is to write a Python function to process the spectra data and extract the m/z values of the real peaks based on a given thresho... | codefeedback |
You are tasked with implementing a simple authentication system using ASP.NET Core Web API. The `AuthController` class is responsible for handling user authentication requests. The controller has a dependency on an `IUserRepo` interface, which is used to interact with the user repository. Additionally, the controller u... | codefeedback |
You are tasked with creating a program that simulates a simple inventory management system for a small retail store. The store sells three types of products: electronics, clothing, and groceries. Each product has a unique identifier, a name, a price, and a quantity in stock. Your program should allow the user to perfor... | codefeedback |
You are given a list of waterways represented by their names and lengths. Each waterway is represented as a tuple containing the name of the waterway as a string and its length as an integer. Your task is to write a function that takes this list of waterways and returns a dictionary where the keys are the names of the ... | codefeedback |
You are tasked with creating a Python function that identifies and returns the modularity communities in a given graph. Modularity communities are groups of nodes within a graph that are densely connected internally while having fewer connections between the groups. The modularity of a community structure is a measure ... | codefeedback |
You are tasked with implementing a distributed tracing system for a microservices architecture. The system should be able to trace the flow of requests through multiple services and provide insights into the performance and behavior of each service. To achieve this, you need to design and implement a mechanism for prop... | codefeedback |
You are tasked with creating a Rust library that provides asynchronous I/O operations using different asynchronous runtime libraries. The library should support both `async-std` and `smol`, as well as two versions of the `tokio` library: `tokio 1.0` and `tokio 0.2`. The library should be designed to allow users to choo... | codefeedback |
You are tasked with implementing a Python script that processes a given input file and performs specific operations on its contents. The input file contains a list of integers, with each integer representing a unique identifier for a product. Your script should read the input file, process the data, and then output the... | codefeedback |
You are working on a software testing framework for a library management system. The framework includes a set of test cases written in Python using the `unittest` module. The code snippet provided contains two test methods within a test class. The first method, `test_process_inoliblist_check_library_manager_compliance`... | codefeedback |
You are tasked with creating a Python class that implements a method for finding the best parameters for the Random Forest algorithm using hyperparameter tuning. The class should also include a method for initializing an XGBoost classifier.
Your task is to complete the Python class by implementing the `best_params_ran... | codefeedback |
You are tasked with implementing a custom Android Fragment that includes a specific layout and functionality. The fragment should contain a custom view called ObservableView, which allows users to drag and slide vertically within the view. Your task is to complete the implementation of the ObservableView and integrate ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.