instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a performance testing framework for a mobile application. The application is built using XCTest, a testing framework for Swift and Objective-C. Your goal is to measure the time it takes to launch the application and ensure that it meets the performance requirements. You need to write a fu...
codefeedback
You are tasked with implementing a circular buffer for storing observations, actions, rewards, and next observations in a reinforcement learning environment. The circular buffer should have a fixed capacity and should overwrite the oldest entries when it reaches capacity. The provided code snippet is a part of the `add...
codefeedback
You are given a Python code snippet that seems to be related to object detection and manipulation. Your task is to analyze the code and identify the potential issues or improvements that can be made to enhance its functionality. Identify and describe the potential issues or improvements in the given code snippet. Prov...
codefeedback
You are tasked with implementing a generic class that represents a message send topology convention for routing keys. The class should be able to handle different types of routing keys and provide a way to define the topology convention for sending messages based on these keys. Your task is to complete the implementat...
codefeedback
You are tasked with implementing a binary tree iterator in Rust. The binary tree is represented using a custom data structure, and the iterator should traverse the tree in a specific manner. The provided code snippet is a part of the iterator implementation and demonstrates the handling of the `Push` action. Your task...
codefeedback
You are tasked with creating a program to generate a maze using a given set of parameters. The maze is represented as a 2D grid, where each cell can be either a wall or an open space. The maze is generated using the following steps: 1. Determine the size of the maze grid, where `mw` represents the width and `mh` repre...
codefeedback
You are tasked with creating a validation function for a data structure that represents a rating. The data structure is defined using a library called `zod`, which provides a way to define and validate data schemas in TypeScript. The given code snippet shows a part of the data structure definition using `zod`. It incl...
codefeedback
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read the contents of the file, tokenize the words, and then count the frequency of each word. However, the program should exclude any words that are found in a given set of stop words. Stop words are co...
codefeedback
You are tasked with implementing a function that converts a given input into a specific data type based on the provided type. The function should handle three different types: `Color`, `Vec4`, and `Int`. The input will be a string representation of the data, and the function should return the corresponding data type ba...
codefeedback
You are tasked with creating a Python script to manage the launching of a ZMQ Connector with MPI. The script should be able to handle different configurations for running the connector on multiple cores, receiving data from a specified port, and performing various stages of processing. Your script should accept the fo...
codefeedback
You are tasked with implementing a Python function that converts polar coordinates to Cartesian coordinates. The function should take in the polar coordinates and the points in the mesh, and return the corresponding Cartesian coordinates. You are given the following information: A class `PolarConverter` has a method `...
codefeedback
You are tasked with creating a Python program to process and analyze data related to a family tree. The input data is provided in JSON format and contains information about individuals and their relationships. Your program should be able to extract specific details from the input data and perform various operations bas...
codefeedback
You are tasked with implementing a program to calculate statistics related to metatiles and states in a game. A metatile is a collection of smaller tiles, and each metatile can have a variable number of states. Your task is to calculate the total number of metatiles, the total number of states, the maximum number of st...
codefeedback
You are tasked with simulating the behavior of a simplified email client application. The application has a mailbox screen that displays a list of emails, and it uses threading to populate the mailbox screen with email headers. The code snippet provided is a part of the application's logic for populating the mailbox sc...
codefeedback
You are tasked with implementing a custom shell feature that expands special tilde (~) expressions to their corresponding directory paths. The tilde expressions are as follows: - `~` expands to the user's home directory, denoted by `$HOME`. - `~username` expands to the home directory of the specified user. - `~+` expan...
codefeedback
You are tasked with creating a TypeScript declaration file for a library called Evora, which is a wrapper for FusionCharts. The provided code snippet is a starting point for the declaration file, but it needs to be completed to ensure proper type definitions for the Evora library. Your task is to extend the provided c...
codefeedback
You are tasked with implementing a data structure to efficiently manage resource configuration values based on their density. The resource configuration values are represented by the `ResourceConfigValue` class, which contains a `config` field representing the configuration and a `density` field indicating the density ...
codefeedback
You are tasked with implementing a class that processes geographical coordinates and absolute coordinates and notifies a listener when the processing is completed. The provided code snippet is a part of the implementation of this class. Your task is to complete the implementation of the class and handle the processing ...
codefeedback
You are tasked with creating a shell script that processes the `/etc/passwd` file to extract and manipulate user information. The script should perform the following steps: 1. Remove any lines starting with `#` from the `/etc/passwd` file. 2. Extract every other line from the remaining content. 3. Split each line using...
codefeedback
You are tasked with implementing a Python class that represents a game tree node and provides a method to list the nodes reachable in one step from the current node. The game tree represents the possible states of a game and the possible moves from each state. Your task is to complete the implementation of the `GameTr...
codefeedback
You are working on a web development project and need to create a function to generate HTML anchor tags with various attributes. The function should take in an array of options and output the corresponding anchor tag. Each option in the array represents a different attribute of the anchor tag. You are given the follow...
codefeedback
You are tasked with implementing a function that performs a restricted edit distance check on two input sequences. The function should raise a ValueError if the edit distance between the sequences exceeds a specified threshold, and return the new sequence along with the calculated edit distance if the check passes. Yo...
codefeedback
You are tasked with creating a Python function that extracts the author's name and email from a given string in the format `author="<NAME>", author_email="<EMAIL>"`. The function should take a single string as input and return a dictionary containing the extracted name and email. Create a function called `extract_auth...
codefeedback
You are tasked with creating a PHP class that interacts with the Intelepeer API to send SMS messages. The IntelepeerConnector class provided in the code snippet is a wrapper for the Intelepeer API and is responsible for handling the communication with the API endpoints. Your task is to implement a method within the In...
codefeedback
You are working on a financial modeling application that involves simulating asset returns using a multivariate normal distribution. To achieve this, you need to generate random samples from a multivariate normal distribution given the mean vector and the covariance matrix. You decide to use the Cholesky decomposition ...
codefeedback
You are tasked with implementing a function to parse and extract information from an OpenAPI document. The OpenAPI document is represented in Rust using the given code snippet as a starting point. Your task is to write a function that takes the OpenAPI document as input and returns specific information from it. You ar...
codefeedback
You are tasked with implementing a module resolution algorithm for a JavaScript/TypeScript project. The project uses the `export * from` syntax to re-export components from one module to another. Your goal is to write a function that resolves the final set of exported components given a starting module. You are given ...
codefeedback
You are working on a data engineering project using dbt (data build tool) and Apache Spark. Your task is to write a dbt test that ensures the correct configuration for seeding data into the Spark environment. The project has different configurations for Spark v2.0 and v3.0, and you need to create a test that runs on bo...
codefeedback
You are tasked with creating a Python function that validates and updates a user's password based on certain criteria. The function should take in the user's input password and ensure it meets the following requirements: 1. The password must be at least 8 characters long. 2. The password must contain at least one upper...
codefeedback
You are tasked with creating a Bash script that retrieves information about GitHub repositories and displays the top repositories based on the number of stars they have. The script should utilize the GitHub API to fetch the data and then process it to present the desired output. Your task is to complete the Bash scrip...
codefeedback
You are tasked with implementing a class that manages a collection of public methods. The class should allow adding, removing, and executing these methods. Each method should take no arguments and return a string. The class should also provide a method to execute all the public methods and return a list of their return...
codefeedback
You are tasked with creating a Dockerfile for a web application that serves a simple PHP page. The PHP page should display the build information and the PHP version. Your task is to complete the Dockerfile by adding the necessary commands to achieve this functionality. The Dockerfile provided below sets up an Apache s...
codefeedback
You are tasked with creating a script to automate the process of uploading code coverage reports to Codecov. Codecov is a tool used to measure code coverage and track code quality over time. The provided code snippet sets an environment variable `CODECOV_TOKEN` with the value passed as an argument and then executes a b...
codefeedback
You are working as a DevOps engineer for a software company. Your team is responsible for managing and deploying various microservices using Docker containers. As part of your daily tasks, you need to monitor the running Docker containers and ensure that they are functioning as expected. One of the essential commands f...
codefeedback
You are given a string containing a title of a book, article, or any other literary work. The title may contain letters, digits, punctuation marks, and spaces. Your task is to write a function that takes the title as input and returns a formatted version of the title with the following rules: - The first letter of each...
codefeedback
You are tasked with implementing a Battleship game board validator. The game board is represented as a 2D grid of characters, where 'O' represents an empty space and 'X' represents a part of a battleship. Battleships can only be placed horizontally or vertically, meaning they can only be made of the shape 1xN (1 row, N...
codefeedback
You are tasked with implementing a function to parse and process an ELF (Executable and Linkable Format) file. The ELF file format is commonly used for executables, object code, shared libraries, and core dumps in Unix and Unix-like systems. Your task is to write a function that extracts and returns the section names a...
codefeedback
You are tasked with creating a function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take two parameters, `start` and `end`, representing the inclusive range within which to...
codefeedback
You are tasked with implementing a custom React component called `FetchHandler` that handles the display of data fetched from an API. The component should handle loading states, errors, and the rendering of the fetched data. The component should accept the following props: - `data`: The fetched data of type `T`. - `isL...
codefeedback
You are tasked with implementing a function to parse and extract information from a given code snippet. The code snippet provided is written in C# and involves the use of the `extern` keyword and the `Il2CppTypeDefinitionSizes` structure. Your task is to write a function that can extract the name, size, and type inform...
codefeedback
You are tasked with implementing a distance calculation algorithm for finding the shortest distance between a 3D point and a 3D rectangle. The rectangle is defined by its center, axis directions, and extents along each axis. Your goal is to write a function that takes a 3D point and the rectangle parameters as input an...
codefeedback
You are tasked with implementing a C++ class that manages the creation and destruction of node collectors for a simulation software. The provided code snippet outlines the declaration of a class `HyperworksNodeCollectorFactory` that inherits from `CollectorFactory`. Your task is to complete the implementation of this c...
codefeedback
You are given a list of 3D geometric shapes represented as strings. Each string represents the name of a 3D shape. Your task is to write a function that counts the occurrences of each unique shape in the list and returns the count for each shape. Create a function `countShapes(shapes: List[str]) -> Dict[str, int]` whe...
codefeedback
You are tasked with implementing a function that adds a configuration group to a database. The function should handle potential errors related to the input name and database operations. You are given the following code snippet as a reference: ```swift func addEmptyConfigGroup(_ name: String) throws { let trimmedN...
codefeedback
You are tasked with creating a Python script that extracts metadata from a given setup.py file and generates a dictionary containing the extracted information. The setup.py file follows the standard format for defining Python package metadata. Your task is to write a function `extract_metadata` that takes the file pat...
codefeedback
You are tasked with implementing a C++ class that manages transformations between different coordinate frames in a robotics simulation environment. The class should handle exceptions related to frame transformations and provide a plugin-specific interface for the implementation of the frame transformation logic. Your ...
codefeedback
You are tasked with implementing a custom data structure called `CustomStack` that simulates the behavior of a stack with an additional operation. The `CustomStack` supports the following operations: 1. `push(x)`: Add an integer `x` to the top of the stack. 2. `pop()`: Remove the top element of the stack and return its...
codefeedback
You are tasked with creating a script to automate the setup of user roles and permissions in a MongoDB database. Your script should generate the necessary commands to create a user with specific roles and permissions for a given database. You are provided with a code snippet that sets up a user with read access to the...
codefeedback
You are tasked with creating a Python function that processes regular expressions and produces a dictionary of named capture groups and their corresponding values. The function should take in a list of regular expressions and their associated conversion functions, and then apply these regular expressions to a given inp...
codefeedback
You are tasked with implementing a Python class that wraps the functionality of the GPy library for multi-output Gaussian process regression. The GPy library is commonly used for Gaussian process modeling and provides a high-level interface for building and fitting Gaussian process models. Your task is to complete the ...
codefeedback
You are tasked with implementing a program to analyze a sequence of integers and identify contiguous blocks of numbers that have a consistent stride. A consistent stride is defined as the difference between consecutive numbers within a block being the same. For example, the sequence [1, 3, 5, 7] has a consistent stride...
codefeedback
You are tasked with creating a Python function to process COVID-19 data for the Kreis Warendorf region. The function should retrieve the latest COVID-19 statistics from a given JSON endpoint, extract relevant information, and calculate the changes in confirmed cases, recoveries, and deaths between the two most recent d...
codefeedback
You are tasked with implementing a data validation system for a configuration model in a Python application. The `Config` class is a model representing configuration settings, and it contains fields for `label`, `key`, `value`, and `status`. The `label` field is a string representing the label of the configuration sett...
codefeedback
You are tasked with implementing a text encoding function that supports both Unix-based and Windows-based systems. The function should take a string as input and return the encoded representation of the text based on the underlying operating system. For Unix-based systems, the encoding should be done using UTF-8, while...
codefeedback
You are tasked with implementing a custom element-wise transpose function for a given input array using the DPC++ programming model. The DPC++ code snippet provided below demonstrates the usage of DPC++ library functions and templates for element-wise transpose operation. Your task is to create a DPC++ kernel that perf...
codefeedback
You are tasked with implementing a function that manipulates a list based on a series of randomly generated values and function calls. The list starts empty, and the function will receive a list of test functions to choose from. Each test function takes the current list, the new value, and the current position as input...
codefeedback
You are tasked with implementing a custom string manipulation class in C++. The class, named `CustomString`, should have the following functionalities: 1. `insert(int pos, const std::string& str)`: This method should insert the given string `str` at the specified position `pos` in the current string. 2. `print()`: Th...
codefeedback
You are tasked with implementing a function that calculates the hash of a given input string using the SHA-256 hashing algorithm. The SHA-256 algorithm produces a 256-bit (32-byte) hash value. Your task is to write a function that takes a string as input and returns its SHA-256 hash in hexadecimal format. You are prov...
codefeedback
You are tasked with implementing a Swift property that manages the display of error messages in a view controller. The property should return an error message if one is present, or `nil` if there is no error. Additionally, you need to create a computed property that determines whether a loading indicator should be disp...
codefeedback
You are tasked with creating a function to parse and extract specific components from an HTML template used in a content management system (CMS) for a gallery module. The function should extract and return the intro content and paging links from the HTML template based on predefined patterns. You are given the followi...
codefeedback
You are tasked with creating a function that validates user sign-up information for a new application. The function should take in a struct containing user sign-up details and then construct an API request to register the user on the backend server. The provided code snippet is a part of the existing codebase and inclu...
codefeedback
You are tasked with creating a custom sensor for a home automation system using the Home Assistant framework. The sensor will retrieve and display data related to air quality. You need to implement a custom sensor class that inherits from `SensorEntity` and `CoordinatorEntity` and provides the necessary functionality t...
codefeedback
You are tasked with implementing a custom exception class and handling various exception scenarios in a Java application. The custom exception class, `HessianFieldException`, is used to represent errors related to field assignments in a Hessian serialization framework. Your goal is to create a method that handles excep...
codefeedback
You are tasked with creating a script to automate the process of executing commands within a Docker container. Your script should take the name of the Docker container as input and then execute a specified command within that container. You need to ensure that the script handles potential errors and provides appropriat...
codefeedback
You are tasked with creating a custom validation rule for a PHP application using the Phalcon framework. The goal is to implement a custom validator that checks if a given URL is accessible and returns a valid HTTP status code. Your task is to create a custom Phalcon validator class that extends the `Phalcon\Validatio...
codefeedback
You are tasked with creating a Rust program that generates unique file names using UUIDs. Your program should implement a function that takes a file extension as input and returns a new file name in the format "uuid.extension". Additionally, you need to write a unit test to verify the correctness of the function. Your...
codefeedback
You are tasked with implementing a function that validates a JSON object based on a given schema. The schema is represented as a JSON object itself, and the validation function should ensure that the input JSON object conforms to the structure defined by the schema. Your task is to implement the `validateJSON` functio...
codefeedback
You are tasked with implementing a Python class that simulates a simple board game. The game board is represented by a 2D grid of cells, and each cell can be in one of two states: alive or dead. The game follows the rules of Conway's Game of Life, a cellular automaton devised by the British mathematician John Horton Co...
codefeedback
You are tasked with implementing a custom data structure in Swift that mimics the behavior of a stack but also keeps track of the minimum element in the stack. You need to create a class `MinStack` with the following functionalities: 1. `push(val: Int)`: Add an element to the stack. 2. `pop()`: Remove the top element f...
codefeedback
You are tasked with creating a Python class that manages a messaging system for a marketing campaign. The class should handle the sending of messages to a list of recipients and keep track of the campaign's performance. Create a Python class named `CampaignManager` with the following specifications: - The class should...
codefeedback
You are tasked with implementing a text editor feature that supports the Russian language. The editor should handle the input of Russian characters and apply specific formatting rules based on the characters entered. Your task is to create a function that processes the input of Russian characters and applies the necess...
codefeedback
You are given a series of tuples, each representing a mapping between an integer key and a tuple value. The tuple value consists of a sequence of integers, a boolean value, an integer, and another integer. The sequence of integers represents a pattern, the boolean value indicates whether the pattern is valid, the first...
codefeedback
You are working on a physics simulation environment for a robotic arm. The environment has a class with a method to get the current state of the system and another method to set the state of the system. The state consists of the positions, velocities, control inputs, and actions of the robotic arm. The class has the f...
codefeedback
You are tasked with creating a Python function that determines whether a given URL is valid for a specific streaming service. The streaming service in question is Live Russia TV, and the function should be able to identify valid URLs for this service based on a specific pattern. Write a function called `is_valid_live_...
codefeedback
You are tasked with creating a program that analyzes the license information of a given software package. The license information is provided as a multi-line string, and your program needs to extract specific details from it. The license information follows a specific format: - The license is under the Apache License,...
codefeedback
You are tasked with creating a Python function that processes and prepares data for a natural language processing (NLP) task. The function should take in various parameters and perform specific operations based on the input. Your task is to complete the implementation of the `get_data` function according to the given r...
codefeedback
You are tasked with creating a program that analyzes a given Rust source code file to determine if it contains a `main` function. If the `main` function is present, the program should execute it using Just-In-Time (JIT) compilation and print the exit code. If the `main` function is not found, the program should log a m...
codefeedback
You are tasked with implementing a function to initialize weights for a neural network layer. The function should handle both elementwise and non-elementwise initialization. For non-elementwise initialization, the weights should be split into two parts, with one part initialized using a specified method and the other p...
codefeedback
You are tasked with creating a Python function that retrieves the UUID (Universally Unique Identifier) of a Minecraft user at a specific point in time. The function should take the username of the Minecraft player and an optional timestamp as input and return the UUID associated with the username at that time. You are...
codefeedback
You are working on a project that involves parsing and processing data from a large dataset stored in a gzip-compressed file. The dataset contains product metadata in a specific format, and you need to extract and manipulate this data for further analysis. The metadata is structured using a custom data type defined in ...
codefeedback
You are tasked with implementing a Python function that extracts the names of all the modules and classes from a given code snippet. The code snippet will consist of import statements and a list of exported items. Your function should parse the code and return a list of the imported modules and classes. Write a functi...
codefeedback
You are tasked with implementing a function to calculate the area of a polygon given its vertices. The vertices are represented as a list of tuples, where each tuple contains the x and y coordinates of a vertex. The area of a polygon can be calculated using the formula for the shoelace algorithm, which involves summing...
codefeedback
You are given a chocolate bar that is represented by an array of integers, where each integer represents the number of squares of chocolate in a segment. Ron's birthday is in month m, and the sum of the integers on the squares must equal his birth day, represented by d. You need to determine how many ways the chocolate...
codefeedback
You are tasked with implementing a Vector2 class in Python that supports basic arithmetic operations. The class should represent a 2D vector and provide methods for addition, subtraction, multiplication, and division with other vectors or scalar values. Additionally, the class should support the right division operatio...
codefeedback
You are tasked with creating a Python decorator that performs input validation for a web application. The decorator should ensure that the specified UUIDs are present in the request parameters and that the corresponding users exist in the system. Additionally, you need to implement three routes for the web application:...
codefeedback
You are given a snippet of SVG (Scalable Vector Graphics) code that defines various linear gradients and a clip path. Your task is to write a program that parses this SVG code and extracts the information about the linear gradients and the clip path. Your program should extract the following information: 1. The IDs of...
codefeedback
You are working on a project that involves managing files in a Linux environment using the Bash shell. Your task is to write a Bash script that will move all files from a specified source directory to a target directory, while avoiding overwriting any existing files in the target directory. The script should be designe...
codefeedback
You are tasked with creating a PHP class method that generates an HTML form for listing keys in a Redis database. The method should take a Redis object as a parameter and return the HTML form as a string. The form should include a list of keys matching a specified pattern and display the total count of keys in the data...
codefeedback
You are given a list of stock prices, where each element represents the price of a given stock on a particular day. Your task is to write a function `max_profit_twice(prices: List[float]) -> float` that calculates the maximum profit that can be obtained by buying and selling a stock at most twice. For example, given ...
codefeedback
You are tasked with implementing a Python class for dynamic scaling functions used in a scientific computing library. The class should handle the calculation of dynamic scaling functions for vertices and susceptibility in a graph. Your task is to complete the implementation of the `DynScalingFunc` class by adding the ...
codefeedback
You are working on a signal processing library and need to implement a function to reparameterize a given real discrete Fourier transform (RDFT) matrix. The function `reparam(rdft)` takes the RDFT matrix `rdft` as input and performs the reparameterization based on certain conditions. The reparameterization involves app...
codefeedback
You are tasked with implementing a Python package that provides a custom data structure for efficiently storing and retrieving key-value pairs. The package should include a class `CustomDict` that supports the following operations: 1. `__init__(self)`: Initializes an empty custom dictionary. 2. `__setitem__(self, key, ...
codefeedback
You are tasked with implementing a simple calculator program that can perform basic arithmetic operations and also include a custom "hello world" operation. The calculator should support addition, subtraction, multiplication, division, and the custom "hello world" operation. The "hello world" operation should simply pr...
codefeedback
You are tasked with creating a Python function that processes a given input string to extract and modify the favorite color mentioned in the input. The function should take a string as input and return a modified string with the favorite color capitalized and appended with "IS A NICE COLOR." if it is a single color, or...
codefeedback
You are tasked with implementing a function to format an outline tree structure and compare it with an expected tree structure. The outline tree is represented as a nested object, where each key represents a node and its value is an array of child nodes. The formatting function should transform the outline tree into a ...
codefeedback
You are tasked with implementing a function that calculates the total padding value used in a given makeStyles object from the Material-UI library in JavaScript. The makeStyles object contains style definitions for different components, and the padding values need to be summed up to determine the total padding used. Y...
codefeedback
You are tasked with implementing a C++ class that represents a set of unique objects. The class should provide methods for adding objects, removing objects, and checking if a specific object is present in the set. Additionally, the class should support iterating through the objects in the set. Your task is to complete...
codefeedback
You are tasked with implementing a method to retrieve information about a class method and its superclass in a Java program. The method should take in the method name and description as input and return whether the method is an initialization method, along with the name of the superclass. You are given the following c...
codefeedback
You are given a list of energy values representing the energy levels of a device at different time intervals. The device starts with an initial energy level of 0. Each energy value in the list represents the change in energy level at that time interval. Positive values indicate an increase in energy, while negative val...
codefeedback
You are tasked with creating a program that reads a file named "input" and processes its contents to count the occurrences of specific patterns. The file contains lines of text, each consisting of two parts separated by a colon. The first part is a string, and the second part is a number. Your program needs to count th...
codefeedback