instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are given a string consisting of only '0's and '1's. Your task is to write a function `minOperations` to determine the minimum number of operations required to make the string alternating, i.e., changing '0's to '1's and vice versa. An operation consists of flipping a single character.
For example, given the input... | codefeedback |
You are tasked with creating a program to implement the FizzBuzz game. In this game, the program must print the numbers from 1 to a given number, but for multiples of three, it should print "Fizz" instead of the number, and for the multiples of five, it should print "Buzz". For numbers that are multiples of both three ... | codefeedback |
You are tasked with implementing a function that evaluates a built-in function call in a programming language. The function takes an argument and a `Builtin` struct containing information about the built-in function to be called. Your goal is to write a function that correctly evaluates the built-in function call based... | codefeedback |
You are working on a data tracking system that involves creating SQL queries based on the fields of a Django model. The code snippet provided is a part of a Python class method that constructs a dictionary of fields and their corresponding SQL expressions for insertion into a database. The fields are derived from the m... | codefeedback |
You are tasked with creating a custom overlay view for an iOS application. The overlay should display a semi-transparent layer over the existing content and allow interaction with the underlying views. To achieve this, you need to implement a custom subclass of `UIView` that provides the overlay functionality.
Your cu... | codefeedback |
You are tasked with implementing a simple observer pattern in C++. The observer pattern is a behavioral design pattern that defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. In this problem, you will create a simplified ver... | codefeedback |
You are tasked with implementing a simple expression parser for arithmetic operations. The given code snippet represents the abstract syntax tree (AST) for the expressions. Each AST node has a corresponding operation and may contain sub-expressions. Your goal is to write a function that evaluates the given AST and retu... | codefeedback |
You are tasked with creating a Bash script to manage printing files on a network printer. The script should check if the count of files to be printed exceeds a certain period of time and, if so, print the file and add a timestamp to a log file.
The script should take the following inputs:
- `$count`: The count of file... | codefeedback |
You are tasked with implementing a function that processes raw lines of code from a version control system and extracts specific information based on certain conditions. The function takes in various parameters and returns a tuple containing the extracted information.
The function signature is as follows:
```rust
fn p... | codefeedback |
You are tasked with implementing a function that performs a binary search on a sorted list of integers. The function should return the index of the target integer if it is present in the list, and -1 if it is not found. However, the function should also allow for an optional parameter `end` to specify the end index for... | codefeedback |
You are tasked with implementing a plagiarism detection algorithm using the Longest Common Subsequence (LCS) approach. The goal is to compare two sets of sentence tokens extracted from large text files and determine if the similarity between the two sets exceeds a given plagiarism threshold.
You are provided with a co... | codefeedback |
You are tasked with implementing a custom version of the `Enum.TryParse` method in C#. The `Enum.TryParse` method is used to convert a string representation of an enum value to the corresponding enum value. The method signature is as follows:
```csharp
public static bool TryParse<TEnum>(string value, out TEnum result)... | codefeedback |
You are tasked with implementing a setup package for a software application. The setup package should perform various initialization tasks required for the application to run smoothly. Your goal is to create a function that sets up the package by executing a series of predefined tasks.
You are given a code snippet tha... | codefeedback |
You are tasked with creating a Python script that generates a software license file based on the given information. The license file should include the kernel protocol version, license type, and author information. Your task is to write a function that takes the kernel protocol version information, license type, and au... | codefeedback |
You are working on a user management system for a web application. The system has a module for user profile management, and you need to implement authorization checks for different user roles. The code snippet provided includes two functions: `identity.authorizedForApp` and `controllers.updateUserProfile`. The `identit... | codefeedback |
You are tasked with implementing a generic function that processes a vector of elements using a specified operation. The function takes a vector of elements and applies the given operation to each element, producing a new vector of the same size as the input vector.
You are provided with a code snippet that outlines t... | codefeedback |
You are tasked with creating a generic data structure that simulates a simplified version of a web service request handling system. The system consists of policies that define the rules for handling requests and services that process the requests. Your goal is to implement the data structure and its associated methods ... | codefeedback |
You are tasked with creating a program that monitors and processes specific window messages in a Windows environment. Your task is to implement a message pump hook function that monitors for `WM_MOVE` and `WM_MOVING` messages on a top-level window and passes notifications to the appropriate instances.
Your program sho... | codefeedback |
You are tasked with implementing a TypeScript function that retrieves the version of Ionic 1 used in a given environment. The function signature is as follows:
```typescript
export declare function getIonic1Version(env: IonicEnvironment): Promise<string | undefined>;
```
The `IonicEnvironment` type represents the env... | codefeedback |
You are given a class `Calculator` with a member function `calculate` that takes a string as input and returns the result of a mathematical expression. The expression can contain the operators '+', '-', '*', and '/' and may also include parentheses for grouping. The input string is guaranteed to be a valid mathematical... | codefeedback |
You are tasked with implementing a Twitter API client in Python. Your goal is to extend the functionality of the existing code snippet by adding a method to set the type of request to a retweet. You should create a method `set_request_type_as_retweet` within the same class that sets the type of request to a retweet and... | codefeedback |
You are tasked with creating a Discord bot that responds to specific commands with customized messages. Your bot should respond to the command "Info" by sending a message containing the creator's name and a copyright notice. However, the creator's name should be dynamically inserted into the message. Your task is to wr... | codefeedback |
You are given a snippet of PHP code that is part of a script to generate an HTML table. The code processes data from a multidimensional array and constructs table rows and cells based on the array values. Your task is to write a function that takes an array of data and generates the corresponding HTML table based on th... | codefeedback |
You are tasked with creating a program to generate random data for educational institutions. The program should generate data for a specified number of institutions, with each institution having various attributes such as name, state ID, local government area (LGA) ID, term ID, category ID, address, and school type ID.... | codefeedback |
You are tasked with implementing a class that manages a list of actions for a task management system. The class, `ActionList`, should support adding, removing, and executing actions. Each action can be of a normal type or a special type. Normal types of actions are executed in the order they were added, while special t... | codefeedback |
You are tasked with implementing a signal processing algorithm to analyze raw data from a file. The provided code snippet is a method `tick()` within a class `RawFileSource` that reads two short integers from a file and converts them into complex numbers. The integers represent the in-phase (I) and quadrature (Q) compo... | codefeedback |
You are working on a cloud infrastructure project using Pulumi, a popular infrastructure as code tool. Your task is to create a custom Pulumi resource for managing floating IP addresses within an OpenStack Nova (compute) environment. The `FloatingIP` class should be designed to handle the creation, update, and deletion... | codefeedback |
You are tasked with simulating a simple traffic light system using Java. The traffic light system consists of three lights: red, yellow, and green. Each light is represented by a separate thread, and the lights should transition in the following sequence: green -> yellow -> red -> green, with each light staying on for ... | codefeedback |
You are working on a data processing pipeline that involves splitting large datasets into smaller chunks for parallel processing. Your task is to create a Bash script that automates the process of combining these split data files and then extracting the contents of the combined archive.
You have been provided with the... | codefeedback |
You are tasked with optimizing the performance of a Python program that simulates the n-body problem, which involves predicting the motion of a group of celestial bodies interacting through gravitational forces. The provided code snippet uses Cython to compile a Python file "nbody.pyx" into a C extension module, aiming... | codefeedback |
You are tasked with implementing a Python function that processes a configuration file and returns a dictionary containing the configuration data. The configuration file is structured using sections and key-value pairs. However, the provided code snippet is incomplete and lacks the necessary context to understand the p... | codefeedback |
You are tasked with implementing a Python class method that processes phone numbers and returns specific data related to the phone number. The method should take a phone number as input, parse it, and then extract and return the country code, national number, country name, and time zones associated with the phone numbe... | codefeedback |
You are tasked with creating a script to monitor and manage the scaling of pods in a Kubernetes environment. The script should wait for a specific target to be running, measure the elapsed time, log a message, and then rescale the pods to a specified number.
The script snippet provided is part of a larger script and c... | codefeedback |
You are working on a project that involves integrating a Python script with the AEDT (Ansys Electronic Desktop) software for electromagnetic simulations. As part of this project, you need to create a class method that inserts a 3D component into the AEDT environment and handles rotation based on certain conditions. The... | codefeedback |
You are tasked with creating a user authentication system for a web application. The provided code snippet includes imports for various controllers, middlewares, and schemas related to user sessions and user creation. Your goal is to implement the necessary functionality to handle user authentication using the imported... | codefeedback |
You are tasked with simulating a producer-consumer economy in a fictional world. The producer is responsible for creating and distributing two types of products: food and goods. The population of the world consumes these products, and their happiness is determined by the availability and consumption of these products. ... | codefeedback |
You are tasked with implementing a simple registry system for OpenCL kernel functions. The provided code snippet is a part of a C++ program that manages the registration and retrieval of OpenCL kernel functions using a registry class `cl_kernel_mgr` and a wrapper class `cl_kernel_wrapper`.
The `cl_kernel_mgr` class is... | codefeedback |
You are tasked with implementing a simplified version of the `popd` command, which is used to remove directories from a stack of directories. The `popd` command removes the top directory from the stack and changes the current working directory to the directory that was removed. If the stack is empty, an error message i... | codefeedback |
You are tasked with creating a class hierarchy for a space combat game. The game involves various types of enemy spaceships, each with its own set of statistics. The game developers have provided an interface `IEnemyStats` that extends the `ICharacterStats` interface. Your task is to design a class hierarchy that imple... | codefeedback |
You are tasked with implementing a priority queue data structure using Python. The priority queue should support the following operations:
1. `insert(item, priority)`: Insert an item with a specified priority into the priority queue.
2. `pop()`: Remove and return the item with the highest priority from the priority que... | codefeedback |
You are working on a project to develop a custom data mapping module for a neurophysiology data processing application. As part of this project, you need to create a custom mapping class for a specific data type called ICEphysFile, which contains custom icephys tables such as InteracellularRecordings and SimultaneousRe... | codefeedback |
You are tasked with creating a script to process blockchain data and extract specific information. The script will read a CSV file containing block data and use the Bitcoin Core command-line interface (CLI) to retrieve additional blockchain information. Your task is to write a Bash script that accomplishes the followin... | codefeedback |
You are tasked with implementing a Python class method that handles the deactivation of certain environment settings. The method, `down`, takes two parameters: `args` and `extra_args`, both of which are optional. If `args` is not provided, the method should immediately return without performing any further actions. Oth... | codefeedback |
You are working on a data processing system that involves joining and unpacking tuples from different tables. Your task is to implement a function that processes a join operation and unpacks tuples based on certain conditions.
You are given a code snippet that includes a function `processJoin` and some related operati... | codefeedback |
You are tasked with implementing a logging system that records the date and time of each log entry. The provided code snippet includes a function to generate a formatted date string and a namespace for logging functionality. Your task is to complete the logging system by implementing a function to log messages along wi... | codefeedback |
You are tasked with creating a function that initializes and returns an instance of Alamofire Session with a custom ServerTrustManager. The ServerTrustManager is responsible for evaluating the trustworthiness of the server's TLS certificate. The provided code snippet serves as a starting point for the function, and you... | codefeedback |
You are tasked with implementing a Python function that processes image data and calculates the average loop time for the processing. The function receives an image and performs some operations on it using the OpenCV library. Additionally, it interacts with hardware by waiting for a key press event to exit the program ... | codefeedback |
You are tasked with creating a method to validate and process incoming messages in a messaging application. The code snippet provided is a part of the existing message processing logic. The snippet shows the initial validation and logging steps for an incoming message.
Your task is to implement the remaining part of t... | codefeedback |
You are tasked with creating a program to process and display data retrieved from a database. The data is organized into groups, and each group contains multiple items. Your program should iterate through the groups and print the items within each group. Additionally, if there is an error while retrieving the data from... | codefeedback |
You are tasked with implementing a custom control for a user interface that executes specific code in response to user interactions. The control should be able to handle various types of user interactions, such as button clicks, text input, or mouse movements, and trigger the execution of custom code defined by the dev... | codefeedback |
You are tasked with implementing a custom HTTP response class in PHP. The class should have the following properties and functionality:
Properties:
- `BACKUP_CODE`: A constant integer with the value 303.
- `CLIENT_CODE`: A constant integer with the value 400.
- `REGION_CODE`: A constant integer with the value 304.
- `... | codefeedback |
You are tasked with implementing a class method for a data structure that represents a list of x-values and a corresponding list of y-values. The method should update the y-value at a given x-index by adding a specified value to it. The method should also handle cases where the x-value does not exist in the list, and i... | codefeedback |
You are given a list of triplets representing relationships between three elements. Each triplet consists of three integers, where the first integer is related to the second and the second is related to the third. The relationships are transitive, meaning if (a, b) and (b, c) are in the list, then (a, c) is also in the... | codefeedback |
You are tasked with implementing a job queue system in Python. The job queue system should support the following operations:
1. `unassignJob(jobId)`: This method should unassign a job with the given `jobId` from the queue.
2. `get(jobId)`: This method should retrieve the job with the given `jobId` from the queue.
3.... | codefeedback |
You are tasked with creating a script to automate the deployment of a Kubernetes storage class and wait for it to be provisioned before proceeding with further operations. The script should apply the storage class configuration and then continuously check the status of the storage class until it is provisioned.
Your t... | codefeedback |
You are tasked with creating a unit test for a ViewModel in an iOS application using Swift. The ViewModel is responsible for processing user input and providing data to the View. Your goal is to write a test case that ensures the ViewModel behaves as expected when handling user input.
The ViewModel has a method `proce... | codefeedback |
You are tasked with implementing a user access control system for a software application. The system should allow for the management of user roles and their corresponding permissions. Each user can be assigned one or more roles, and each role can have a set of permissions associated with it. The permissions can be used... | codefeedback |
You are tasked with implementing a function to perform a "dumb round" operation on a given floating-point number. The "dumb round" operation involves rounding the number to a certain precision and returning the result as a string. The precision for rounding is determined by the number of decimal places to which the num... | codefeedback |
You are tasked with implementing a function to validate credit card numbers using the Luhn algorithm. The Luhn algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers. The algorithm is as follows:
1. From the rightmost digit (excluding the check digit) an... | codefeedback |
You are tasked with implementing a clustering algorithm using the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) method. DBSCAN requires the determination of two key parameters: `eps` (the maximum distance between two samples for one to be considered as in the neighborhood of the other) and `minPt... | codefeedback |
You are tasked with implementing a Python class that provides data to controllers in a web application. The class should have methods for retrieving and updating data, as well as for validating the input data. The data provided by the class will be used by the controllers to respond to client requests.
Your task is to... | codefeedback |
You are tasked with creating a generic data structure that represents a binary tree. The binary tree should support operations for insertion, deletion, and searching for a given value. Additionally, you need to implement a method to determine if the binary tree is balanced.
Your binary tree should be implemented using... | codefeedback |
You are tasked with creating a custom exception class in Java to handle specific error conditions in a banking application. The exception class should be designed to handle situations where a user attempts to withdraw an amount greater than their account balance.
Your task is to create a custom exception class named ... | codefeedback |
You are tasked with implementing a task management system in Python. The system should support adding tasks to a queue, updating their status, and retrieving them based on their ID. You are provided with a partial code snippet from the system, which includes the initialization of certain data structures and the additio... | codefeedback |
You are tasked with creating a PHP function that interacts with a MongoDB database to perform CRUD operations on a collection of music bands. The provided code snippet is the beginning of a PHP function called `Edit`, which takes an `$id` parameter. Inside the function, a MongoDB client is used to connect to the `Disco... | codefeedback |
You are given a list of strings, each representing a line of code. Your task is to write a function that identifies and extracts all the comments from the code. Comments in the code are denoted by either "//" for single-line comments or "/* */" for multi-line comments. Your function should return a list of strings cont... | codefeedback |
You are tasked with simulating the growth of a population of rabbits over a certain number of generations. Each pair of rabbits produces a litter of offspring, and these offspring take a certain amount of time to mature before they can reproduce. Your goal is to calculate the total number of rabbits after a given numbe... | codefeedback |
You are tasked with creating a parameter store configuration provider for a software application. The provider should be able to load a set of parameters and allow retrieval of parameter values based on a specific format. The format for the parameter names and values is as follows:
- Parameter Name: "/start/path/{level... | codefeedback |
You are tasked with designing a permission management system for a software application. The system should allow the creation of various permissions for different modules within the application. Each permission should have a unique name and be associated with a specific module or feature.
Your task is to implement a ... | codefeedback |
You are tasked with implementing a Python function that simulates the movement of entities within a version control system repository. The provided code snippet is a part of a larger system and serves as a starting point for the problem.
Your task is to create a function `move_entity_with_history` that takes in four p... | codefeedback |
You are tasked with implementing a custom inventory management system for a retail company. The system needs to handle the setup of inventory packets, which contain information about various products. To ensure proper handling of the inventory packets, you need to create a class `InventorySetupPacket` with specific fun... | codefeedback |
You are tasked with implementing a configuration file parser for a custom configuration format. The configuration file contains lines of key-value pairs, where the key and value are separated by an equal sign (=). Additionally, comments can appear at the end of a line, denoted by a hash symbol (#), and should be ignore... | codefeedback |
You are tasked with implementing a LineGraph class in Swift that can handle multiple series of data and render them to a file. The LineGraph class should support adding series with different axis types, colors, and labels. Additionally, it should allow setting a plot title, axis labels, and line thickness. Your task is... | codefeedback |
You are tasked with implementing a Python function that handles the comparison of two JSON objects and provides debugging information in case of a mismatch. The function should take in two JSON objects, compare them, and if they are not equal, write the test JSON to a file for debugging purposes. Your task is to implem... | codefeedback |
You are tasked with creating a custom tooltip component for a data visualization library. The custom tooltip should be implemented in React using TypeScript. The tooltip component should display information about the data points on a chart and should have customizable colors based on a predefined set of colors.
You ar... | codefeedback |
You are tasked with implementing a simple routing system for a web application using Python and the Pyramid web framework. The provided code snippet is a part of the configuration for the routing system. The `simple_route` function is used to define a route for the `socket.io` service, and the `add_static_view` functio... | codefeedback |
You are tasked with creating a program that simulates a simple environment creation system. The program should take a string as input, which represents the environment to be created. The input string will consist of lowercase letters and spaces. Each lowercase letter represents a specific component of the environment, ... | codefeedback |
You are tasked with implementing a command-line tool for managing and exporting different types of plots in a data visualization library. The tool will accept commands to create figures, subplots, legends, and various types of plots, as well as export the resulting visualizations to different file formats. The commands... | codefeedback |
You are tasked with implementing a function that calculates the nth Fibonacci number using an iterative approach. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence goes: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on.
Write a fu... | codefeedback |
You are tasked with creating a file upload validation system for a web application using PHP. The system should ensure that only PDF files are allowed to be uploaded and that the file size does not exceed a specified maximum size. You are provided with a code snippet from a PHP class that sets up the configuration for ... | codefeedback |
You are given a function `fuel_required(mass)` that calculates the amount of fuel required for a given mass. The function `fuel_required` takes an integer `mass` as input and returns the amount of fuel required, which is also an integer. The fuel calculation follows a specific algorithm, and the code snippet provided b... | codefeedback |
You are working on a travel recommendation system that utilizes the Amadeus API to fetch reference data such as locations, airlines, and recommended locations. Your task is to create a Python class that interacts with the Amadeus API to retrieve and manipulate this reference data.
Define a class `AmadeusReferenceData`... | codefeedback |
You are tasked with creating a Python function that interacts with a web service to retrieve and process data from a specific endpoint. Your function should handle the HTTP request, parse the response, and extract relevant information for further processing.
Write a function `fetch_conference_data` that takes a confer... | codefeedback |
You are given a list of tuples, each containing three elements: a string representing a function name, another string representing an operation, and an integer representing a value. Your task is to write a function that processes this list and returns a dictionary containing the function names as keys and the result of... | codefeedback |
You are tasked with implementing a custom wrapper class for a binary tree node. The wrapper class should provide additional functionality to the standard binary tree node, such as tracking the number of times a node is accessed or modified. Additionally, the wrapper class should be able to work with a party class to pe... | codefeedback |
You are tasked with creating a Python program that utilizes the `aquests` library to perform asynchronous HTTP requests to multiple URLs and then processes the responses. Your program should be able to handle a large number of concurrent requests efficiently.
Write a function `fetch_urls` that takes in a list of URLs ... | codefeedback |
You are tasked with creating a program that processes a list of GitHub repositories and calculates the total number of stars for each repository within a specified range. The program should read a list of repository names and their corresponding star counts from an input file, and then output the total number of stars ... | codefeedback |
You are tasked with implementing a Python function that processes and validates a series of raw byte data representing JSON objects. The function should parse the raw byte data, validate it as a JSON object, and return a list of valid JSON objects.
You are given a code snippet that includes a test case using the `pyte... | codefeedback |
You are working on an image processing application that involves grouping bounding boxes within an image into Regions of Interest (RoIs) and creating smaller images based on these RoIs. Your task is to implement a method that reduces the size of an image based on the RoIs and saves the smaller images to a specified dir... | codefeedback |
You are tasked with creating a logging system for a mobile application using Swift. The system should utilize SwiftyBeaver for logging and CoreData for persistent storage of logs. Your task is to implement a class that encapsulates the logging functionality and provides methods for logging messages at different levels ... | codefeedback |
You are tasked with creating a custom decorator in TypeScript for validating the format of a phone number. The decorator should ensure that the phone number is in a specific format and is unique within a given context. You will need to implement the decorator function and apply it to a property of a class.
Your custom... | codefeedback |
You are working on a project to optimize a function using the Nelder-Mead algorithm. The given code snippet is a part of the optimization process. The function `minimize` is used to minimize a given function `fun` with an initial guess `x0` using the Nelder-Mead method. However, the code snippet provided is incomplete ... | codefeedback |
You are tasked with creating a function to determine whether a seat is available on an airplane. The seat arrangement is represented by a series of seat IDs, and the function should check if a specific seat is available.
You are given the following code snippet to assist you in creating the function:
```python
import... | codefeedback |
You are tasked with implementing a filtering function for a dataframe in Python. The function should filter the dataframe based on specified conditions and return the filtered dataframe.
You are given a code snippet that demonstrates the usage of the filtering function:
```python
dficts = filter.dficts_filter(dficts, ... | codefeedback |
You are tasked with creating a Python function that generates Docker image tags based on certain input parameters. The function should take in the application name, image type, version, and domain, and then construct the appropriate image tags following a specific format.
The function signature should be:
```python
de... | codefeedback |
You are tasked with creating a Python function that calculates the average of a list of numbers, excluding any negative numbers from the calculation. You should implement the function `calculate_average` which takes a list of numbers as input and returns the average of the positive numbers in the list. If the input lis... | codefeedback |
You are tasked with creating a program that processes a table of financial transactions and calculates the total amount for each category. The table is represented in HTML format and contains rows of transactions, with each row having two columns: "Category" and "Amount". Your task is to parse the HTML table, calculate... | codefeedback |
You are working on a software deployment system that automates the installation and configuration of scientific software packages. As part of this system, you need to create a Python script that generates a series of installation steps for the CCP4 and CCP-EM software packages. The script uses the `pypyr` library to de... | codefeedback |
You are tasked with implementing a system for managing event subscriptions and forwarding events between components in a distributed system. The system involves a management server (Mgm server) and a component called SimBlockCMCtrBlck, which communicates with the management server to request changes in event subscripti... | codefeedback |
You are tasked with implementing a 1D linear interpolation function in Python. Linear interpolation is a method of curve fitting using linear polynomials to construct new data points within the range of a discrete set of known data points. The function should take two arrays, `x` and `y`, representing the x and y coord... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.