instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a function that takes a string as input and modifies it based on a specific set of rules. The function should modify the input string by replacing all occurrences of certain characters with their corresponding replacements, and then return the modified string. The replacement rules are ... | codefeedback |
You are tasked with creating a Python class that manages API session accesses for a web application. The class should handle the creation, retrieval, and deletion of API sessions, and it should maintain a record of these accesses. Your task is to implement the `APISessionManager` class with the following requirements:
... | codefeedback |
You are tasked with creating a Python function that generates and executes a SQL query based on given input parameters. The function should construct a SELECT query with optional WHERE clause and return the result set from the database.
You are provided with a code snippet that partially implements the functionality. ... | codefeedback |
You are tasked with implementing a function that performs genesis initialization for a module in a blockchain application. The function should take in the context of the blockchain, a JSON marshaler, and raw message data, and return a list of validator updates. The provided code snippet contains a commented-out impleme... | codefeedback |
You are given a list of operations to be performed on a stack. The operations are represented as strings in the following format:
- "PUSH X": Push the integer X onto the stack.
- "POP": Pop the top element from the stack.
- "INC Y Z": Increment the bottom Y elements of the stack by Z.
Your task is to simulate these op... | codefeedback |
You are given an array of integers `nums` of length `n`. Your task is to write a function that finds the two numbers in the array that have the maximum absolute difference. The function should return the absolute difference and the two numbers themselves.
Write a function `maxAbsoluteDifference` that takes in an array... | codefeedback |
You are tasked with creating a program that processes text content to identify and extract specific patterns using regular expressions. Your program should be able to identify and extract various types of text patterns, such as block quotes, code spans, and mathematical expressions, based on the provided regular expres... | codefeedback |
You are tasked with creating a Python class for normalizing audio and video files using FFmpeg. Your class should provide a simple interface for users to normalize media files to a specified audio level.
Create a class called `FFmpegNormalizer` with the following specifications:
- The class should have a constructor t... | codefeedback |
You are tasked with creating a program that extracts URLs from an HTML file and returns them as a list of strings. The HTML file contains a list of anchor tags (`<a>`) with `href` attributes representing the URLs. Your program should parse the HTML file and extract all the URLs present in the anchor tags.
For example,... | codefeedback |
You are tasked with implementing a custom data structure called `DayOf` in Swift. The `DayOf` data structure represents a day of the week and contains two values of type `A`. Your task is to define the `DayOf` type and implement two functions: `extract` and `coflatMap`.
The `DayOf` type has the following definition:
`... | codefeedback |
You are tasked with creating a Python function that performs a specific file operation based on certain conditions. The function should take in three parameters: `version` (string), `task` (object), and `langs_path` (string). The `task` object has an attribute `app` which contains a property `jam_version`. The function... | codefeedback |
You are tasked with creating a Python function that compares two files and asserts whether a specific portion of one file matches the content of another file. Your task is to implement the function that performs this comparison and raises an assertion error if the content does not match.
You are given the following co... | codefeedback |
You are tasked with implementing a simplified version of a performance monitoring system. The system should track the duration of various operations and provide summary statistics for different categories of operations.
You are given a code snippet from a Java method that is part of the performance monitoring system. ... | codefeedback |
You are tasked with implementing a media file metadata parser that extracts and populates metadata information from audio and video files. The provided code snippet is a part of a larger media file parsing library. The `Fill` function is used to populate metadata fields such as audio codec, codec settings, encoded libr... | codefeedback |
You are tasked with implementing a function that mimics the behavior of the `export default` statement in JavaScript. The `export default` statement is used to export a single default export from a module. When another module imports the default export from the original module, it can choose to import it under any name... | codefeedback |
You are tasked with creating a Minecraft mod that utilizes the Forge modding framework. Your mod needs to listen for a specific event and perform a custom action when that event occurs. The event you are interested in is the opening of a GUI (Graphical User Interface) within the game. You want to register a listener fo... | codefeedback |
You are given a text file containing a series of comments in the form of Python multi-line comments. Each comment starts with a '#' symbol and may span multiple lines. Your task is to write a program that counts the total number of comments in the file and the average number of lines per comment.
Write a function `cou... | codefeedback |
You are tasked with implementing a task management system for a web application. The system should allow users to create, view, and manage tasks within different folders. Each task can be marked as complete or incomplete, and users should be able to remove tasks from the system.
You are given a code snippet from the f... | codefeedback |
You are tasked with creating a program that simulates the behavior of the `rsync` command for synchronizing files and directories between two locations. The `rsync` command is a widely used utility for efficiently transferring and synchronizing files across systems. Your program should handle the synchronization of fil... | codefeedback |
You are tasked with creating a user authentication system using PHP. Your goal is to implement a function that verifies a user's credentials and sets a session if the user is active and the password is correct.
You are given the following code snippet as a starting point:
```php
if ($user['active'] == 1) {
// CEK... | codefeedback |
You are tasked with creating a form validation function for a web application. The function should validate the input fields based on the provided rules and return an array of error messages for any invalid fields.
You are given a code snippet representing an input field in the form. The input field has the following ... | codefeedback |
You are tasked with implementing a customer management system for a retail company. One of the requirements is to generate a unique customer ID for each new customer. The customer ID should be a combination of the customer's initials and a sequential number. The initials are derived from the customer's first and last n... | codefeedback |
You are tasked with implementing a class that manages file operations for a Visual Studio solution. The class should provide functionality for working with solution files, project file references, and stringly-typed paths. Your task is to complete the implementation of the class by adding the necessary methods to perfo... | codefeedback |
You are given a string representing a sequence of instructions. Each instruction is either "(" or ")". The instructions are meant to represent movements in a building. Each "(" instruction means going up one floor, and each ")" instruction means going down one floor. The building has an infinite number of floors, and t... | codefeedback |
You are working on a graphics application that involves handling color values and layout parameters. Your task is to create a function that calculates the total size of a header section based on the given constants and rules.
Given constants:
- `RGB_EVENT_MARKER`: A constant representing a color marker in RGB format.
... | codefeedback |
You are given a code snippet that represents a configuration for a game or simulation system. The snippet contains declarations of various data structures and their associated properties. Your task is to write a program that parses this configuration and extracts specific information based on the given structure.
Your... | codefeedback |
You are tasked with creating a script to automate the generation of gRPC code from Protocol Buffer (.proto) files using the `protoc` compiler. The provided code snippet is a part of such a script and contains some variables and a command to execute `protoc` with specific options and flags.
Your task is to write a Bash... | codefeedback |
You are tasked with implementing a simple checkpoint system for a 3D game using Unity and C#. The provided code snippet is a part of the checkpoint system. The `OnTriggerEnter` method is called when another collider enters the trigger collider attached to the game object. The goal is to complete the implementation of t... | codefeedback |
You are tasked with implementing a simple parser for a custom programming language. The parser is responsible for processing tokens generated by a lexer and constructing an abstract syntax tree (AST) for further processing. Your goal is to implement the `Parser` struct and its associated methods to achieve this functio... | codefeedback |
You are tasked with implementing a higher-order function called `reject` in TypeScript. The `reject` function should take an array or object as input and return a new array or object containing only the elements that do not satisfy a given predicate function.
The `reject` function should be implemented using the provi... | codefeedback |
You are given a list of strings representing various categories. Your task is to implement a function that takes this list as input and returns a dictionary where the keys are the first letters of the categories and the values are lists of categories starting with the corresponding letter. If a category starts with a l... | codefeedback |
You are working on a recommendation system for a book-sharing platform. The system aims to suggest books to users based on their wishlists and the wishlists of other users. You have been given a snippet of code that processes the wishlists of users and calculates suggestion scores for books. Your task is to complete th... | codefeedback |
You are tasked with implementing a concrete subclass of the abstract class `CmsPageAdapter` to adapt a specific type of source data to a `CmsStructureModel`. The `CmsStructureModel` represents the structure of a content management system (CMS) page, while the `CmsPageAdapter` serves as a generic adapter for different t... | codefeedback |
You are tasked with creating a Python function that retrieves replay data from a database based on a specified timestamp. The function should interact with a database session, send a GET request to a specified URL, and handle the response data appropriately. Your task is to implement the function `get_replays_with_date... | codefeedback |
You are tasked with creating a Python class that manages the placement of text labels in a document. The class, `TextLabelManager`, should provide methods for adding text labels and generating a PDF document with the added labels. The text labels can be placed in different positions such as 'left', 'right', 'top', or '... | codefeedback |
You are tasked with implementing a Python function that processes the output of a command-line program and extracts specific information from it. The output of the program is captured in the variable `result.stdout_`, which contains a multi-line string. Each line in the string represents a separate piece of information... | codefeedback |
You are tasked with creating a Python program that utilizes the `openface` library to perform facial recognition and then organizes the recognized faces into separate directories based on their identities. The program should take a source directory containing images of individuals' faces as input and create a destinati... | codefeedback |
You are tasked with implementing a custom view in Swift that separates and displays two lists of items. The view should be able to receive two arrays of items and visually separate them within the view. Each list should be displayed with its own distinct style, and the view should be able to handle different types of i... | 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 account holder's name and account balance.
Create a Python class named `BankAccou... | 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 tasked with creating a script that automates the process of running ESLint, a popular tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. The provided code snippet sets the `-e` flag, which causes the script to exit immediately if any command exits with a non-zero status, and ass... | codefeedback |
You are tasked with implementing a simple TCP socket server for a keylogger application. The provided code snippet shows the function `start_socket_server()` that sets up and starts the server. The server listens on all network interfaces (`0.0.0.0`) and a specific port denoted by `SOCKET_PORT`. Upon starting, it logs ... | codefeedback |
You are tasked with implementing a hierarchical clustering algorithm using the Poincaré ball model. The Poincaré ball model is a hyperbolic space that is commonly used for clustering data with hierarchical structures. In this problem, you will create a Python class that performs hierarchical clustering using the Poinca... | codefeedback |
You are tasked with implementing a Python class that manages a process and its associated PID file. The given code snippet is part of a class method that handles the reloading of the process. Your task is to complete the implementation of the `ProcessManager` class by adding the necessary methods to manage the PID file... | codefeedback |
You are tasked with implementing a function that processes an array of tags and returns a subset of the most popular tags. Each tag is represented as a string, and the popularity of a tag is determined by the number of occurrences in the input array. The function should return a subset of the most popular tags, limited... | codefeedback |
You are tasked with implementing a class that manages email verification for a mobile application. The class, `EmailVerificationManager`, should handle the process of sending a verification email to the user and then navigating to the login screen upon successful completion. The class should utilize the Android framewo... | codefeedback |
You are tasked with creating a web application using Python and Panel library to display a modal dialog box with customizable content. The modal should be triggered by a button and should contain a form with input fields for the user to enter their name and email address. Upon submission of the form, the modal should d... | codefeedback |
You are tasked with implementing a function that checks whether a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization.
You need to write a function `isPalindrome` that takes ... | codefeedback |
You are tasked with creating a React Native component that fetches a list of sentiments from an API and allows the user to select multiple sentiments using a checkbox group. Upon confirming the selected sentiments, an alert should be displayed to confirm the user's selection. You are provided with a code snippet that i... | codefeedback |
You are tasked with creating a script to automate the synchronization of articles from a local directory to a remote server using Ruby. The script should handle the transfer of files from the local directory to the remote server, ensuring that only new or modified files are synchronized.
Your task is to implement a Ru... | codefeedback |
You are tasked with implementing a class that represents a rational number and provides methods for arithmetic operations. The class should be able to simplify the rational number to its simplest form and provide a string representation of the rational number.
You are given a code snippet that represents a method in t... | codefeedback |
You are given a Python dictionary representing a nested structure. Your task is to write a function that flattens this nested dictionary into a single-level dictionary, where the keys are concatenated with a dot (.) to represent the nesting.
For example, given the following nested dictionary:
```python
nested_dict = {... | codefeedback |
You are tasked with implementing a simple command-line interface for a state machine. The state machine can be in one of several states, and the user can input commands to interact with the state machine. Your task is to implement the logic for processing user commands and updating the state machine accordingly.
You a... | codefeedback |
You are tasked with creating a multithreaded Python program that simulates a simple ticket booking system for a movie theater. The program should use threading to handle multiple ticket booking requests concurrently. The movie theater has a limited number of seats, and each booking request should be processed in a thre... | codefeedback |
You are tasked with creating a custom UITableViewCell subclass for a location-based app. The cell should display information about a specific location, including its name, street, city, date, and an image. Your task is to implement the `LocationTableViewCell` class with the necessary properties and methods to populate ... | codefeedback |
You are given a list of courses labeled from 0 to numCourses - 1, and an array of prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi before you can take course ai. Write a function to return the ordering of courses you should take to finish all courses. If it is impossible to finish ... | codefeedback |
You are tasked with implementing a custom data processing pipeline using the MiddleMan library in C#. The MiddleMan library provides a flexible and efficient way to create data processing pipelines by allowing the chaining of multiple processing steps.
Your task is to create a pipeline that performs the following oper... | codefeedback |
You are tasked with implementing a JSON serializer in C#. Your goal is to write a method that serializes a given object into a JSON string. The JSON serializer should support serializing primitive types (such as integers, strings, booleans), arrays, and objects. The serializer should handle nested objects and arrays, a... | codefeedback |
You are working on a computer vision project that involves processing images and extracting information from them. Your task is to write a Python function that takes in an image file path, performs certain operations on the image using the OpenCV library, and then processes the results to generate a specific output for... | codefeedback |
You are tasked with implementing a custom data structure in Swift that mimics the behavior of a loadable integer wrapper. The loadable integer wrapper is a type that represents an integer value and provides the ability to load and store the value from memory. The wrapper has the following properties and methods:
Prope... | codefeedback |
You are tasked with implementing a function to initialize parameter parallel groups for distributed training in a parallel computing environment. The function `_initialize_parameter_parallel_groups` takes an optional parameter `parameter_parallel_size`, which represents the number of processes to be used for parameter ... | codefeedback |
You are tasked with implementing a function to calculate the time derivative of the spatial metric in a numerical relativity simulation. The given code snippet is part of a larger computational physics simulation and represents a portion of the time evolution equation for the spatial metric in a spacetime with a specif... | codefeedback |
You are given a code snippet that processes input from the standard input. The input consists of rows, where each row contains tab-separated fields. The fields are delimited by the characters '~^~'. Your task is to write a program that reads the input and processes it according to the following rules:
1. For each row,... | codefeedback |
You are tasked with implementing a point adjustment system for a loyalty program. The system should allow for adjusting the points of a specific payer by deducting points from the oldest transactions associated with that payer.
You are given a Python function `adjust(data)` that takes a dictionary `data` as input. Th... | codefeedback |
You are tasked with implementing a particle simulation program. The program should allow users to set various parameters for the simulation, such as maximum velocity, random factor, and other relevant attributes. The provided code snippet is a part of the user interface setup for the program, where controls for setting... | codefeedback |
You are tasked with implementing a custom neural network layer in Python using PyTorch. Your task is to create a class called `CustomLayer` that inherits from `nn.Module` and contains two operations: a softmax operation and a hyperbolic tangent (tanh) operation. The `forward` method of the class should take an input te... | codefeedback |
You are tasked with creating a Python function that automates the process of logging into a website using Selenium and Chrome WebDriver. Your function should take in the website URL, username, and password as input parameters, and return a boolean value indicating whether the login was successful or not.
Your function... | codefeedback |
You are tasked with creating a PHP class that manages a simple inventory system for a fictional online store. The class should allow for adding and removing items from the inventory, as well as checking the availability of a specific item.
Your task is to implement the `Inventory` class with the following specificatio... | codefeedback |
You are tasked with creating a program that processes a list of software licenses and determines whether each license is valid according to the Apache License, Version 2.0. The Apache License, Version 2.0 is a permissive free software license written by the Apache Software Foundation. It allows users to use the softwar... | codefeedback |
You are tasked with implementing a file tracking system that keeps track of files being added and removed. The system should maintain two sets of files: `todo` for files to be processed and `done` for files that have been processed. The system should also calculate a unique hash for each file based on its original path... | codefeedback |
You are tasked with creating a Python class to represent and manipulate microscope settings. The class should have methods to set and get the values of various microscope parameters, such as acquisition mode, beam current, beam energy, convergence angle, magnification indicated, and microscope name. Each parameter can ... | codefeedback |
You are tasked with creating a C# method that validates the configuration settings for an authentication provider. The method should ensure that the required environment variables are set and that the configuration object is properly initialized.
You are given the following C# code snippet as a starting point:
```cs... | codefeedback |
You are tasked with creating a program that categorizes companies based on their industry. The program should take a company's industry code as input and output the corresponding industry name. The industry codes and their corresponding names are as follows:
1: "Other"
2: "Mining"
3: "Processing"
4: "Energy"
5: "Utili... | codefeedback |
You are tasked with implementing a class that renders data into a string format. The class should adhere to a specific interface and handle various data types. Your task is to create a PHP class that fulfills the requirements of the given interface and can render different types of data into a string.
You are provided... | codefeedback |
You are working on a user role management system for a project management application. The code snippet provided is part of a Python class that handles the creation and management of user roles on a project. The `_create_user_role_on_project` method is responsible for creating user roles on a project, and the `_list_an... | codefeedback |
You are tasked with simulating the behavior of a network device controller in response to a series of commands and messages. The controller is responsible for configuring a device and sending a renew message to the device. The given code snippet is a part of the controller's functionality, where it resets the device to... | codefeedback |
You are tasked with implementing a function that performs element-wise multiplication on two matrices using the Eigen C++ library. The function should handle different scenarios, including when one of the matrices is a row vector and the other is a matrix. Your task is to write a function that correctly performs the el... | codefeedback |
You are tasked with implementing a Python function to calculate the gravitational acceleration at a specific geodetic latitude on the Earth's surface. The gravitational acceleration is influenced by the Earth's rotation and its ellipsoidal shape. The formula for calculating the gravitational acceleration (g) at a given... | codefeedback |
You are tasked with implementing a utility function to determine whether a given string is a valid Base64 encoded string. Base64 encoding is a method of encoding binary data into an ASCII string format, which is commonly used for encoding data in email attachments, image uploads, and other data transmission processes.
... | codefeedback |
You are tasked with creating a Python function that generates a directed graph using the `networkx` library, saves it to a temporary file in the DOT format, and then returns the path to the temporary file. Your function should take in the number of nodes in the graph and the probability of an edge between any two nodes... | codefeedback |
You are tasked with creating a function that processes a CSV file containing information about tasks and stores them in a database using functional programming techniques. The CSV file contains the following columns: `id`, `name`, `description`, and `completed`. Each row represents a task to be stored in the database. ... | codefeedback |
You are tasked with implementing a feature flag system for a web service that provides different response types based on enabled features. The code snippet provided is a part of the feature flag system and demonstrates the use of conditional compilation in Rust.
Your task is to create a function `generate_response` th... | codefeedback |
You are tasked with implementing a function that generates a statistical table for a given set of test titles, variable names, and statistics. The function should utilize the `limix._display.Table` class to create the table and populate it with the provided data.
The function `draw_lrt_table(test_titles, pv_names, sta... | codefeedback |
You are working in a factory that produces items on a conveyor belt. The belt has N slots, and each slot contains a number representing the item's durability. Additionally, there are K robots placed on the belt to assist in the production process. The robots can move along the belt and pick up items to perform various ... | codefeedback |
You are tasked with creating a script to automate the process of compiling a C++ project. The project has the following directory structure:
```
project/
src/
main.cpp
file1.cpp
file2.cpp
include/
header1.h
header2.h
obj/
lib/
```
Your script should perform the ... | codefeedback |
You are given a non-negative index `rowIndex`. Your task is to generate the `rowIndex`-th row of Pascal's triangle.
Pascal's triangle is a triangular array of binomial coefficients. The `n`-th row of the Pascal's triangle represents the coefficients of the expanded polynomial `(a + b)^n`.
For example, when `rowIndex ... | codefeedback |
You are given a Python function `merged_arrays(heap1, heap2)` which takes in two heaps `heap1` and `heap2`. Each heap is represented as a list of integers and contains elements in ascending order. Your task is to implement the `merged_arrays` function to return a single combined array with all the elements from both he... | codefeedback |
You are tasked with implementing a network update algorithm for a social media platform. The platform has a network of users, and the algorithm aims to update the connections between users based on certain criteria. The code snippet provided is a part of the network update process, where the function `update_network` i... | codefeedback |
You are tasked with implementing a custom pipeline for feature data processing using the AutoNet framework. The AutoNetFeatureData class inherits from the AutoNet class and is responsible for defining the default pipeline for feature data processing.
Your task is to complete the implementation of the get_default_pipel... | codefeedback |
You are tasked with implementing a class for creating cylinder primitives in a 3D graphics library. The class should support two constructors, one with default parameters and another with explicit parameters. Your task is to implement the constructors and ensure that the cylinder is aligned with the height in the z-dir... | codefeedback |
You are tasked with creating a program to efficiently crawl and retrieve submissions for problems from an online judge platform. The code snippet provided is a simplified representation of the asynchronous crawling process using Python's `asyncio` library.
Your task is to implement a function that takes a list of prob... | codefeedback |
You are tasked with implementing a function to retrieve the latest day for the weekly ranking. The function should take an optional format parameter and return the latest day in the specified format.
You are given the following code snippet as a starting point:
```php
/**
* Retrieve the latest day for the weekly rank... | codefeedback |
You are tasked with implementing a function to calculate the factorial of a given non-negative integer. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 5 (denoted as 5!) is 5 * 4 * 3 * 2 * 1 = 120.
Your task is to implement the `f... | codefeedback |
You are tasked with implementing a wallet system for a financial application. The system involves transferring funds from one user's wallet to another. You are given a Python code snippet that partially implements this functionality using SQLAlchemy, a popular Python SQL toolkit and Object-Relational Mapping (ORM) libr... | codefeedback |
You are given a Python class with a method `merge_k_sorted_lists` that takes in a list of sorted lists and merges them into a single sorted list. The method uses a helper function `merge_two_sorted_lists` to merge two sorted lists. Your task is to complete the implementation of the `merge_k_sorted_lists` method to merg... | codefeedback |
You are tasked with implementing a simple messaging system using Python's Twisted framework. The provided code snippet includes the beginning of a class definition for a client avatar in a networking application. Your task is to complete the implementation of the `ClientAvatar` class by adding methods to handle message... | codefeedback |
You are tasked with implementing a simple calculator program that can perform addition and subtraction operations on numerical inputs. The calculator accepts a series of tokens representing either numbers or operators and must evaluate the expression to produce a final result.
The calculator supports the following ope... | codefeedback |
You are tasked with creating a SwiftUI view for an insulin pump application. The view, `InsertCannulaView`, is responsible for guiding the user through the process of inserting a cannula for insulin delivery. The view is initialized with an `InsertCannulaViewModel` object, which manages the data and behavior of the vie... | codefeedback |
You are tasked with implementing a session visit counter for a web application. The session visit counter should keep track of the number of times each page is visited by a user. The code snippet provided is a series of assertions that test the functionality of the session visit counter. The `client` object simulates a... | codefeedback |
You are tasked with creating a script to automate the process of moving plot directories based on certain conditions. The script should iterate through a list of directories and move each directory to a specified destination if certain conditions are met. Your task is to implement the logic for moving the plot director... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.