instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function to handle the encoding of a dictionary containing Unicode characters and then making a POST request using the encoded data. Your function should take the dictionary as input, encode it using UTF-8, and then send a POST request to a specified endpoint with the encoded data. Yo...
codefeedback
You are tasked with implementing a function that takes a string as input and returns the reverse of the string, while preserving the position of non-alphabetic characters. For example, if the input string is "hello!world", the output should be "dlrow!olleh". Your task is to implement the function `reverseStringWithNon...
codefeedback
You are tasked with implementing a memory management system for a genetic algorithm. The genetic algorithm operates on a collection of datasets, each containing a set of numbers. The memory management system is responsible for storing and retrieving these datasets efficiently. The provided code snippet is a part of the...
codefeedback
You are tasked with creating a program that simulates a file system and performs file operations. Your task is to implement a class that represents a simplified file system and provides methods for copying files and finding a specific command. You are given a code snippet that demonstrates the usage of the file system...
codefeedback
You are tasked with creating a function that takes an integer as input and returns its negative value if it is positive, and returns the input value as is if it is already negative or zero. Your task is to implement the `make_negative` function to achieve this behavior. Create a function `make_negative` that takes an ...
codefeedback
You are tasked with implementing a custom reusable view in a Swift iOS application. The view will be used to display a list of items in a collection view. Your goal is to create a custom reusable cell that can be registered and dequeued in the collection view. You are provided with the following code snippet as a star...
codefeedback
You are tasked with implementing a class for managing sleep events in a resource management system. The class `SleepStartEvent` represents an event where a resource goes into a sleep state for a specified duration. The constructor of the `SleepStartEvent` class takes four parameters: `resourceId` (the ID of the resourc...
codefeedback
You are tasked with implementing a function to calculate the final position of a joint in a physics simulation. The function should account for different physics engines and handle non-zero initial values. You are given a code snippet that includes a function call to `EXPECT_NEAR(initialPosition, initialResultPosition...
codefeedback
You are tasked with creating a custom tag helper in an ASP.NET Core web application. Tag helpers are a feature in ASP.NET Core that enables server-side code to participate in creating and rendering HTML elements in Razor files. In this problem, you will create a custom tag helper to generate a custom HTML element based...
codefeedback
You are tasked with implementing a custom blockchain consensus algorithm for a new cryptocurrency. The consensus algorithm will be a proof-of-work (PoW) system, where miners compete to solve complex mathematical puzzles to add new blocks to the blockchain. Your task is to create a PoW block import module that integrate...
codefeedback
You are tasked with implementing a function that simulates a simple text-based adventure game. The game will involve navigating through different rooms, interacting with objects, and making decisions that affect the outcome of the game. You are provided with a basic structure for the game, including a Room struct and ...
codefeedback
You are working for a financial investment firm that uses quantitative models to make investment decisions. Your task is to create a program that calculates the volatility of investment views based on given signals and leverages. The program should also handle absolute signals only. You are given a code snippet that i...
codefeedback
You are tasked with creating a Python class that handles key-value pairs in a string format. The class should provide methods to parse a string into key-value pairs and to convert key-value pairs into a string. Additionally, the class should be able to handle nested key-value pairs within the string. Your task is to i...
codefeedback
You are tasked with creating a Python function that processes a dictionary containing data on the number of joins by day. The function should calculate the average number of joins for each day of the week and return a new dictionary with the average values. The input dictionary, `JBD`, contains keys representing the d...
codefeedback
You are tasked with implementing a function that processes a given field of study and returns a modified version of it. The input field of study may contain special characters, and the function should remove any leading or trailing whitespace and convert the field of study to lowercase. Additionally, if the input field...
codefeedback
You are tasked with creating a Python program that simulates a simplified version of a build system for a software project. The build system is responsible for compiling and linking various components of the project. Your program should handle the dependencies between different components and ensure that they are built...
codefeedback
You are tasked with creating a function that retrieves character information for a specific user and world from a database and then announces the details on a designated log channel. The function should take the user's member ID and the world as input parameters. The database contains a table named "character" with col...
codefeedback
You are tasked with creating a shell script to automate the build process for a software project. The script should handle various options and generate a JAR file for the project. Your task is to complete the shell script by implementing the missing parts based on the given code snippet and requirements. The script sh...
codefeedback
You are tasked with implementing a function to calculate the zonal mean dataset from an input xarray dataset containing full fields of basic state variables such as velocity components and temperatures. The zonal mean dataset should include as many zonal mean diagnostics as possible. The function signature is as follo...
codefeedback
You are tasked with implementing a region registration system for a virtual environment. The environment consists of scenes, each of which can contain multiple regions. Each region can be associated with a grid for spatial organization. Your task is to create a class that manages the registration of regions and their a...
codefeedback
You are tasked with implementing a Python function that processes SNMP (Simple Network Management Protocol) MIB (Management Information Base) data. The given code snippet is a part of an SNMP agent implementation using the PySNMP library. The code snippet imports symbols from the 'SNMP-TARGET-MIB' module and initialize...
codefeedback
You are tasked with implementing a class that manages environment variables for a system. The class should provide methods to set, get, and delete environment variables, as well as a method to generate a string representation of the environment variables in the format required by a specific application. You are provid...
codefeedback
You are working on a computer vision project and need to preprocess images before feeding them into a neural network for classification. The preprocessing steps involve undoing a specific transformation and then clipping the pixel values to a certain range. You are given an image represented as a NumPy array with shap...
codefeedback
You are working on an e-commerce platform that tracks various user actions. The platform uses constants to represent different types of user actions. Each action has a specific description associated with it. Your task is to implement a function that takes an action constant as input and returns its corresponding descr...
codefeedback
You are tasked with implementing a class that represents a geometric shape. The class should have an abstract property `area` that represents the area of the shape. When this property is accessed without being implemented in a subclass, it should raise a fatal error indicating that the property is abstract and needs to...
codefeedback
You are tasked with implementing a simple data processing pipeline using the Combine framework in Swift. The pipeline will involve fetching data from a remote server, parsing it, and then performing some operations on the parsed data. You are provided with a `DataFetcher` class that has a method `fetchData` to retriev...
codefeedback
You are tasked with implementing a function to calculate the false discovery rate (FDR) ranking for a given set of p-values. The FDR is a method used in multiple hypothesis testing to account for the expected proportion of false positives among the rejected hypotheses. The FDR ranking is a way to prioritize the signifi...
codefeedback
You are given a list of items, and you are required to rank the items based on their frequency of occurrence in the list. Your task is to write a function that takes the list of items as input and returns a dictionary where the keys are the unique items from the input list, and the values are their respective ranks bas...
codefeedback
You are tasked with implementing a Python function that performs a specific transformation on a given input. The function should take a nested data structure as input and convert all its elements to a specified device, while also allowing for non-blocking operations. The function should handle various data types and ne...
codefeedback
You are working on a Python project that involves importing various modules and classes from a package. The code snippet provided shows a series of imports from different modules within the package. Your task is to create a function that dynamically imports and initializes the classes based on a given list of class nam...
codefeedback
You are tasked with creating a custom cross-validation class for gridding geospatial data using splines. The class should extend the `BaseGridder` class from the `verde` library and implement cross-validation functionality using the `cross_val_score` function. The goal is to create a custom cross-validation class that ...
codefeedback
You are working on a network management system that interacts with network devices using NETCONF (Network Configuration Protocol). The system uses a Python-based framework with a custom decorator `@Action.action` to define actions that can be executed on the network devices. One such action is `cb_action`, which contin...
codefeedback
You are tasked with creating a Python function that performs coordinate transformation using the `osr` library. The function should take as input the EPSG (European Petroleum Survey Group) codes for the input and output spatial references, and a set of coordinates in the form of a tuple (x, y). The function should then...
codefeedback
You are tasked with creating a Python unit test to verify the functionality of a code analysis tool. The code snippet provided imports several modules from the `vivisect` library, which is used for analyzing and reverse engineering binary files. Your goal is to write a unit test that checks the behavior of a specific f...
codefeedback
You are given a list of integers representing the heights of a series of buildings. Your task is to write a function that calculates the total amount of rainwater that can be trapped between the buildings. The height of each building is represented by a non-negative integer. The width of each building is 1 unit. For e...
codefeedback
You are tasked with implementing a class that manages inequalities matrices and provides methods for manipulation and analysis. An inequalities matrix is a square matrix where each element represents the relationship between two variables. For example, if element (i, j) is set to 1, it indicates that variable i is grea...
codefeedback
You are given a Python script that processes a directory of CSV files and calculates the average number of lines in each file based on a specific pattern in the file names. Your task is to understand the given code snippet and implement a function to achieve the same result. You need to write a Python function `calcul...
codefeedback
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry. The account information should be stored in a dictionary with the account number as the key and the acc...
codefeedback
You are working on a project to simulate the behavior of biological cell membranes. The given code snippet contains method signatures for creating and generating cell membrane components. Your task is to implement a class that utilizes these methods to create a cell membrane structure based on the provided specificatio...
codefeedback
You are tasked with implementing a function that performs a specific type of data conversion. The function takes in a byte array representing a sequence of data and converts it into a numerical value based on the specified endianness. Endianness refers to the order in which bytes are stored in memory. For little-endian...
codefeedback
You are tasked with implementing a Python function that performs a specific type of decompression on a given input data. The function should take the input data and produce the decompressed output in a specific format. Your task is to complete the implementation of the `cbfdecompress` function according to the provided...
codefeedback
You are tasked with implementing a Python class that manages a collection of trigger registers for an Event Receiver Version 2 (EvrV2) device. The code snippet provided is a part of the class constructor that adds a specified number of trigger registers to the collection. Your task is to complete the implementation of...
codefeedback
You are tasked with creating a PHP function that processes an array of transaction data and returns a modified version of the array with specific transformations applied. The transaction data is represented as an array of associative arrays, where each inner array contains information about a single transaction. The t...
codefeedback
You are tasked with implementing a function that checks whether a given HTML string contains a valid Bootstrap navbar component. A valid Bootstrap navbar component should consist of a `<nav>` element with the class "navbar", a `<button>` element with the class "navbar-toggler", and a `<div>` element with the classes "c...
codefeedback
You are tasked with creating a program that analyzes the structure of HTML code to identify the number of nested elements within a given HTML snippet. The program should count the levels of nesting for each HTML tag and output the maximum nesting level found. Write a function `maxNestingLevel(html)` that takes a strin...
codefeedback
You are tasked with implementing a Python function that takes a dictionary and converts it to a JSON string. The function should also handle cases where the dictionary contains non-serializable data types. You should ensure that the function returns a JSON string with the non-serializable data types replaced by their s...
codefeedback
You are tasked with implementing a simple command-line utility for executing external commands and capturing their output. Your program should allow users to specify a command to run and then display the command's output to the console. Additionally, the program should capture the exit code of the command and print it ...
codefeedback
You are given a string containing a series of words and numbers, but some of the characters are misspelled or incorrectly formatted. Your task is to clean up the string by correcting the misspelled words and removing any unnecessary characters. Specifically, you need to correct the misspelled words and remove any backs...
codefeedback
You are tasked with implementing a program to simulate reading and writing data to a disk. The program should perform random writes to a file and then read the written data back from the file. The goal is to measure the time taken for these operations and analyze the performance of the disk I/O. Your task is to write ...
codefeedback
You are tasked with creating a Python script to automate the generation of SSL/TLS certificates for a secure communication setup. The script should utilize the `openssl` command-line tool to generate a root certificate authority (CA), a server certificate, and a client certificate. The script should also handle the sig...
codefeedback
You are tasked with implementing a Python class that represents a multi-dimensional axis series. The class should enforce certain constraints during initialization to ensure the integrity of the axis series. The provided code snippet is a part of the class constructor and contains error-checking logic. Your task is to ...
codefeedback
You are tasked with creating a command-based autonomous system for a robot that needs to perform a sequence of actions to return to its home position. The robot has a subsystem responsible for its movement, and the autonomous system is designed to execute a series of commands in a sequential manner to guide the robot b...
codefeedback
You are given a list of integers representing the scores of a game. The game has a rule that if a score of 0 is encountered, the game ends immediately. Your task is to find the maximum score that can be achieved by playing the game according to the given rule. You need to implement a function `maxGameScore(scores)` tha...
codefeedback
You are tasked with creating a Python function that processes a matrix received from a server. The function should handle potential server errors and timeout errors gracefully. The code snippet provided gives a glimpse of the error handling and matrix retrieval process. Your task is to implement the function `process_m...
codefeedback
You are working on a scientific data analysis project and need to implement a class for fitting a linear model to a set of data points and computing the chi-square statistic to evaluate the goodness of fit. The class should have methods for fitting the model, computing the predicted values, and calculating the chi-squa...
codefeedback
You are tasked with implementing a timer decorator in Python that can be used to measure the execution time of functions. The decorator should be able to accept an optional interval parameter, which specifies the time interval in seconds at which the function execution time should be printed. If the interval is not pro...
codefeedback
You are given a set of 3D coordinates representing points in space. Each line of the input represents a point with its x, y, and z coordinates separated by commas. The input ends with a line containing "--- scanner 4 ---", indicating that there are 4 points in total. Your task is to write a program to calculate the di...
codefeedback
You are tasked with creating a Python class that represents a use case for a user account management system. The use case involves multiple steps to create a user account and generate an activation token. Your task is to implement the missing methods in the given Python class to fulfill the use case requirements. You ...
codefeedback
You are tasked with implementing a function to grid a set of frames in a graphical user interface (GUI). The function should take a variable number of frame objects as input and arrange them in a grid layout. Each frame should be positioned in a specific row and column within the grid. You are given the following info...
codefeedback
You are tasked with creating a Python function that validates user registration data for a web application. The function should take in a JSON payload containing user information and perform the following validations: 1. Check if the request contains the required fields: "username", "email", "password", and "confirm_pa...
codefeedback
You are given a Python code snippet that defines two lambda functions, `isPentagonal` and `isHexagonal`. The `isPentagonal` function checks if a given number is a pentagonal number, and the `isHexagonal` function checks if a given number is a hexagonal number. A pentagonal number is a figurate number that extends the c...
codefeedback
You are tasked with implementing a function to resize an image using a given scaling factor. The function should take an image object and a scaling factor as input and return the resized image. The image object is represented as a 2D array of pixels, where each pixel is represented by a tuple of RGB values. The scaling...
codefeedback
You are tasked with implementing a viewshed update system for a game engine. A viewshed represents the area visible to an actor within the game world. The provided code snippet is a part of a function that updates the viewsheds for all the actors in the game world. The function takes in a mutable reference to the game ...
codefeedback
You are tasked with implementing a function that finds the maximum value within a given range of cells in a 2D grid. Each cell in the grid contains a value, and the function should return the maximum value found within the specified range. You are given the following function signature: ```c position_value_t findMaxVa...
codefeedback
You are tasked with implementing a real-time data processing algorithm for a depth-sensing camera. The camera provides a stream of depth data, and your goal is to process this data in real-time to identify and track the movement of objects within the camera's field of view. The provided code snippet initializes some c...
codefeedback
You are tasked with implementing a Python class method that generates a unitary matrix based on a specific parametrization. The provided code snippet is a part of the method `create_unitary_matrix` within a class. The method takes in parameters `c23`, `s23`, and `symb`, and sets the `symb` attribute of the class instan...
codefeedback
You are tasked with implementing a Python class to represent a deck of playing cards. The class should have methods to initialize the deck, shuffle the cards, deal a specified number of cards, and display the remaining cards in the deck. Your task is to complete the implementation of the `DeckOfCards` class by filling...
codefeedback
You are tasked with creating a Python class to handle unit conversions for various physical quantities. The class should be able to convert values between different units for length, sound, frequency, and musical intervals. The conversion data is provided in a dictionary format, where the keys represent the units and t...
codefeedback
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the highest possible score by choosing a subset of the scores such that no two chosen scores are adjacent in the original list. Write a function `maxNonAdjacentScore` that takes in a list of integers `s...
codefeedback
You are tasked with implementing a custom pipeline processing system using Python. The `pipetools` library provides a set of utilities for creating and managing data processing pipelines. Your goal is to create a pipeline that processes a series of data transformations and filters. You are given the following requirem...
codefeedback
You are tasked with creating a function that extracts and returns all the URLs present in the given HTML code snippet. The function should take the HTML code as input and return a list of unique URLs found within the anchor tags (<a>). Function Signature: `def extract_urls(html: str) -> List[str]:` Example: Input: ``...
codefeedback
You are given a list of integers representing the heights of a series of buildings. Your task is to write a function that determines the maximum amount of rainwater that can be trapped between the buildings. The function should take in a list of integers representing the heights of the buildings and return the maximum ...
codefeedback
You are tasked with implementing a Swift protocol that extends the functionality of SpriteKit nodes. The protocol, named `SKNodeWithBlendMode`, is intended to be adopted by classes conforming to `SKNode`. The protocol should include a property or method related to blend modes, which are used to control how a node's col...
codefeedback
You are tasked with creating a script to automate the installation of a software package called GeoIP. The script should download the GeoIP package, extract it, configure it with specific options, build it, and then install it. The script should be able to handle different versions of the GeoIP package and should be wr...
codefeedback
You are tasked with creating a secure password management system using property wrappers in Swift. Your goal is to implement a `Password` property wrapper that securely stores and retrieves passwords using the Keychain service. The `Password` property wrapper should provide a convenient and secure way to manage passwor...
codefeedback
You are tasked with implementing a parser for a custom configuration language. The language consists of various contexts, each with its own set of parsing rules. The provided code snippet shows a partial mapping of context names to parsing functions. The `context_map` dictionary maps context names to parsing functions,...
codefeedback
You are tasked with implementing a method to optimize API filters for a request object. The request object contains a map of dimensions to sets of API filters. The goal is to merge filters for dimensions that implement the `FilterOptimizable` interface. The `ApiFilters` class provides a method `merge` to merge filters ...
codefeedback
You are tasked with creating a program that analyzes the namespace hierarchy of a given C# code file. Your program should be able to identify the deepest level of nested namespaces and count the occurrences of each namespace at that level. Write a function `CountDeepestNamespaces` that takes a string representing the ...
codefeedback
You are tasked with implementing a multi-threaded function to render an appleseed image using various texture maps and a template file. The function `render_appleseed` takes in several parameters including the target file path, texture maps for base color, normal, roughness, and metallic properties, the resolution of t...
codefeedback
You are tasked with implementing a Monte Carlo Tree Search (MCTS) algorithm for a simple game-playing AI. The game environment is provided by the `Environment` class from the `TTTArena` package. The AI will use the MCTS algorithm to make decisions in the game. Additionally, the AI will utilize a neural network-based mo...
codefeedback
You are tasked with creating a Python class that represents a link tag in HTML. Your class should have the following attributes: - `rel` (string): representing the relationship between the current document and the linked document - `mimetype` (string): representing the type of the linked document's content - `href` (s...
codefeedback
You are tasked with implementing a Python class that represents a statistical variable with a specified domain. The class should allow for the storage of a list of floating-point values and provide functionality to manipulate and analyze the data. Additionally, the class should support a configuration option for case s...
codefeedback
You are given the lengths of the sides of a right-angled triangle, AB and BC. Your task is to find the angle θ, where θ is the angle ΑBC. Write a function `find_angle` that takes two integer inputs AB and BC, representing the lengths of the sides of the right-angled triangle. The function should calculate the angle θ ...
codefeedback
You are given a snippet of code that processes a matrix and performs certain operations based on the values in the matrix. Your task is to implement a function that replicates the functionality of the given code snippet. You are given a matrix `valid` and a matrix `mask`, both of which are 2D arrays of boolean values....
codefeedback
You are tasked with creating a function to retrieve billing information for a user from a database. The database schema includes the following tables: `users`, `bills`, `detail_bills`, `detail_products`, and `products`. The `bills` table contains information about each bill, such as the total coin amount and the creati...
codefeedback
You are tasked with implementing a function composition utility in Swift. Function composition is a fundamental concept in functional programming, where you combine multiple functions to create a new function. Your task is to create a function that composes single-argument functions from right to left. You are provide...
codefeedback
You are tasked with creating a class for generating PDF documents. Your task is to implement a method that will add a header to each page of the PDF. The header should display the total number of pages in the document and some specific information related to the questions being displayed in the PDF. You are provided w...
codefeedback
You are tasked with creating a Python program to automate the process of fetching images from a website using Selenium and Chrome WebDriver. Your program should be able to navigate to a specific webpage, locate and download images, and save them to a designated folder on your local machine. Your program should perform...
codefeedback
You are tasked with understanding and implementing a specific feature in Rust related to type aliases and asynchronous programming. Given the provided code snippet, you are required to explain the concept of `type_alias_impl_trait` feature and its usage in the context of defining a type alias for an asynchronous funct...
codefeedback
You are tasked with creating a Python function that converts a given string from camel case to snake case, while also removing any non-alphanumeric characters except for underscores. The function should follow these specific requirements: - The input string will be in camel case, meaning it will consist of one or more ...
codefeedback
You are tasked with implementing a state machine for a chat application. The state machine has several states, including the CHAT state, which represents a conversation with a specific contact. The code snippet provided includes a portion of the state machine implementation, focusing on transitioning to the CHAT state ...
codefeedback
You are tasked with creating a password validation function for a web application. The function should take in a password and a confirmation password as input and return a boolean value indicating whether the two passwords match. The function should also perform additional checks for password strength, including the fo...
codefeedback
You are tasked with implementing a simple synchronization mechanism in Rust using the `std::sync` module. Your goal is to create a custom synchronization primitive that allows one thread to wait until another thread signals it to proceed. You will need to implement a struct `SignalGuard` that provides methods for waiti...
codefeedback
You are given a Python code snippet that sets up a unit test for a function called `nested_if_else`. Your task is to implement the `nested_if_else` function according to the given specifications. The `nested_if_else` function takes a NumPy array `x` as input and performs nested if-else operations to modify the array e...
codefeedback
You are tasked with implementing a PWM (Pulse Width Modulation) control system for a microcontroller. The given code snippet is a part of a Rust programming language implementation for configuring PWM on a microcontroller using the `tim` timer and `porth::PH4` pin. The `into_pwm` function takes two arguments: `tim` (t...
codefeedback
You are tasked with creating a NestJS module for managing user addresses. The module should include the necessary imports, controllers, and providers to handle address-related operations. Additionally, the module should integrate Mongoose for database operations and Passport for authentication using JWT strategy. Your...
codefeedback
You are tasked with implementing a function to_refs that converts a linked list of mutable references into a vector of mutable references. The List struct is defined as follows: ```rust struct List<T> { value: T, next: Option<Box<List<T>>>, } ``` The to_refs function takes a Box containing a mutable reference...
codefeedback
You are tasked with creating a movie management system using Core Data in Swift. Your goal is to implement a function that fetches all the favorite movies from the Core Data storage. The provided code snippet includes a method `fetchAllFavoriteMovies()` that attempts to achieve this functionality. Your task is to analy...
codefeedback
You are tasked with implementing a directory structure using a custom data structure. The directory structure should support operations such as creating directories, navigating through directories, and listing the contents of a directory. You are given a code snippet that initializes the root directory and sets its nam...
codefeedback
You are tasked with creating a Discord bot that supports various functionalities, including level management and music playback. Your goal is to implement a command handler for the bot that processes user commands related to level management and music playback. For level management, the bot should support a command ca...
codefeedback