instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a custom baseline function for a layout engine using the Yoga library. The Yoga library is a cross-platform layout engine that implements Flexbox layout. The baseline function is used to determine the baseline of a node in the layout, which is essential for aligning items along a common...
codefeedback
You are tasked with implementing a function that organizes a list of test cases into a hierarchical structure based on their naming convention. Each test case is represented by a string in the format "category.test", where "category" represents the broader category of the test and "test" represents the specific test ca...
codefeedback
You are tasked with creating a Python function to parse and extract information from a dictionary representing a location's properties. The dictionary contains various fields such as reference number, name, address, city, state, postcode, latitude, longitude, and phone number. Additionally, the dictionary includes a ne...
codefeedback
You are tasked with automating the installation of various software packages on a Linux system. Your goal is to create a Python script that can execute the necessary commands to install the required packages without user intervention. The script should handle both system package installations using `apt-get` and Python...
codefeedback
You are tasked with creating a program that simulates a simplified version of a package manager's dependency resolution process. Given a list of package installation commands, you need to determine the final state of the installed packages. Each package installation command consists of a series of `cd` and `npm instal...
codefeedback
You are tasked with creating a Rust function that initializes a PxFoundation class using the provided code snippet as a reference. The PxFoundation class is part of the PhysX physics engine and requires specific initialization steps. Your task is to implement a function that sets up the PxFoundation class with the nece...
codefeedback
You are given a partially implemented function in Swift that is intended to find the maximum value in a binary search tree (BST). However, the function is incomplete and needs to be fixed. Your task is to complete the implementation of the `findMaxValue` function to correctly find and return the maximum value in the gi...
codefeedback
You are tasked with implementing a function that calculates the sum of all the even Fibonacci numbers up to a given limit. 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. For example, the first few numbers in the Fibonacci sequence ...
codefeedback
You are tasked with implementing a Python class that performs word relation mapping and labeling for natural language processing tasks. The class should support the following functionalities: 1. Initialize a dictionary to store word relations. 2. Define a method to map word pairs to labels. 3. Implement a function to ...
codefeedback
You are tasked with implementing a custom URI comparator in Java. The comparator should be able to compare two URIs based on specific criteria and return the result of the comparison. Your task is to complete the implementation of the `UriComparator` interface and provide the necessary logic to compare URIs based on th...
codefeedback
You are tasked with creating a program that analyzes the frequency of words in a given text file and outputs the top N most frequent words along with their counts. Your program should ignore common stop words (e.g., "the", "and", "is") and should be case-insensitive (i.e., "The" and "the" should be considered the same ...
codefeedback
You are working as a DevOps engineer for a company that uses Kubernetes to manage its containerized applications. Your task is to create a script that automates the process of updating the container image for a specific stateful set and then monitors the rollout status to ensure the update is successful. You have been...
codefeedback
You are tasked with implementing a method to handle database queries that should return only a single item or nothing. You need to create a Python class method that executes the query and returns the result. The method should handle the case where the query returns more than one element or none at all. Your task is to ...
codefeedback
You are tasked with implementing a class to represent a curve in a graph. The class should have the following attributes and methods: Attributes: - `y1Unit`: The units of measure for the Y1-axis. It can take values from a predefined set: "A", "rad", "none", "g", "W/Hz", "V", "m2", "VA", "VArh", "N", "Pa", "VAh", "F", ...
codefeedback
You are tasked with creating a simple command-line tool to manage user accounts in a PostgreSQL database using Golang. Your tool should be able to perform the following operations: 1. Add a new user to the database. 2. Authenticate a user by checking their email and password. 3. Update a user's information. 4. Delete a...
codefeedback
You are tasked with creating a Python function that simulates a client-server interaction using ZeroMQ for communication. The client function will connect to a server and request a random number within a specified range. Your goal is to implement the client-side function that sends a request to the server and receives ...
codefeedback
You are tasked with creating a program that parses a given text file to extract and count the occurrences of words that start with a specific prefix. The program should read the text file, identify words that begin with the specified prefix, and then output the count of such words. Write a function `countWordsWithPref...
codefeedback
You are tasked with implementing a method to compare two lists of elements. The method should take into account the order of elements and allow for custom comparison logic. Your task is to complete the implementation of the `CompareLists` method, which compares two lists of elements and asserts their equality based on ...
codefeedback
You are tasked with creating a Python program that scans a given directory for files and categorizes them based on their file types. The program should utilize the `os` and `mimetypes` modules to achieve this. The program should prompt the user to input a directory path and then display a summary of the file types pres...
codefeedback
You are tasked with implementing a method to retrieve a list of rounds for a motorcycle gymkhana event. The provided code snippet is a part of a server resource class for handling requests related to gymkhana rounds. The `GetRoundsServerResource` class extends `ServerResource` and implements the `GetRoundsResource` int...
codefeedback
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific license URLs. The program should read the text file and identify the number of times a URL matching the pattern `http(s)://<domain>/licenses/<license>` appears in the file. The program should consider URLs with d...
codefeedback
You are working on a data preprocessing task for a blockchain dataset. The given code snippet is part of a larger data processing pipeline. The script is responsible for joining transaction inputs and outputs to create edges, creating unique edges, and adding timestamps to the edges. Your task is to complete the scrip...
codefeedback
You are tasked with implementing a generic heap data structure using C++ templates. The heap should support two operations: `PopHeap` and `PushHeap`. The `PopHeap` function removes the largest element from the heap, while the `PushHeap` function adds a new element to the heap. You are given the following code snippet ...
codefeedback
You are given a code snippet that simulates a stack using the C++ standard library. The stack initially contains the integer 1, and a variable `sz` is initialized to 0. The code snippet then enters a while loop that continues as long as the stack is not empty. Within the loop, the size `sz` is incremented, and the top ...
codefeedback
You are tasked with implementing a function that processes a given string and performs a specific transformation on it. The transformation involves finding and replacing all occurrences of a particular pattern within the string. The pattern to be replaced is defined as a substring enclosed within a pair of single quote...
codefeedback
You are tasked with implementing a JavaScript function that simulates a simple drawing application's rendering process. The provided code snippet is a part of the rendering logic for applying a drawing operation to a canvas. The `veilCtx` represents the rendering context of a canvas, and the `paintMode` determines whet...
codefeedback
You are tasked with implementing a custom comparison function for a struct using the Boost.Hana library in C++. The struct `SomeStruct` is defined with a single member `x` of type `int`. Your goal is to create a custom comparison function that checks if two instances of `SomeStruct` are equal based on the value of thei...
codefeedback
You are tasked with implementing a simple dependency injection framework called "Incanter." The framework allows registering hooks for specific dependencies and preparing and invoking functions with dependencies. The code snippet provided demonstrates the usage of Incanter. It registers a hook for a dependency named "...
codefeedback
You are tasked with implementing a custom database container provider for TimescaleDB, a time-series database built on top of PostgreSQL. The `TimescaleDBContainerProvider` class extends the `JdbcDatabaseContainerProvider` and is responsible for providing a containerized instance of TimescaleDB for integration testing....
codefeedback
You are tasked with creating a Java program that manipulates strings using various methods. Your program should take a string as input and perform the following operations: 1. Check if the input string is equal to "sdsad" and print the result. 2. Check if the input string is equal to "Curso de Java" and print the resul...
codefeedback
You are tasked with implementing a user management system for a database. The system involves executing SQL queries to retrieve and create user information. You are provided with a code snippet that contains two functions: `get_user_info` and `create_user`. The `get_user_info` function takes in a database connection `...
codefeedback
You are tasked with implementing a function that calculates the total number of ways to reach the top of a staircase. You can climb either 1 or 2 steps at a time. The function should take the number of steps in the staircase as input and return the total number of distinct ways to reach the top. For example, if the st...
codefeedback
You are tasked with implementing a simple dependency injection (DI) container in C#. The DI container should be able to resolve dependencies for classes with constructor injection and property injection. Your DI container should support the following features: 1. Registering types and their corresponding implementatio...
codefeedback
You are working on a project to develop a graphical user interface (GUI) for managing restraints in a molecular modeling application. The code snippet provided is a simplified representation of a class that handles the addition and deletion of restraints in the GUI. The `AddRestraint` method is responsible for adding ...
codefeedback
You are tasked with creating a program that checks the validity of file names based on a set of rules. The program should take a list of file names as input and determine whether each file name meets the specified criteria. The criteria for valid file names are as follows: 1. The file name must not contain any special...
codefeedback
You are tasked with implementing a function to detect self-intersections in a given geometry. The geometry is represented as a collection of points, and the goal is to identify any points of self-intersection within the geometry. A correct topology graph must be constructed, and the geometry must be self-noded before c...
codefeedback
You are tasked with implementing a timer management system for a smart home automation application. The system should allow users to start and cancel timers for various home devices. Each timer will be associated with a specific device and a duration. The system should support concurrent timers for different devices an...
codefeedback
You are tasked with implementing a class `TestRunner` that can execute test cases for a given function. The class should have a method `runTest` which takes a function and a list of test cases as input. Each test case is a tuple containing the input arguments for the function and the expected output. The `runTest` meth...
codefeedback
You are tasked with implementing a generic data structure called `ParallelArray` in Java. The `ParallelArray` class is designed to hold elements of a specific type and provide various operations on those elements. Your task is to implement the `all` method, which creates a new `ParallelArray` holding elements of a diff...
codefeedback
You are tasked with implementing a custom asynchronous stream filter in Rust. The filter will process items emitted by an inner stream and apply a filtering function to each item. If the filtering function returns `true`, the item should be emitted by the filter; otherwise, it should be discarded. You are provided wit...
codefeedback
You are tasked with implementing a function that performs matrix multiplication using AVX2 and AVX512 SIMD instructions. SIMD (Single Instruction, Multiple Data) instructions allow for parallel processing of data, which can significantly improve the performance of certain operations, such as matrix multiplication. You...
codefeedback
You are tasked with creating a web application that manages a list of projects for a portfolio. The application should have functionality to add, view, update, and delete projects. You are given a Laravel controller snippet for the portfolio section of the application: ```php class PortfolioController extends Controll...
codefeedback
You are tasked with creating a custom authentication mixin for a Django web application. The mixin should restrict access to certain views based on a specific user test. You will need to implement a custom mixin class that inherits from `UserPassesTestMixin` and restrict access to a particular view by overriding the `t...
codefeedback
You are tasked with designing a system for managing user acquisitions in an e-commerce platform. The system should handle the process of users making purchases, payments, and the methods used for payment. The code snippet provided is the beginning of a function to create an "AcquisitionController" that will orchestrate...
codefeedback
You are tasked with creating a Java program that manages a directory of files. The program should provide functionality to add, delete, and search for files within the directory. Additionally, it should be able to display the total size of all files in the directory. Your task is to implement the `FileDirectory` class...
codefeedback
You are tasked with implementing a class that adapts handler data to the `EmailNotificationInterface` required for email notifications processing. The `EmailNotificationInterface` is used by the email notifications processor to handle email notifications. Your task is to create a class that adapts the handler data to t...
codefeedback
You are tasked with implementing a function that interacts with a client to start a project session using the provided code snippet as a reference. The function should handle asynchronous operations and error handling. You are given the following code snippet as a reference: ```swift return try await self.client.execu...
codefeedback
You are tasked with implementing a text processing function that takes a string as input and returns the count of each unique word in the string. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters separated by spaces. The function should ignore punctuation and treat uppercase an...
codefeedback
You are tasked with implementing a simple game mechanic in Unity using C#. The game involves a player-controlled character and various game objects. One of these game objects is a power-up that, when collected by the player, grants a temporary ability. The power-up has a limited lifetime and should disappear after a ce...
codefeedback
You are tasked with implementing a function `atoi` that converts a given string to an integer. The function should handle various input cases and return the integer equivalent of the input string. The function should consider leading whitespaces, optional plus or minus sign, and invalid input cases. Your task is to im...
codefeedback
You are tasked with implementing a two-factor authentication (2FA) system using the HOTP (HMAC-based One-Time Password) algorithm. The provided code snippet is a part of a Django REST framework view that handles the POST request for verifying the OTP (One-Time Password) entered by the user. The view receives the userna...
codefeedback
You are tasked with implementing a function that constructs a directed graph representation of a computational graph. The computational graph represents the flow of data and operations in a neural network or similar computational model. The provided code snippet is a part of a larger function that recursively construct...
codefeedback
You are tasked with creating a program that processes a series of log messages and extracts specific information from them. Each log message is a string containing various pieces of information, and your program needs to extract a particular substring from each message. The log messages have the following format: ``` ...
codefeedback
You are tasked with creating a script to automate the versioning of software releases based on Git tags. The script should extract the latest version number from the Git tags and increment it for the next release. The versioning follows the semantic versioning format, which consists of three numbers separated by dots (...
codefeedback
You are tasked with creating a Python program to manage a photo-sharing server. The program should read configuration settings from a file, initiate a logging system, and then prompt the user to start the photo upload process. Additionally, the program should clear the console before proceeding with the main functional...
codefeedback
You are tasked with implementing a test case generator for a Montgomery multiplication hardware module. The Montgomery multiplication algorithm is used in cryptography and modular arithmetic to efficiently perform modular exponentiation and modular multiplication. Your task is to create a Python class that generates te...
codefeedback
You are tasked with creating a script to convert all WAV files in a specified directory to MP3 format with a quality setting of V2. The script should also display the progress of the conversion process using a progress bar. Additionally, the script should be able to suppress output when called with specific arguments. ...
codefeedback
You are tasked with creating a function that validates the consistency between a project's `package.json` file, its lockfile, and the actual presence of a package in the project's dependencies. The function should take in the project's directory path and return a boolean value indicating whether the dependencies are co...
codefeedback
You are working on a deep learning project and need to implement a logging mechanism to track the performance of your model during training. The provided code snippet is a part of the logging process and includes the following components: 1. `vutils.make_grid(im_noisy, normalize=True, scale_each=True)`: This function ...
codefeedback
You are tasked with creating a program to manage a list of tasks. Each task has a name and a status (completed or not completed). Your program should allow users to perform various operations on the task list, such as adding a new task, marking a task as completed, displaying all tasks, and removing a task. Your progr...
codefeedback
You are working for a networking company that provides solutions for monitoring network interfaces. Your task is to create a function that calculates the degradation percentage of network interfaces based on LLDP (Link Layer Discovery Protocol) information. The function `degradation_percent` takes three parameters: `to...
codefeedback
You are tasked with implementing a function to handle the creation and validation of DNS zones in a system. The function should take in a zone object and perform the necessary operations to create the zone and ensure its activation. The zone object has the following structure: ```python zone = { 'name': 'not.loade...
codefeedback
You are tasked with creating a shell script to automate the setup process for a Telegram bot on a Linux server. The script should take two command-line arguments: the Telegram bot name and the Telegram bot token. The script should perform the following tasks: 1. Set the `telegramBot` variable to the first command-line ...
codefeedback
You are tasked with implementing a simplified version of a tile request system for an image layer in a mapping application. The `ImageLayeri3d` class has a method `RequestTile` that takes a quadcode, a callback function for when the tile is ready, and a callback function for when the request fails. The quadcode is a s...
codefeedback
You are tasked with implementing a reinforcement learning algorithm to estimate the state-value function for a given environment. The state-value function represents the expected return from a given state under a specific policy. In this problem, you are required to implement the state-value function estimation using t...
codefeedback
You are tasked with implementing a cache management system that supports various cache decorators. The cache system should be able to register new decorators and apply them to the cache. Your goal is to implement the `CacheAdministator` class, which will be responsible for registering and applying decorators to the cac...
codefeedback
You are tasked with creating a custom tab navigation component for a web application. The component should render a set of tab items and allow users to switch between them. Your goal is to implement the logic for the tab navigation component and write tests to ensure its functionality. You are provided with a code sni...
codefeedback
You are tasked with implementing a simplified version of a Jasmin file generator, which is a tool used to generate Java bytecode files. The provided code snippet is a part of the JasminFileGenerator class, which is responsible for generating and writing the Jasmin file content. The class has the following member funct...
codefeedback
You are tasked with creating a Python function that processes a list of Category objects and generates a nested dictionary representing the category hierarchy. Each Category object has the following attributes: id (unique identifier), name (category name), parent_id (id of the parent category), and status (status of th...
codefeedback
You are tasked with implementing a class to manage image parameters for a mobile application. The class, named `ImageParameters`, should store and handle various attributes related to image display and layout. The provided code snippet initializes some of the attributes in the `ImageParameters` class using the `Parcel`...
codefeedback
You are tasked with implementing a serializer for a "withdraw-wallet" endpoint in a Python application using the Django REST framework. The serializer should handle the withdrawal of funds from a user's wallet. The provided code snippet includes a partial implementation of the serializer, with a missing method that nee...
codefeedback
You are tasked with creating a script to automate the deployment of a Docker container and execute specific commands within the container. Your script should handle the following requirements: 1. Pull the Docker image named $IMAGE_NAME with the tag $TAG from the repository. 2. Start a shell within the container and ex...
codefeedback
You are tasked with creating a Python program to compare the performance of two different optimization levels for a given function. The program should utilize the `timeit` module to measure the execution time of the function under different optimization levels and then calculate the percentage improvement in performanc...
codefeedback
You are a software developer working on a project that requires the use of the AMReX library for adaptive mesh refinement applications. Your task is to automate the setup and installation process of the AMReX library for both 2D and 3D dimensions. The provided code snippet is a part of the automation script that sets u...
codefeedback
You are working on a project that involves processing data from a set of HDF5 files. Each file contains a dataset with timestamps from two different sources: a camera and a lab sensor. Your task is to write a Python function that reads the dataset from a given HDF5 file and plots the timestamps from the camera and lab ...
codefeedback
You are tasked with implementing a method `get_samples` within a class. The method should take in a parameter `min_samples` and return a list of samples based on certain criteria. The class has access to a list of data points stored in an attribute `data_points`. The `get_samples` method should select a subset of data ...
codefeedback
You are tasked with creating a Python class that utilizes the `param` library to define parameters and perform operations on them. The `param` library allows for the creation of parameterized classes, where parameters can be defined with specific types, default values, and constraints. Your task is to create a class c...
codefeedback
You are tasked with implementing a reminder system for a scheduling application. The system should load reminders from a storage, initialize the reminders, and check for any downtime invites before indicating readiness. You are given a class `ReminderSystem` with the following methods: 1. `loadToCache()`: Asynchronous...
codefeedback
You are tasked with implementing a class that manages attributes and their values. The class should have methods to load attributes from a configuration, retrieve a specific attribute value, and set multiple attributes at once. You are provided with a code snippet that outlines the structure of the class and its method...
codefeedback
You are tasked with creating a custom control in a WPF application that displays a list of items and allows the user to add, remove, and reorder them. To achieve this, you need to implement a custom control called `SortableListControl` that inherits from `ItemsControl` and provides the functionality to manage the list ...
codefeedback
You are tasked with implementing a Python function that performs namespace flattening. Namespace flattening involves transforming a nested dictionary into a flattened dictionary, where the keys are concatenated with a delimiter to represent the original nested structure. For example, given the input dictionary `{'a': {...
codefeedback
You are working on a natural language processing project and need to implement a neural sequence-to-sequence translation (NSST) algorithm. The NSST algorithm takes a source sentence and translates it into a target sentence using tokenization and best transition sequence techniques. Your task is to implement the `best_t...
codefeedback
You are tasked with implementing a sliding window algorithm to process a stream of data. The algorithm should be able to handle multiple input dimensions and provide the flexibility to adjust the window size. Additionally, the algorithm should support verbose logging, monitoring of the experiment, and the option to use...
codefeedback
You are tasked with implementing a search functionality for a Django REST framework view. The view currently has a method `filter_queryset` that takes a queryset `qs` and filters it based on the search parameter provided in the request's query parameters. The search parameter is obtained from the `sSearch` key in the r...
codefeedback
You are working on a speech recognition system and need to optimize the decoding process for a specific model. The given code snippet is part of a larger script used for training and decoding with a speaker-adaptive Gaussian mixture model (SGMM2). The script performs various steps, including training the SGMM2 model, c...
codefeedback
You are tasked with implementing a Python generator function that simulates a simple experimental loop for a psychological experiment. The provided code snippet contains a part of the experimental loop, including a yield statement and a function call. Your task is to complete the implementation of the EXPERIMENT functi...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The system should allow users to create accounts, deposit and withdraw funds, and check their balance. Each account should have a unique account number, and the system should be able to handle multiple accounts. Your task is to implement a ...
codefeedback
You are working on a machine learning project and need to manipulate matrices. You have two NumPy arrays, Y and CC_2, representing data from your project. Your task is to write a function that takes these arrays as input and performs a specific matrix operation. You are given the following code snippet as a starting p...
codefeedback
You are working on a 2D game development project and need to implement a method for projecting game objects onto the screen. The provided code snippet contains a method `project` that calculates the screen coordinates and dimensions of a game object based on the camera position and depth. The method takes three paramet...
codefeedback
You are tasked with implementing a resource management system for a game development framework. The provided code snippet is a part of the initialization process for a procedural generation module. The `init_procgen` class inherits from an `initializer` class and is responsible for specifying the resources it uses and ...
codefeedback
You are tasked with creating a Python function that simulates rolling a six-sided die. Your function should return a random integer between 1 and 6, inclusive. You are not allowed to use any external libraries or modules for random number generation. Write a function `roll_die()` that accomplishes this task.
codefeedback
You are tasked with implementing a document processing module that extracts various insights from a given text document. The module should provide functions to process the document, generate a summary, identify entities, categorize the content, and determine key topics. Your goal is to write the implementation for thes...
codefeedback
You are tasked with implementing a file processing service that accepts image files and performs various operations on them. The service should be able to handle image files uploaded by users and process them according to specific requirements. You need to design a method that takes a `MultipartFile` object representin...
codefeedback
You are tasked with implementing a class hierarchy for a graphical user interface (GUI) framework. The framework provides a set of base classes and components for building GUI applications. Your goal is to design and implement the class hierarchy for the given GUI framework, ensuring proper inheritance and initializati...
codefeedback
You are tasked with creating a script to automate the deployment of a web application using Docker. Your script should pull a specific Docker image and run a container with the appropriate port mapping. Write a Python script that accomplishes the following: 1. Pulls the Docker image "konrness/konrness.com" from the Do...
codefeedback
You are given a string containing digits from 2-9. Each digit maps to a set of possible letters as shown in the following mapping: 2 -> "abc" 3 -> "def" 4 -> "ghi" 5 -> "jkl" 6 -> "mno" 7 -> "pqrs" 8 -> "tuv" 9 -> "wxyz" Write a function to return all possible letter combinations that the given string could represent...
codefeedback
You are tasked with creating a Python function that processes an image and performs a specific operation on it. The function should take an input image and perform the following steps: 1. Read the input image using the `imageio` library. 2. Extract the first channel of the image and save it as a new grayscale image us...
codefeedback
You are tasked with creating a Python function that interacts with a remote server using the SMB protocol to retrieve a list of shared resources. The function should take in the target server's IP address, a server name, and a timeout value as input parameters. The function should then establish a connection to the ser...
codefeedback
You are tasked with implementing a function that inserts a parameter value into a job run data stored in a Redis database. The function should take a Redis connection, job ID, parameter key, and parameter value as input and update the job run data with the new parameter value. The job run data is stored in a Redis has...
codefeedback
You are tasked with implementing a lazy evaluation method for exporting a facility object in C++. A facility object is a design pattern used to encapsulate the creation and management of a particular set of related objects. In this scenario, the facility object represents a service driver for a specific technology int...
codefeedback