instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program that simulates a simple inventory management system for a small retail store. The system should allow users to add, remove, and update products in the inventory, as well as display the current inventory status. Your program should include the following functionalities: 1. Add a n...
codefeedback
You are tasked with implementing a custom physics behavior for a platformer game. The game includes platforms with both regular colliders and trigger colliders. The provided code snippet is a part of the platform behavior script. The `Start` method is called when the platform is initialized. Within this method, the scr...
codefeedback
You are tasked with creating a Python function that reads a file, converts its content to uppercase, and then counts the occurrences of each word in the file. Your function should take a filename as input and return a dictionary where the keys are the unique words in the file (case-insensitive) and the values are the c...
codefeedback
You are tasked with implementing a custom PyTorch dataset class for adding synthetic noise to the MNIST dataset. The provided code snippet initializes a DataLoader for the noisy MNIST test dataset using the custom SyntheticNoiseDataset. Your task is to create the SyntheticNoiseDataset class, which takes the original MN...
codefeedback
You are tasked with creating a custom annotation processor in Java. Your goal is to implement a program that processes classes annotated with `@Reactant` and generates a new class that contains a method to react with other reactants. Your program should perform the following tasks: 1. Define a custom annotation `@Reac...
codefeedback
You are given a Python code snippet that includes a comment with a date and author information. Your task is to write a Python function that extracts the creation date and author from the given code snippet. Write a function `extract_info(code)` that takes a string `code` as input and returns a tuple `(creation_date, ...
codefeedback
You are tasked with creating a Python decorator that logs the execution time of a function and prints the result. Your decorator should be able to handle functions with any number of positional and keyword arguments. Additionally, you need to implement a function that calculates the factorial of a given number and appl...
codefeedback
You are tasked with creating a script to automate the process of building LLVM and its related projects from source code. The script should handle extracting source code archives, setting up the directory structure, and invoking the necessary build commands. Your script should perform the following steps: 1. Extract t...
codefeedback
You are tasked with implementing a logging system for a software application. The logging system should support different levels of logging, flags, and colors for the log messages. You need to create a class `ToolLogger` with a method `log` that takes in the level of the log message, a flag, a color, the log message da...
codefeedback
You are tasked with creating a Django model for a social media application that allows users to link their accounts to external providers such as Facebook. The model should store information about the user's social profile, including the provider, social ID, photo, extra data, and a reference to the user's main profile...
codefeedback
You are tasked with implementing a Python function that processes a list of dependencies and operations related to database migrations. The function should parse the dependencies and operations and return a formatted string representing the migration operations. You are given a list of dependencies and a list of migra...
codefeedback
You are tasked with creating a program to manage a student's course schedule. The provided code snippet is a part of a graphical user interface (GUI) for this program, written in Python using the Tkinter library. The GUI includes a list of available courses and buttons to insert a course and create a schedule. Your ta...
codefeedback
You are tasked with creating a custom validation attribute for a .NET Core MVC application. The attribute should ensure that the `Keyword` property is not empty and contains at least one character. Additionally, the attribute should be applied to the `Keyword` property in a model class. Your task is to implement the cu...
codefeedback
You are tasked with creating a Java program that utilizes the Spring Framework to implement a simple JDBC-based application. Your program should include the necessary components to connect to a database, perform CRUD (Create, Read, Update, Delete) operations on a table, and demonstrate the usage of Spring's dependency ...
codefeedback
You are tasked with implementing a custom data structure called `CustomQueue` in Rust. The `CustomQueue` should have the following functionalities: 1. `new`: Create a new empty queue. 2. `enqueue`: Add an element to the end of the queue. 3. `dequeue`: Remove and return the element at the front of the queue. 4. `peek`: ...
codefeedback
You are tasked with implementing a function to extract audio data from a file using the ExtAudioFile API in Swift. The given code snippet sets up the necessary variables and opens an audio file using the ExtAudioFileOpenURL function. Your task is to complete the implementation by writing a function that reads the audio...
codefeedback
You are tasked with implementing a TypeScript function that takes in an array of `Types` and returns the count of occurrences of each unique type in the array. The `Types` type is a union type that can include various type literals. You need to create a function that can accurately count the occurrences of each unique ...
codefeedback
You are tasked with implementing a program that simulates a simple options trading system. The system will allow users to buy and sell options contracts based on the current market price of the underlying asset. Each options contract represents the right to buy or sell the underlying asset at a specified price (the str...
codefeedback
You are working on a Django web application that includes an admin interface and RESTful API endpoints. The code snippet provided includes some import statements for Django modules and views from a local package. Your task is to create a custom Django admin view that allows the admin to manage a specific model in the a...
codefeedback
You are tasked with creating a Python program that simulates a simple online store. The program should have a class representing a product, a class representing a shopping cart, and a main program to interact with the user. The Product class should have the following attributes: - name: a string representing the name ...
codefeedback
You are given the definition of a binary tree node and a function `mergeTrees` that takes in two binary trees `t1` and `t2` as input and merges them into a new binary tree. The `mergeTrees` function creates a new binary tree by summing up the values of corresponding nodes from the input trees. If a node exists in only ...
codefeedback
You are tasked with creating a program that processes a list of files generated by the Microsoft AutoRest Code Generator. The AutoRest Code Generator produces code for interacting with RESTful APIs based on a provided OpenAPI specification. The generated code includes comments and annotations that need to be parsed and...
codefeedback
You are given a list of integers representing the results of a series of submissions in a programming contest. Each integer represents the result of a submission, where 1 indicates a correct answer and 0 indicates a wrong answer. Your task is to find the index of the first incorrect submission (0) in the list. If there...
codefeedback
You are tasked with implementing a generic data structure in Rust that allows for the creation of a singly linked list. The linked list should support the addition of elements at the front and back, as well as the removal of elements from the front. Additionally, the linked list should provide an iterator that allows f...
codefeedback
You are working on a project that involves processing and visualizing 3D image data using the VTK (Visualization Toolkit) library in Python. As part of this project, you need to create a VTK pipeline to visualize a 3D image dataset using the `vtkImageDataGeometryFilter` class. The `vtkImageDataGeometryFilter` class is...
codefeedback
You are tasked with creating a script to automate the process of creating a bootable disk image for a custom operating system. The script should perform the following tasks: 1. Remove any existing disk image file named "bos.img" from the parent directory. 2. Create a new disk image file named "bos.img" with a capacity ...
codefeedback
You are tasked with implementing a decorator function in Python that restricts access to a given function based on user privileges. The decorator should check if the user is logged in and has the necessary permissions to access the function. You are provided with the following code snippet for inspiration: ```python @...
codefeedback
You are tasked with implementing a simplified version of a peer-to-peer communication protocol using Rust. The protocol involves a handshake process between two peers to establish a connection. The provided code snippet is a part of the handshake process, where a handshake message is constructed and sent to the remote ...
codefeedback
You are given a code snippet that tests a function `part2` with different inputs and expected outputs. Your task is to implement the `part2` function based on the given inputs and expected outputs. The `part2` function takes an `Input` object as input and returns an integer. The `Input` object is created using the `In...
codefeedback
You are tasked with creating a Django migration to alter a field in a model. The model in question is `LearnerProgressNotification` and the specific alteration involves changing a field within this model. Your task is to write the necessary migration code to achieve this alteration. Your task is to complete the `opera...
codefeedback
You are tasked with creating a JavaScript module that exports a schema object. The schema object will define the structure and constraints for a specific data model. Your task is to implement the schema object with the following requirements: The schema object should have a property named "fields" which is an array of...
codefeedback
You are tasked with implementing a password decoder utility for a web server using Java. The `JettyPasswordDecoder` class is responsible for decoding obfuscated passwords used in the web server configuration. The `Password` class provides a method to obfuscate passwords. Your goal is to implement the `JettyPasswordDeco...
codefeedback
You are tasked with implementing a Python class that processes sequence data from a FASTA file and organizes it into groups based on a specified sense. The class should be able to handle the loading of the FASTA file, grouping the sequences based on the specified sense, and providing access to the grouped sequences. Y...
codefeedback
You are tasked with implementing a dynamic programming algorithm to find the minimum cost of transforming one sequence of elements into another. The cost of transformation is determined by the cost of adding, deleting, or substituting elements in the sequences. Additionally, a custom comparison function is used to comp...
codefeedback
You are tasked with implementing a class for a scientific calculator. The class should have methods to change the display mode from degrees to radians and to change the text of trigonometric function buttons when the user switches to radians mode. You need to implement the following methods in the scientific calculato...
codefeedback
You are tasked with creating a Python function that manages the installation and configuration of a software package on a system. The function should take in various parameters to customize the installation process. Below is a code snippet that outlines the argument specifications for the function: ```python argument_...
codefeedback
You are tasked with implementing a custom decorator that measures the execution time of a function in Python. Your decorator should be able to calculate the time taken for the function to execute and print the result in milliseconds. You should also ensure that the original function's return value is preserved and retu...
codefeedback
You are tasked with implementing a custom layout system in Swift for iOS development. The system involves creating a prefix operator function and several custom classes to handle layout attributes and constraints. Your task is to implement the missing parts of the layout system based on the given code snippet. The sys...
codefeedback
You are tasked with creating a PHP function that processes user registration data and stores it in a database. Your function should handle validation, insertion, and error handling. You are provided with the following code snippet as a starting point: ```php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username...
codefeedback
You are tasked with implementing a function that processes a given depth stencil descriptor and returns a corresponding Metal depth stencil state. The function should handle potential errors and post notifications in case of failure. You are provided with the following code snippet as a reference: ```swift } catch le...
codefeedback
You are tasked with creating a validation rule for a specific field in a Laravel application. The application has a `store` method within a controller that handles incoming requests. The `store` method receives a `Request` object and is responsible for validating the input data before processing it further. The code sn...
codefeedback
You are tasked with implementing a keypoint detection algorithm for a computer vision application. The algorithm takes as input a 4-dimensional array `preds` representing the predictions of a neural network for keypoints in an image. The array has the shape (N, H, W, C), where N is the number of samples, H is the heigh...
codefeedback
You are given a dataset containing the results of a series of experiments. The code snippet provided is a part of a Python script that generates a normal quantile-quantile (QQ) plot to assess whether the data follows a normal distribution. The QQ plot compares the quantiles of the dataset against the quantiles of a the...
codefeedback
You are tasked with creating a program that analyzes HTML code to identify and count the occurrences of specific HTML tags within a given snippet. Your program should be able to handle various HTML tags and provide the count of each tag present in the input. Write a function `count_html_tags(html_snippet: str, tags: L...
codefeedback
You are tasked with creating a program that reads a text file and counts the occurrences of specific words within it. The program should ignore any lines that start with a "#" symbol, as these are considered comments. The words to be counted are provided in a separate input file, with each word on a new line. The progr...
codefeedback
You are tasked with implementing a custom string encoding and decoding algorithm. The encoding algorithm will take a string as input and return the encoded version of the string, while the decoding algorithm will take the encoded string and return the original string. The encoding algorithm works as follows: 1. For ea...
codefeedback
You are given a function `countOccurrences` that takes in two parameters: a string `text` and a string `pattern`. The function is designed to count the number of occurrences of the `pattern` within the `text`. However, the implementation of the function is incomplete and needs to be fixed. The function `countOccurrenc...
codefeedback
You are given a string `s` containing only lowercase English letters. Your task is to write a function that returns the length of the longest substring without repeating characters. For example, given the input string "abcabcbb", the longest substring without repeating characters is "abc", so the function should retur...
codefeedback
You are tasked with implementing a generic image processing library in Rust. The library should support the creation and manipulation of square images represented by the `SquareImage` struct. The `SquareImage` struct has an `edge_length` field representing the length of each edge of the square image and an `inner` fiel...
codefeedback
You are tasked with creating a Python class that simulates a magical witch who can cast spells and brew potions. The witch class should have the following functionalities: 1. Casting Spells: The witch should be able to cast spells by providing the spell name and the power level. The power level of a spell can range fr...
codefeedback
You are tasked with implementing a custom view controller in Swift that manages a list of tasks. The view controller should allow users to add, remove, and display tasks. Additionally, it should provide a method to mark a task as completed. You need to implement the `Task` struct and the `TaskListViewController` class ...
codefeedback
You are tasked with creating a Django web application for a project management system. The given code snippet represents the URL patterns defined in the `urls.py` file of the Django application. Each URL pattern is associated with a specific view function that handles the corresponding HTTP request. Your task is to des...
codefeedback
You are given a Python function called `uncycle` that takes a list of integers as input and returns a modified list. The function is intended to remove any cyclic shift from the input list and return the list in its original order. The code snippet provided is a part of the `uncycle` function. The function uses recurs...
codefeedback
You are tasked with creating a Python program to automate the process of fetching and organizing emails from an IMAP server. Your program should connect to the IMAP server, log in with the provided credentials, and then fetch specific information from the emails. Your program should perform the following steps: 1. Con...
codefeedback
You are tasked with creating a Python class that simulates a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should have a method for transferring funds to another bank account. Your task is to implement the `BankAcco...
codefeedback
You are tasked with creating a Python function that processes a given string to extract and count the occurrences of Korean words. The function should take a string as input and return a dictionary where the keys are the unique Korean words found in the input string, and the values are the counts of each word's occurre...
codefeedback
You are tasked with creating a simple timer application using the GTK library in Rust. The provided code snippet initializes a GTK window and a label to display the timer. Your task is to implement the timer functionality that updates the label to show the elapsed time in the format "HH:MM:SS". Your timer should start...
codefeedback
You are tasked with creating a Python decorator that can be used to skip a test if a specific condition is not met. The decorator should be able to handle skipping tests based on the absence of a network connection and the availability of a specific URL. Your task is to implement the `skip_if_no_network` and `skip_if_...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should be able to handle various types of bank accounts, such as savings accounts and checking accounts. Additionally, it should be able to process transactions, including deposits, withdrawals, and transfers between accounts. Y...
codefeedback
You are tasked with implementing a function that finds the nearest free memory block in a given process's address space. The function should take a memory address as input and return the nearest free memory block address that precedes the given memory address. The memory blocks are defined using the `MEMORY_BASIC_INFOR...
codefeedback
You are tasked with implementing a reinforcement learning environment for a simple game. The environment is initialized with the given code snippet, which sets up the initial state and some parameters. Your task is to complete the implementation of the environment by defining the step function, which determines the beh...
codefeedback
You are tasked with implementing a graph data structure to represent a map of cities and their connections. Each city is represented as a vertex in the graph, and the connections between cities are represented as edges. Your goal is to create a Python class that can be used to construct the graph and perform various op...
codefeedback
You are tasked with creating a program that processes a given Laravel language file and extracts the translatable strings for further processing. In Laravel, translatable strings are typically enclosed within the `__()` helper function or its alias `@lang`. The translatable strings are enclosed within a specific syntax...
codefeedback
You are tasked with implementing a data storage system for a company's products. The system should support sparse fields, which are fields that are only stored if they have a non-default value. To achieve this, you need to design a class that can handle sparse fields and store them efficiently. You are given a code sn...
codefeedback
You are tasked with creating a Python function that processes log data from a web application. The log data is represented as a list of Log objects, where each Log object has the following attributes: - `timestamp`: an integer representing the time of the log entry - `level`: a string representing the severity level of...
codefeedback
You are tasked with implementing a Python function that processes an abstract syntax tree (AST) and modifies it based on certain rules. The AST represents a snippet of Python code and needs to be transformed by inserting return statements into the code body. Additionally, the function should create an environment dicti...
codefeedback
You are tasked with implementing a Python class method that sets the endianness and creates transport-specific constructors. The method should handle the setting of endianness and the creation of constructors based on the given endianness. Your task is to complete the implementation of the `__setup_constructors` method...
codefeedback
You are tasked with simulating the display of a character on a screen using a simplified video memory system. The provided code snippet is a part of a larger system responsible for rendering characters on a display. The variables and operations used in the code snippet are as follows: - `x`: Current x-coordinate on the...
codefeedback
You are tasked with creating a Python utility for file manipulation. Your task is to implement a class `FileManipulator` that provides various file operations using the methods provided in the `fileutil.utils` module. The methods to be implemented in the `FileManipulator` class are as follows: 1. `findFileNameWithoutS...
codefeedback
You are tasked with implementing a function to decompose a data URI into its constituent parts. A data URI is a scheme that provides a way to include data in-line in web pages as if they were external resources. The general format of a data URI is `data:[<media type>][;charset=<character set>][;base64],<data>`, where `...
codefeedback
You are given a code snippet that appears to be the result of fuzzing or random input generation. Your task is to analyze the code and identify the potential issues or errors present in it. The code seems to be a mix of Swift syntax elements, but it is heavily obfuscated and contains multiple nested curly braces, class...
codefeedback
You are tasked with implementing a Python class that manages a multi-line view for displaying and selecting glyphs from a font. The class should provide methods for setting the glyphs to be displayed, as well as a callback function for handling glyph selection events. Your task is to implement the `MultiLineView` clas...
codefeedback
You are tasked with implementing a class that manages hotkeys for a desktop application. The class, `HotkeyManager`, is responsible for handling the registration and management of hotkeys. It provides functionality to set a hotkey, listen for hotkey events, and retrieve the current hotkey label. The class has the foll...
codefeedback
You are tasked with implementing a multi-threaded program that simulates a simple banking system. The program should support multiple account holders making deposits and withdrawals concurrently while ensuring data consistency and avoiding race conditions. You are provided with a partial code snippet for the `Bank` cl...
codefeedback
You are tasked with implementing a simple ray tracing algorithm to render a 3D scene. The provided code snippet is a part of a method in a Rust program that calculates the color emitted by a material at a given intersection point. The `emitted` method takes in a reference to a `Ray` and a `HitRecord` and returns the co...
codefeedback
You are given a simplified programming language that supports conditional statements and arithmetic operations. The conditional statement has the following syntax: ``` alt <expression> { <value1> { <statement1> } <value2> { <statement2> } ... _ { <default statement> } } ``` Where `<expression>` is an arithmetic...
codefeedback
You are tasked with creating a program that simulates a simple calculator. The program should take a string as input, which represents a mathematical expression in postfix notation. Postfix notation, also known as Reverse Polish Notation (RPN), is a mathematical notation in which every operator follows all of its opera...
codefeedback
You are tasked with creating a program to manage the layout constraints of UI elements in a mobile application. The program should be able to parse and process layout constraint code snippets, and then output the constraints in a human-readable format. You are given a code snippet that represents layout constraints us...
codefeedback
You are tasked with creating a program that parses a given input text using a specific parsing algorithm. The input text will be provided through a text box in a Windows Forms application. Your task is to implement the parsing functionality triggered by a button click event. The parsed output should be displayed in a s...
codefeedback
You are working on a computer vision project and need to implement a function to process and manipulate tensors representing bounding box coordinates and offsets. The code snippet provided is a part of this function, which involves reshaping and manipulating tensors using PyTorch operations. Your task is to implement ...
codefeedback
You are tasked with implementing a virtual list component in Vue 3. A virtual list is a UI component that efficiently renders a large list of items by only rendering the visible items and dynamically updating the rendered content as the user scrolls. The provided code snippet is a part of the implementation of this vir...
codefeedback
You are given a linked list where each node contains an integer value and a reference to the next node in the list. Write a function `detectCycle` to determine if the linked list contains a cycle and return the node where the cycle begins if it exists. The function signature is: ```python def detectCycle(head: ListNod...
codefeedback
You are working on a project that involves using the e3nn library for tensor field networks in PyTorch. Your task is to create a custom tensor field transformation using the e3nn library and apply it to a given input tensor. The transformation involves using the o3 module from e3nn to perform a specific operation on th...
codefeedback
You are tasked with implementing a loss calculation method for a deep learning model. The provided code snippet is a part of a larger deep learning framework. The `calc_losses` method is responsible for calculating the loss function for the model. The method takes in input data and a boolean flag `is_train` indicating ...
codefeedback
You are tasked with creating a Django view that allows users to upload a new post with a picture. The view should also associate the post with the currently logged-in user. You are given the following code snippet as a starting point: ```python from users.models import Profile class Post(models.Model): descriptio...
codefeedback
You are given a list of integers and a target value. Your task is to implement a function that finds the closest value to the target in the list. If there are multiple closest values, return the smallest one. Function Signature: `def closest_value(arr: List[int], target: int) -> int:` Input: - `arr`: A list of intege...
codefeedback
You are tasked with implementing a state machine for a simple animation system. The animation can be in one of four states: `hide`, `hiding`, `show`, or `showing`. The state machine should support transitioning between these states and provide methods to query the current state. You are given a partial code snippet th...
codefeedback
You are tasked with implementing a function that takes a list of integers as input and returns the median of the list. The median of a list of numbers is the middle number when the list is sorted in ascending order. If the list has an odd number of elements, the median is the middle number. If the list has an even numb...
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 the staircase by either taking 1 or 2 steps at a time. Write a function `countWaysToTop` that takes an integer `n` as input, representing the total number of steps in the staircase, and re...
codefeedback
You are working on a data processing pipeline for analyzing information about biographical films. The pipeline takes a CSV file `cleaned_biopics.csv` as input and performs a series of operations using command-line tools. Your task is to write a script that accomplishes the same data processing steps as the given code s...
codefeedback
You are given a graph represented by a list of edges. Each edge is represented by a struct `Edge` containing two integers `u` and `v`, denoting the vertices it connects. Your task is to write a function to determine whether the given graph contains a cycle. Write a function `bool hasCycle(vector<Edge>& edges, int n)` ...
codefeedback
You are given a class `Graph` that represents a directed graph using adjacency lists. The class has a method `topologicalSort` that returns a topological ordering of the graph nodes. The method uses a helper function `topologicalSortUtil` to perform the actual topological sorting. However, the implementation of the `to...
codefeedback
You are tasked with implementing a Python class to manage tiers of a cloud computing service. The class should provide methods to retrieve all tiers and to parse a tier from a string representation. You are given a code snippet that defines a `Tier` class and a `get_all_tiers` function that returns a list of predefine...
codefeedback
You are tasked with implementing a custom data structure to manage web service requests. The structure should support equality comparison and include a header with specific properties. Your task is to create a Swift class `WSRequest` that represents a web service request. The `WSRequest` class should have the followin...
codefeedback
You are working on a project that involves analyzing neuron shapes represented as directed graphs. The graph is represented using the networkx library in Python. You have a function that reads a neuron shape file and generates a directed graph `G` representing the neuron shape. The function also returns the neuron shap...
codefeedback
You are tasked with implementing a function to calculate the inverse error function (erf_inv) for a given input value. The inverse error function is a mathematical function that maps the range of the error function onto the real numbers. The function erf_inv_impl is used to approximate the inverse error function, and i...
codefeedback
You are tasked with implementing a function that checks whether a given string is a valid palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. You need to create a function `is_valid_pa...
codefeedback
You are tasked with implementing a Python function that generates rows based on given input parameters. The function takes two arguments: `inx`, which represents the index of the row, and `result`, which is a dictionary containing keys that can be obtained from the `processor()` function in `mori.py`. The function shou...
codefeedback
You are tasked with implementing a function compiler that takes a function as input and compiles it into a callable object. The function takes a `std::valarray<double>` as input and returns a `double`. Your goal is to create a class `function_compiler` that can compile different functions and then execute them. The `f...
codefeedback
You are tasked with implementing a simplified version of a timer wheel data structure in C++. A timer wheel is a circular array of slots, where each slot represents a specific time interval. When a timer is added to the wheel, it is placed in the slot corresponding to its expiration time. When the wheel "ticks," it adv...
codefeedback