instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a class for a 3D terrain visualization system. The given code snippet is a part of the class constructor, where the class is being initialized with a Tkinter plotter and the terrain size is being set. Your task is to complete the implementation of the class by adding methods for adding ... | codefeedback |
You are given a code snippet that manipulates a variable `ai` based on the values of `j`, `k`, and `a`. Your task is to implement a function that simulates the behavior of the given code and returns the final value of `ai` after the loop terminates.
The code snippet is as follows:
```python
ai = 0
while j < k:
if ... | codefeedback |
You are tasked with creating a Python script to automate the installation of various security tools and utilities for a lab environment setup. The script should be able to install the following tools:
- Ettercap
- Social Engineer's Toolkit (SET)
- mitmproxy
- Evilginx
Additionally, the script should also install an XF... | codefeedback |
You are tasked with implementing a simplified version of a class for managing HTML elements in a web application. The class, named `HTMLManager`, is responsible for handling the title and stylesheets of an HTML document. The provided code snippet shows part of the `HTMLManager` class, including a method for setting the... | codefeedback |
You are tasked with implementing a simple gradient descent optimization algorithm for a Gaussian process model. The provided code snippet is a part of the training loop for the optimization process. Here's a brief explanation of the components involved:
- `gp_model(train_x)`: This function represents a Gaussian proces... | codefeedback |
You are tasked with implementing a C++ class that manages a shared render context for multi-threaded resource creation. The class, `SharedRenderContext`, should provide methods for creating and managing resources in a multi-threaded environment.
Your task is to complete the implementation of the `SharedRenderContext` ... | codefeedback |
You are tasked with creating a Swift program to process astronomical data for a given date. The program should parse a JSON object containing astronomical information and populate the appropriate data structures. The JSON object contains information about the date, astrological events, and hourly astronomical data.
Yo... | codefeedback |
You are tasked with creating a class that represents a "Chamado" (call) in a customer support system. The "Chamado" class should have the following functionalities:
1. A method to set the ID of the call.
2. A method to retrieve the ID of the call.
3. A method to add a new "Alteracao" (change) to the call, including a ... | codefeedback |
You are tasked with creating a React component for a Net Promoter Score (NPS) dialog box. The dialog box should allow users to provide a star rating and submit their feedback. The component should utilize the `useConvergeSettingsContextProvider` hook to access and update the NPS settings. Additionally, the component sh... | codefeedback |
You are tasked with implementing a function that simulates a simplified version of the `print` function in Python. Your function should take a list of names as input and print each name in the list on a new line. However, you are not allowed to use the built-in `print` function or any looping constructs (e.g., for loop... | codefeedback |
You are tasked with creating a program that simulates a simple task management system. The system should be able to create tasks, assign them to specific individuals, and execute the tasks asynchronously using the Task Parallel Library (TPL) in C#.
Your task is to implement the `TaskManager` class, which should have t... | codefeedback |
You are tasked with implementing a resource pool for managing objects of a specific type. The resource pool should allow efficient reuse of objects to prevent unnecessary memory allocation and deallocation. Your goal is to create a resource pool for managing objects of the `AACFrame` class, which represents frames of A... | codefeedback |
You are tasked with creating a Python package manager tool that can handle the installation and execution of various command-line tools. Your tool should be able to register multiple entry points for different command-line scripts within the package. An entry point is a Python function or method within a package that c... | codefeedback |
You are tasked with implementing a custom class for drawing leading margins in a text layout. The class, named `QuoteMarginSpan`, is responsible for drawing a colored line as the leading margin for a paragraph of text. The provided code snippet shows part of the implementation for this class.
The `QuoteMarginSpan` cla... | codefeedback |
You are working on an image processing application that involves reading pixel data from an image. The code snippet provided is a commented-out section that prints the color information of a pixel in the format: "Pixel (x, y) has color (r, g, b, a)".
Your task is to implement a function that takes an image object and ... | codefeedback |
You are tasked with implementing a data structure to track the success rate of a series of data points over time. Each data point consists of a timestamp, a metric, and a success flag. Your goal is to create a class that can efficiently store these data points and provide a method to calculate the success rate over a s... | codefeedback |
You are tasked with implementing a Python program that processes a given file containing a corpus of documents. The program should be able to handle both regular and compressed files, and optionally support subcorpora for smaller vocabularies and fewer documents.
Your task is to implement a function `process_corpus` t... | codefeedback |
You are tasked with implementing a custom interface to handle large data structures in Java. The interface, named `LargeCollection`, provides a method for obtaining the size of the collection, specifically designed to handle sizes larger than `Integer.MAX_VALUE`. Your task is to create a class `LargeStructure` that imp... | codefeedback |
You are tasked with implementing a specialized stack that supports the following operations: push, pop, and getMin. The getMin operation should return the minimum value currently in the stack. The stack should have O(1) time complexity for all operations.
You are given a code snippet that partially implements the stac... | codefeedback |
You are tasked with creating a program that processes a given input file and performs specific operations based on the content of the file. The input file contains a series of lines, each representing a command or directive for the program to execute. Each line can be one of the following types:
1. `<gh_stars>min-max`... | codefeedback |
You are tasked with implementing a hash table data structure in Python. A hash table is a data structure that stores key-value pairs and provides efficient insertion, deletion, and retrieval operations. In this problem, you will create a Python class called `Hashtable` that supports these operations.
The `Hashtable` c... | codefeedback |
You are tasked with implementing a class for a GUI numeric text field in a Java application. The class should allow users to input numeric values and provide functionality for handling both integer and non-integer inputs.
You are given a partial code snippet for the constructor of the `GuiNumericTextField` class:
```... | codefeedback |
You are tasked with implementing a traffic simulation system for a city's road network. The road network is represented by a graph, where each intersection is a node and each road segment is an edge connecting two intersections. Your goal is to simulate the movement of vehicles through this network, taking into account... | codefeedback |
You are tasked with implementing a data processing system that utilizes a class hierarchy to analyze and manipulate data. The provided code snippet is a simplified representation of a data processing system that uses a base class `BaseDataGenusProcessor` and its subclass `StructureDGP`. The `StructureDGP` class contain... | codefeedback |
You are tasked with implementing a program to calculate the minimum number of matches required to form a specific number of geometric shapes. Each shape is formed by connecting a certain number of matchsticks. The program should take into account a factor that multiplies the number of matches needed for each shape.
Yo... | codefeedback |
You are tasked with implementing a robust k-means clustering algorithm for a set of speech embeddings. The k-means algorithm is known to be sensitive to the initial placement of cluster centroids, and in some cases, it may fail to converge due to poor initialization. To address this issue, you decide to employ a retry ... | codefeedback |
You are tasked with implementing a Java method to extract a public key from a given KeyStore file. The KeyStore file contains a certificate that holds the public key. Your method should take the KeyStore file and the alias of the certificate as input and return the public key as a result.
You are provided with the fol... | codefeedback |
You are tasked with writing a Bash script to automate the execution of a Spark application for calculating PageRank. The script should handle the setup and execution of the application on a cluster. The provided code snippet is a starting point for the script and contains some variables and initial setup.
Your task is... | codefeedback |
You are tasked with creating a function that can calculate the sum of numbers provided in a custom string format. The input string can contain the following types of data:
1. The string can contain multiple numbers separated by a delimiter. The delimiter can be a comma (`,`), a newline character (`\n`), or a custom mu... | codefeedback |
You are given a list of coin denominations and a target amount of money. Your task is to write a function to find the minimum number of coins needed to make up the target amount. You should assume that an unlimited supply of coins is available for each denomination.
For example, given the coin denominations [1, 2, 5] ... | codefeedback |
You are tasked with creating a Python function that generates a specific type of lambda function based on the given input. The lambda function should accept any number of arguments and return an array of ones with the length specified by the input. Additionally, you need to handle potential exceptions that may arise du... | codefeedback |
You are tasked with creating a Python class that interacts with a server to retrieve job statuses and, optionally, a list of files associated with those jobs. Your task is to implement the `Inquirer` class and its method `get_jobs_statuses` to handle this interaction.
The `Inquirer` class should have the following att... | codefeedback |
You are tasked with creating a PHP function that validates and sanitizes user input data for a user registration form. The input data is provided as an associative array, where the keys represent the form field names and the values represent the user input. The function should perform the following tasks:
1. Validate a... | codefeedback |
You are tasked with creating a Python function that processes a list of user objects and returns a dictionary containing the count of users for each unique username. Each user object is represented as a tuple containing the username and password.
You need to implement the function `count_users` which takes a list of u... | codefeedback |
You are tasked with implementing a dataset registration system for a machine learning framework. The system should allow for the registration of different datasets and provide a way to initialize models with the appropriate dataset using Xavier initialization. Your task is to create a class-based system that enables da... | codefeedback |
You are tasked with creating a PHP class that can convert a given date string to a UTCDateTime object. The class should implement the ParamConverterInterface and provide a method to support the conversion of the date string to a DateTimeInterface object.
Your task is to implement the `convert` method within the class ... | codefeedback |
You are given a hexadecimal string representing a sequence of bytes. Your task is to write a function that decodes this string and returns the corresponding ASCII representation.
Write a function `hex_to_ascii(hex_string: str) -> str` that takes a hexadecimal string as input and returns the ASCII representation of the... | codefeedback |
You are tasked with creating a function that calculates the total padding applied to a SwiftUI view, given the top, leading, bottom, and trailing insets, and the background color of the view. The function should take into account the navigation bar height, safe area insets, and tab bar height, and return the total padd... | codefeedback |
You are tasked with creating a Python class to manage the downloading and storage of Wikidata dump files. The class should have the ability to download different types of dump files and store them for future use. Your task is to implement the `WikidataDumpManager` class with the following requirements:
1. The class sh... | codefeedback |
You are tasked with implementing a function that parses a given code snippet and extracts information about the number of GitHub stars and the imported modules from the crate. The code snippet is written in Rust and contains a partial import statement and a range of GitHub stars.
Write a function `parseCodeSnippet` th... | codefeedback |
You are given a code snippet that involves the creation and comparison of logical formulas. Your task is to implement a function that evaluates whether two logical formulas are equivalent.
A logical formula is represented using a custom enum `Term` with variants `Var` and `Forall`. The `Var` variant holds a string re... | codefeedback |
You are given a sorted 2D matrix of integers with the following properties:
- Each row is sorted in ascending order from left to right.
- The first integer of each row is greater than the last integer of the previous row.
Write a function `searchInMatrix` that takes in a sorted 2D matrix `matrix` and an integer `targe... | codefeedback |
You are tasked with implementing a custom attribute system in C#. Your goal is to create a custom attribute that can be used to annotate fields within a class. The attribute should allow the programmer to specify a token and a field offset for the annotated field. Additionally, you need to create a method that can retr... | codefeedback |
You are tasked with implementing a sorting algorithm that can handle multiple sort queries efficiently. The algorithm should be able to sort a given list of integers based on the specified sorting criteria and return the sorted list. Each sort query will consist of a sorting key and a sorting order. The sorting key wil... | codefeedback |
You are tasked with creating a Python package versioning system. Your task is to implement a class `Version` that represents a software version. The class should support comparison operations such as equality, greater than, less than, etc. The versioning system should follow the semantic versioning scheme, which consis... | codefeedback |
You are tasked with creating a Python script that can parse command-line arguments and execute a specific module based on the provided input. Your script should be able to handle various scenarios and execute the appropriate module based on the user's input.
Your script should be named `coverview.py` and should be abl... | codefeedback |
You are tasked with implementing a custom iterator in Rust for a stock trading application. The iterator should iterate over a list of stock shares and return the number of zero shares encountered. The iterator should keep track of the number of zero shares encountered and provide the ability to reset the iteration to ... | codefeedback |
You are tasked with creating a script to automate the packaging and signing of Debian packages. Your script should take in the package name, version, temporary directory, and output directory as input parameters. The script should perform the following tasks:
1. Import the original source tarball into the temporary dir... | codefeedback |
You are tasked with implementing a learning rate scheduler for a deep learning model. The learning rate scheduler is responsible for adjusting the learning rate during training to optimize the model's performance. The scheduler is defined by a set of factors and parameters, and it follows a specific formula to determin... | codefeedback |
You are tasked with creating a program to parse and extract information from a given HTML code snippet. The HTML code represents a card component displaying details about a course. Your task is to extract specific information from the HTML and present it in a structured format.
The HTML code snippet is as follows:
```... | codefeedback |
You are tasked with creating a script to automate the setup and execution of a testing environment for a PHP project. The script should perform the following tasks in sequence:
1. Remove the package `codedungeon/phpunit-result-printer` from the project's dependencies without updating the composer.lock file or dev depe... | codefeedback |
You are tasked with implementing a Quantity class in C# that represents a physical quantity such as length, mass, time, etc. The Quantity class should support conversion between different units of the same physical quantity. The provided code snippet is a constructor for the Quantity class, which takes a value in a spe... | codefeedback |
You are tasked with implementing a function that processes a list of React components and their corresponding class names. The function should return a new list of React components with modified class names based on a set of rules.
You are given the following code snippet as a starting point:
```jsx
return (
<ListI... | codefeedback |
You are tasked with implementing a user authentication system for a web application. The system should include a user login functionality and role-based access control. You are provided with a TypeScript code snippet that defines the structure of a user and a user login data transfer object (DTO).
The `User` class has... | codefeedback |
You are tasked with implementing a function to determine whether a given number is prime or not. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should return `True` if the number is prime, and `False` otherwise.
You are given a code snippet that r... | codefeedback |
You are tasked with simulating a simple navigation system for a robotic finger within a virtual environment. The robotic finger has the ability to move forward and backward, and it is equipped with sensors to detect its current location and state. Your goal is to implement a Python class that controls the movement of t... | codefeedback |
You are tasked with implementing a gas fee strategy algorithm for a blockchain network. The gas fee strategy is responsible for recommending the appropriate gas fee for transactions based on the current network conditions. The gas fee is determined by the gas price and gas limit, where the gas price is the amount of cr... | codefeedback |
You are tasked with creating a Python program to control a two-wheeled robot equipped with distance sensors. The robot has two wheels, "wheel1 motor" and "wheel2 motor", which can be controlled to move the robot. The distance sensor, referred to as "sensor1", is used to detect obstacles and enable the robot to avoid co... | codefeedback |
You are tasked with creating a Python function that computes the sum of all natural numbers that are multiples of 3 or 5 and are less than a given input number `num`.
Write a function `compute_sum_of_multiples(num)` that takes an integer `num` as input and returns the sum of all natural numbers that are multiples of 3... | codefeedback |
You are tasked with implementing a class method for generating and writing XML data using the ElementTree library in Python. The provided code snippet is a part of a method within a class, and it demonstrates the usage of the ElementTree library to append XML data and write it to a file.
Your task is to complete the i... | codefeedback |
You are tasked with implementing a thread-safe circular buffer in Rust using the given code snippet as a starting point. The code snippet provides the declaration of two static variables: `DATA` and `IDX`. `DATA` is a mutable array of mutable arrays, and `IDX` is an atomic usize variable. The `DATA` array represents th... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. Your program should read in a text file and then prompt the user to input a list of words to search for within the file. The program should then output the count of each word in the list that appears in th... | codefeedback |
You are tasked with implementing a priority-based message queue for a distributed system. The system receives different types of messages, each with its own priority and maximum queue length. Your goal is to design a data structure and implement the necessary methods to handle the message queue efficiently.
You are gi... | codefeedback |
You are tasked with implementing a custom search bar component in a SwiftUI application. The search bar should allow users to input text and perform search operations. Your task is to create a SwiftUI view that encapsulates the functionality of a search bar and its associated coordinator.
You are provided with a code ... | codefeedback |
You are given two lists of strings representing routes taken by two vehicles. Each route is a sequence of directions, where each direction is represented by a single uppercase letter: 'U' for up, 'D' for down, 'L' for left, and 'R' for right. The starting point for both vehicles is the origin (0, 0) on a 2D grid. The g... | codefeedback |
You are tasked with implementing a function that takes a byte array as input and returns a hexadecimal string representation of the bytes. Each byte should be represented by two hexadecimal characters, and the bytes should be separated by a space.
Write a function `byte_array_to_hex_string` that takes a reference to a... | codefeedback |
You are tasked with implementing a function to calculate the exponent of a given number with respect to a given base. The function should take three parameters: `num` (an integer representing the number), `base` (an integer representing the base), and `exp` (an integer representing the exponent). The function should de... | codefeedback |
You are given two strings, S and T, and a function lcs(i, j) that calculates the length of the longest common subsequence (LCS) between the prefix of S ending at index i and the prefix of T ending at index j. The function returns the length of the LCS and uses memoization to optimize the computation. The memoization ta... | codefeedback |
You are tasked with implementing a data structure to track changes made to different types of columns in a database. The data structure should support adding and retrieving changes for integer and string columns. You are given a partial code snippet that demonstrates the usage of this data structure.
Your task is to c... | codefeedback |
You are tasked with implementing a class that represents a person's information and their associated organization. The class should have properties for the person's last name, organization ID, and organization name. Additionally, you need to implement a method that returns the person's information in a specific format.... | codefeedback |
You are tasked with implementing a function that simulates the behavior of a JavaScript function call in Swift. The function should take a JavaScript function, along with its arguments, and execute the function within the Swift environment.
You are given the following code snippet as a reference:
```swift
let promise ... | codefeedback |
You are tasked with creating a Python program to scrape a website and extract specific information. The website "https://www.shelterlist.com/city/ca-sacramento" contains a list of shelters in Sacramento, California. Your goal is to extract the names and addresses of these shelters using web scraping techniques.
Write ... | codefeedback |
You are tasked with implementing a CRC (Cyclic Redundancy Check) algorithm in Swift. The CRC algorithm is used for error-checking in digital networks and storage devices. The provided code snippet initializes a variable `crc` of type `UInt16` using a conditional expression. If `seed` is not nil, its value is assigned t... | codefeedback |
You are tasked with implementing a custom stream reader in Rust. The `ReaderStream` struct is provided, which wraps a generic type `S`. Your goal is to implement a method for the `ReaderStream` that reads a specified number of bytes from the underlying stream and returns them as a slice.
You need to implement the foll... | codefeedback |
You are tasked with implementing a graph compression algorithm for a social network analysis tool. The graph is represented as a collection of nodes and edges, and the compression algorithm aims to reduce the memory footprint of the graph while maintaining its structural integrity. The graph compression algorithm shoul... | codefeedback |
You are tasked with implementing a program to analyze a DataTable containing randomly generated integer values. The DataTable is created with a random number of columns (between 3 and 10) and 10 rows, with each cell containing a random integer between 0 and 100. Your task is to write a function that calculates the sum ... | codefeedback |
You are tasked with creating a Python program that can encrypt and decrypt files using the Fernet symmetric encryption algorithm. The Fernet algorithm is a secure and easy-to-use encryption method provided by the cryptography library in Python. Your program should have two main functions: one for encrypting a file and ... | codefeedback |
You are tasked with implementing a Trie data structure to efficiently store and search for words. A Trie is a tree-like data structure used to store a dynamic set of strings, where each node represents a single character of the string. The root node is empty, and each subsequent level represents one character of the st... | codefeedback |
You are tasked with implementing a simple 2D modeling system for geometric shapes. The system provides a `Model` struct that can be used to create and manipulate shapes. Each shape is defined by its number of sides, fill color, and stroke color. The `Model` struct has methods to add single or multiple shapes, and to mo... | codefeedback |
You are tasked with implementing a C# program that involves working with unions and explicit layout in structs. Your goal is to create a program that manages job object rate control tolerances using unions and explicit layout.
You are given the following code snippet as a starting point:
```csharp
public partial stru... | codefeedback |
You are tasked with simulating the behavior of an application's undo and save functionalities. The application maintains a stack of states, and the undo operation reverts the application to the previous state, while the save operation saves the current state of the application. You need to implement a class `Applicatio... | codefeedback |
You are given a 3x3 grid initially filled with letters A, B, and C. The grid is represented as a 2D array. You need to perform a series of operations on this grid. Each operation involves either removing a letter at a specific position or adding a new letter at a specific position.
The operations are represented as st... | codefeedback |
You are tasked with implementing a function to parse and extract information from a JavaScript object representing a dialog box. The object contains properties for the icon, title, and HTML content of the dialog box. Your goal is to create a function that takes this object as input and returns a formatted string repres... | codefeedback |
You are tasked with creating a program that processes a given HTML table and extracts the data from it. The HTML table contains postal code and locality information. Your program should parse the HTML table and output the postal code and locality data in a structured format.
The HTML table structure is as follows:
```... | codefeedback |
You are tasked with creating a function that processes a list of elements and performs specific actions based on the type of each element. The elements can be of different types, including a custom type called `Indic`. When an `Indic` type element is encountered, the function should check if an object with the same nam... | codefeedback |
You are tasked with implementing a custom timer in Swift using Grand Central Dispatch (GCD). Your goal is to create a DispatchTimer class that allows for the scheduling of recurring events at specified time intervals. The class should provide the ability to start, pause, and resume the timer, as well as handle the time... | codefeedback |
You are working on a machine learning project and need to implement a data sampling algorithm to create subsets of training data from two different datasets. The code snippet provided is a part of the data sampling process. Your task is to complete the implementation of the data sampling algorithm by writing a function... | codefeedback |
You are given a code snippet from a C# program. Your task is to write a program that can parse the given code snippet and extract the namespaces and class names from it.
Write a function or program that takes the code snippet as input and returns a list of namespaces and class names present in the code.
For example, ... | codefeedback |
You are given a list of integers and a target sum. Your task is to write a function that finds all unique combinations in the list that sum up to the target. Each number in the list may only be used once in the combination. The solution set must not contain duplicate combinations.
For example, given the list [10, 1, 2... | codefeedback |
You are tasked with implementing a generic function that performs a specific operation on a collection of elements. The function should be able to handle various types and perform the operation in a flexible manner. Your task is to write a generic function that takes a collection of elements and performs an addition op... | codefeedback |
You are working on a genetic algorithm optimization problem, and you need to implement a fitness function that calculates the distance-based fitness for a set of genomes. The genomes are represented as a list of strings, and the distance between them is calculated using a distance matrix provided by the optimization en... | codefeedback |
You are tasked with implementing a job management system in Rust. The system should support creating, canceling, and deleting jobs. The code snippet provided includes modules for these operations: `create`, `cancel`, `delete`, and `jobs`.
Your task is to create a Rust module that manages jobs and provides functions fo... | codefeedback |
You are tasked with implementing a function that processes a list of chunks and groups them based on a specific key. Each chunk is represented as a tuple containing data and a key. The function should then concatenate the data of the chunks within each group and return a dictionary where the keys are the unique keys fr... | codefeedback |
You are working on a distributed computing system where nodes communicate with each other to perform certain tasks. The code snippet provided is a part of a communication algorithm that aims to minimize communication costs by selectively sending data between nodes. The algorithm iterates through a 3D array `w` and perf... | codefeedback |
You are tasked with testing a Python function that involves patching multiple methods using the `unittest.mock` library. Your goal is to write a unit test that ensures the correct behavior of the `upload` function in the `windlass` module. The `upload` function is responsible for uploading data to a remote location and... | codefeedback |
You are tasked with implementing a generic function that creates an empty immutable map. The function should adhere to the given type signature and utilize the provided `TMap` and `List` data structures. Your goal is to create a TypeScript function that returns an empty immutable map using the provided type definitions... | codefeedback |
You are tasked with implementing a validation mechanism for a web application. The application uses the following method to check if the model is valid and then execute an asynchronous action:
```csharp
protected async Task<bool> ModelValidAndSuccess(Func<Task> action)
{
if (!ModelState.IsValid)
return fal... | codefeedback |
You are tasked with creating a Python program that simulates a simple file transfer server. The server is designed to handle incoming client requests and transfer a specified image file to the client using base64 encoding. Your task is to implement the server-side logic for this file transfer system.
Your program shou... | codefeedback |
You are tasked with creating a FastAPI endpoint for user authentication using JWT (JSON Web Tokens). You need to define a route that accepts a POST request with a JSON body containing an email and password. The endpoint should validate the email and password, generate a JWT token if the credentials are correct, and ret... | codefeedback |
You are tasked with implementing a numerical integration algorithm using the Runge-Kutta-Cash-Karp method to solve a system of ordinary differential equations (ODEs). The provided code snippet initializes the necessary components for the integration process. Your task is to complete the implementation by defining the O... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.