instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function to find the best motifs in a set of DNA sequences. Motifs are short, recurring sequences that are presumed to have biological significance. The function should utilize a scoring system to evaluate the quality of motifs and then return the best motifs based on this scoring. Y...
codefeedback
You are tasked with implementing a Python function that calculates the total number of valid IP addresses that can be formed using a given string of digits. An IP address consists of four numbers (each ranging from 0 to 255) separated by periods. The input string can contain any number of digits, and the function shoul...
codefeedback
You are given a string `string` containing only uppercase and lowercase English letters. Your task is to write a function or program to count the occurrences of each letter in the string and print the count for each letter in the format: "Letter is Count times". The count should be case-insensitive, meaning that 'A' an...
codefeedback
You are tasked with implementing a JavaScript function executor class in C++. The JavaScriptFunctionExecutor class is responsible for executing JavaScript functions within a C++ environment. The class should be able to load and execute JavaScript functions, passing arguments to them and retrieving their return values. ...
codefeedback
You are tasked with implementing a custom Django template filter that converts a given numerical value into a percentage format with a specified number of significant digits. The filter function `to_percent` takes two parameters: `obj`, the numerical value to be converted, and `significant_digits`, the number of signif...
codefeedback
You are tasked with implementing a data encoding and decoding process using JavaScript. The provided code snippet demonstrates the usage of encoding and decoding functions, along with assertions to validate the decoded data. Your task is to create a JavaScript function that performs the encoding process and another fu...
codefeedback
You are tasked with creating a Python program that utilizes the Tcam and Gst libraries to capture video from a camera and save it to a file. The Tcam library provides access to industrial cameras, while the Gst library is used for handling multimedia data flow. Your program should initialize the camera, set its propert...
codefeedback
You are tasked with implementing a Python function that processes and analyzes the output of a machine learning model during training. The function will take a string containing the output log of the model and extract specific information from it. The log contains lines of text that include various pieces of informatio...
codefeedback
You are tasked with implementing a custom sorting web component in JavaScript using the Custom Elements API. The custom element should be defined as "outline-sort-span" and should provide a user interface for sorting a list of items. Your task is to create a custom web component called "outline-sort-span" that allows ...
codefeedback
You are tasked with implementing a performance counter system for a software application. The application has a set of flags that can be passed as command-line arguments, and based on these flags, different functionalities are triggered. Additionally, the application can either read input from a file or generate it int...
codefeedback
You are tasked with creating a Python class to manage patch sets for a version control system. Your class should include a method to resolve rejected hunks during the patch application process. The code snippet provided is a part of the `Resolve` method within the class. Your task is to implement the `Resolve` method ...
codefeedback
You are given a list of integers `num`. Your task is to write a function that finds the index of the first element in the list such that the element is less than the element immediately to its right. If no such element exists, the function should return -1. Write a function `find_index` that takes in the list `num` as...
codefeedback
You are tasked with implementing a Python function that processes data and generates a histogram plot using the `matplotlib` library. The function should take in the data, color information, weights, and file name, and produce a histogram plot with specific visual attributes. Write a Python function `generate_histogra...
codefeedback
You are tasked with implementing a height calculation feature for a web view using promises. The code snippet provided uses a fictional promise library and a WKWebView instance to demonstrate the usage of promises for asynchronous height calculation. Your task is to create a function that calculates the height of the w...
codefeedback
You are tasked with implementing a function that rotates a given 3D point around the x, y, and z axes by specified angles. The function should take the initial 3D point coordinates and the rotation angles as input and return the new coordinates after the rotation. The function signature should be: ```python def rotate...
codefeedback
You are tasked with implementing a role-based access control system for a web application. The provided code snippet is a part of the access control logic in Python using the Flask-Security library. The code snippet demonstrates how permissions are assigned based on the roles of users. Your task is to create a functio...
codefeedback
You are tasked with creating a photo management system for a photography application. The system should allow users to add, display, and save photo data. Your task is to implement the functionality to display a photo caption and to exit the application, ensuring that the photo data is saved before exiting. You are pro...
codefeedback
You are tasked with implementing a Python function to perform eigenvalue decomposition and validation for a symmetric matrix. Eigenvalue decomposition is a fundamental concept in linear algebra and has numerous applications in various fields such as physics, engineering, and computer science. You are given the followi...
codefeedback
You are tasked with creating a Python program that processes command-line arguments and generates an HTML file based on a given graph file. The program should handle exceptions and print the result to the standard output. Your task is to implement the `html_exporter` function, which takes two parameters: `graph_file_p...
codefeedback
You are tasked with implementing a function that processes a series of masks and returns the areas of the contours within each mask. The masks are represented as 2D arrays, where each element is either 0 or 1. The contours are defined by the 1s in the array, and the area of a contour is the number of connected 1s withi...
codefeedback
You are tasked with creating a Python script that simulates a simple banking system. The script should allow users to create accounts, deposit funds, withdraw funds, and check their balance. To achieve this, you will need to implement a class called `BankAccount` with appropriate methods and attributes. The `BankAccou...
codefeedback
You are tasked with implementing a simple banking system that supports account withdrawals. The provided code snippet is a part of a Rust program that defines a method for withdrawing funds from a bank account. Your task is to complete the implementation of the `withdrawal` method and handle various scenarios related t...
codefeedback
You are tasked with creating a Python function to read light intensity from a sensor and publish the data to an MQTT broker. The sensor is connected to the Raspberry Pi via the I2C bus. The sensor supports different measurement modes, including continuous high-resolution mode 1, continuous high-resolution mode 2, one-t...
codefeedback
You are tasked with implementing a test execution monitoring system for a software testing framework. The system should calculate the total time taken for test execution and notify a listener when all tests have been completed. You are provided with a code snippet from the existing system, which includes a method `endT...
codefeedback
You are tasked with creating a module loader for a JavaScript application. The module loader should be able to import and export modules using the ES6 module syntax. Your task is to implement a function that can parse and load the modules based on the provided code snippet. You are given a code snippet that demonstrat...
codefeedback
You are tasked with creating a program that processes and displays images using Python's OpenCV and Matplotlib libraries. The program should read an image file, convert it to grayscale, and display the grayscale image using the appropriate library based on user input. Your program should have the following functionali...
codefeedback
You are tasked with implementing a function to count the instances of specific patterns in a set of files. The function should take in the files to be analyzed, a set of expressions to base the counting on, and the patterns of strings to search for within the files. Your task is to write a function that returns a map o...
codefeedback
You are tasked with creating a Python function that simulates the behavior of the `async_init` method in the context of Home Assistant's configuration flow. The `async_init` method is used to initialize a configuration flow for a specific domain in Home Assistant, and it returns a result that contains information about...
codefeedback
You are given a Python function `size_of_state(x, k, window_size)` that takes in three parameters: - `x`: a list of numerical values representing a time series data. - `k`: a positive integer representing a scaling factor. - `window_size`: a positive integer representing the size of the sliding window. The function ca...
codefeedback
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score of the game, excluding the lowest and highest scores. Write a function `calculateAverage(scores)` that takes in a list of integers `scores` (2 <= len(scores) <= 100) and returns the av...
codefeedback
You are tasked with creating a Python module for managing a distributed storage system. The module will be used to perform various operations on the storage nodes, such as adding new nodes, removing existing nodes, and modifying storage configurations. Your task is to implement the logic for the module's main function,...
codefeedback
You are tasked with creating a Python function that validates and processes input data for a module using the given code snippet as a reference. Your function should perform the following tasks: 1. Validate the input arguments based on the provided specifications. 2. Process the input data to ensure it adheres to the ...
codefeedback
You are tasked with creating a Java class that represents a form in a web application using Selenium. The form has various fields, and you need to define the form fields and their corresponding locators. Your task is to create a class called `MarketplaceForm` that extends the `BaseMarketplaceForm` class and implements...
codefeedback
You are tasked with implementing a custom macro in Rust that modifies the behavior of a given function. The macro, `with_method!`, takes a function as an argument and generates a new function that includes additional functionality. The additional functionality is determined by the provided documentation comment, which ...
codefeedback
You are tasked with designing a photo management system for a social media platform. The system should allow users to upload photos, add captions, and generate thumbnails for display. You are provided with a code snippet from the existing photo interface implementation in Rust. Your task is to extend the functionality ...
codefeedback
You are tasked with implementing a Python class that aggregates batches of data. The class should have the ability to inherit from a base class and provide specific functionality for different types of data. Your task is to create a class called `DataBatch` that inherits from a base class called `Batch`. The `DataBatch...
codefeedback
You are tasked with creating a function that processes a given HTML template and extracts all the unique URLs present in the `img` tags. The function should return a list of these unique URLs. For example, given the following HTML template: ```html <div class="logo pull-left"> <a href="{{ url('/') }}"><img src="{{...
codefeedback
You are tasked with creating a Python script that processes video files based on metadata provided in a separate file. The script should take in command-line arguments to specify the metadata file and the target directory for the processed video files. The metadata file contains information about the video files to be...
codefeedback
You are tasked with creating a Rust program that utilizes traits and asynchronous programming. Your goal is to implement a trait for making API requests and then use it to define a specific request type. Your task is to complete the implementation of the `PandoraApiRequest` trait and create a struct that represents a ...
codefeedback
You are tasked with implementing a file usage quota system for users in a file management application. The provided code snippet outlines the structure of the file usage quota system. The `UserFileUsageQuota` struct contains a field `kind` of type `UserFileUsageQuotaKind`, which is an enum defining two variants: `Unlim...
codefeedback
You are tasked with implementing a custom file management system for a deep learning model training process. The system should handle the storage and retrieval of model weights at different epochs. The code snippet provided is a part of a class that manages the storage and retrieval of model weights in PyTorch. The `DO...
codefeedback
You are given a code snippet that involves a Just-In-Time (JIT) compiler for a simple function. Your task is to write a program that simulates the execution of the given code snippet and computes the result of the function call. The code snippet involves the creation of a JIT function, addition of two parameters, and ...
codefeedback
You are tasked with implementing a simple server management system. The system should allow for starting a server, serving requests indefinitely, and gracefully shutting down the server when requested. You are provided with a code snippet that partially implements this functionality using Python. Your task is to comple...
codefeedback
You are tasked with implementing a custom deserialization feature for a data class in Python. The data class is designed to accept input in various date and time formats and convert them into the appropriate Python objects using the Pendulum library for date and time manipulation. Your task is to create a `DataClass` ...
codefeedback
You are tasked with creating a token management system for a web application. The system should include a requirement checker to determine if a token check is required for a specific route and a token manager to retrieve the token for the route. You are given a code snippet that sets up mock objects for the requirement...
codefeedback
You are given a dataset containing two sets of performance metrics: precision and recall. Your task is to visualize these metrics using box plots and swarm plots. The dataset is represented by two DataFrames, `df_prec` for precision and `df_rec` for recall. Each DataFrame contains multiple columns, each representing a ...
codefeedback
You are tasked with creating a program that analyzes a given source code file and identifies potential formatting issues based on a set of specified code style rules. The code snippet provided is a command for the `indent` tool, which is commonly used to automatically format source code according to a defined style gui...
codefeedback
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. However, if the last two scores are the same, the player's score is doubled. Your task is to write a function that calculates the total score for the given list o...
codefeedback
You are tasked with creating a script to automate the versioning of iOS projects. The script needs to update the CFBundleVersion and CFBundleShortVersionString in the Info.plist file of an iOS project. The CFBundleVersion should be set to the provided $VERSION, and the CFBundleShortVersionString should be set to the fi...
codefeedback
You are tasked with implementing a Python class that simulates a village populated with villagers. The village is represented by a grid, and each villager is placed at a specific coordinate on the grid. Your task is to complete the `populate()` method of the `Village` class, which iterates over the number of villagers ...
codefeedback
You are tasked with creating a Python function that parses a SQL query and extracts the table names mentioned in the query. The SQL query may contain multiple table names and may include various SQL syntax elements such as joins, subqueries, and aliases. Write a function `extract_table_names(sql_query: str) -> List[st...
codefeedback
You are tasked with implementing a Sounding data structure in Rust to store atmospheric data from weather stations. The Sounding structure should allow for the storage of various atmospheric parameters such as source description, station information, valid time, pressure profile, height profile, temperature profile, de...
codefeedback
You are tasked with implementing a cipher storage factory that can generate instances of different types of ciphers. The factory should support the creation of instances for various types of ciphers, such as Caesar cipher, Vigenère cipher, and Substitution cipher. Each cipher instance should be capable of both encrypti...
codefeedback
You are given a Python class `Calculation` with the following methods: ```python class Calculation: def __init__(self, abs_calc, obs, calc): self.abs_calc = abs_calc self.obs = obs self.calc = calc def calculate(self, ac): if ac == 0: if self.obs == 0: ...
codefeedback
You are tasked with implementing a custom hook in React that will conditionally execute an effect only when the code is running in a browser environment. The custom hook should mimic the behavior of the built-in `useEffect` hook, but it should only run when the code is executed in a browser environment. You are provid...
codefeedback
You are tasked with implementing a command-line utility for slicing media files. The utility should accept a specified number of slices and a list of input files, and then proceed to cut each input file into the specified number of slices. Your task is to complete the implementation of the `main` function, which parse...
codefeedback
You are tasked with designing a URL shortening service using Python and MongoDB. The code snippet provided is a part of the data model for the shortened URLs. The `shortUrl` field stores the shortened URL, `date_submitted` records the date and time when the URL was submitted, and `usage` keeps track of the number of ti...
codefeedback
You are tasked with implementing a function that calculates the average of a list of floating-point numbers, excluding any outliers. An outlier is defined as a value that differs significantly from the rest of the data. In this case, a value is considered an outlier if it is not "close" to the average of the other valu...
codefeedback
You are tasked with creating a program that generates a 3D plot using a given dataset and specific plot settings. The program should take the dataset and plot settings as input and produce a PNG image of the 3D plot as output. The input will consist of the following: - A dataset, represented as an array of numerical v...
codefeedback
You are tasked with creating a Python function that processes file paths based on a given module name. The function should generate an ordered list of paths to look for the module in, considering various file extensions and package structures. Write a Python function `generate_module_paths` that takes in two parameter...
codefeedback
You are given a list of coordinate sets, where each coordinate set is represented as a list of tuples. Your task is to write a function to stack these coordinate sets in sequence vertically (row-wise) to create a 2D array. The length of each coordinate set varies, and the resulting 2D array should accommodate the maxim...
codefeedback
You are tasked with simulating a motion detection system using Python. The system will utilize a motion sensor to detect movement and count the number of times motion is detected. You are provided with a code snippet that initializes a motion sensor, waits for 30 seconds to allow the sensor to learn the environment, an...
codefeedback
You are tasked with implementing a function that processes a given array of strings and returns the longest common prefix among all the strings. The longest common prefix is the longest string that is a prefix of all the strings in the array. If there is no common prefix, an empty string should be returned. You are gi...
codefeedback
You are tasked with implementing a function to parse and extract data from an HTML table. The function should take an HTML string containing a table and return the data in a structured format. You are given the following HTML snippet as an example: ```html <table> <thead> <tr> <th>Name</th> <th>Age<...
codefeedback
You are given a string representing a series of parentheses. Your task is to determine if the parentheses are balanced. A string of parentheses is considered balanced if every opening parenthesis has a corresponding closing parenthesis and they are properly nested. Write a function `isBalancedParentheses` that takes a...
codefeedback
You are tasked with creating a Python function that processes a list of database migration operations and extracts specific information from it. The function should identify the names of the models being created and the dependencies they have on other models. You are given a list of migration operations, where each op...
codefeedback
You are tasked with implementing a Python function that processes a given list of strings and returns a new list containing only unique strings in the original list. However, the given code snippet contains a bug that prevents the function from working as intended. Your task is to identify and fix the bug in the code s...
codefeedback
You are given a Python class `MyClass` with a method `enum()` that returns an iterator over a sequence of elements. Your task is to implement a custom iterator that iterates over the elements returned by `MyClass.enum()` and returns the elements in reverse order. Your custom iterator class `ReverseIterator` should hav...
codefeedback
You are tasked with implementing a statistical calculation for a given probability distribution. The cumulative probability of a continuous random variable is the probability that the variable takes a value less than or equal to a given number. Your task is to create a program that calculates the cumulative probability...
codefeedback
You are tasked with implementing a Python decorator that validates the input arguments of a method in a class. The decorator should ensure that the method's input arguments are of a specific type and raise an error if the input does not match the expected type. Your task is to complete the implementation of the `input...
codefeedback
You are tasked with implementing a class that represents a resizable and rotatable element on a canvas. The class should have properties for position, width, height, rotation, minimum width, and minimum height. Additionally, it should provide a method to convert its properties to a model representation. Your task is t...
codefeedback
You are tasked with creating a program that analyzes a given C++ code snippet to identify and extract specific information. The code snippet provided is part of a larger program and contains comments and function calls. Your task is to write a program that can extract the following information from the code snippet: 1....
codefeedback
You are tasked with implementing a word guessing game. The game involves a function to process the user's input and another function to match the input with a hidden word and update the game state. You need to implement the following functions: 1. `process_input(input_guess: str) -> str`: This function takes a user's...
codefeedback
You are tasked with implementing a function to set up NAT port mapping using UPnP (Universal Plug and Play) protocol. The function should attempt to set up port mapping on multiple UPnP devices and handle any failures gracefully. You are given a code snippet that attempts to set up port mapping on UPnP devices. The sn...
codefeedback
You are working on a natural language processing (NLP) project and need to create a program to preprocess and classify movie reviews. The goal is to build a machine learning model that can accurately classify movie reviews as positive or negative based on their content. To achieve this, you need to preprocess the raw t...
codefeedback
You are given a string `stream` and its reverse `reverse`. Your task is to write a function to determine the length of the longest prefix of `stream` that is also a suffix of `reverse`. If there is no such prefix, the function should return -1. Write a function `longest_prefix_suffix(stream: str, reverse: str) -> int`...
codefeedback
You are tasked with creating a function that generates a random username for a new user. The username should consist of a combination of the user's first name and a random string of characters. The random string of characters should be of a specified length and can include uppercase letters, lowercase letters, and digi...
codefeedback
You are tasked with creating a program that allows users to search for a specific name within a list of names. The program should repeatedly prompt the user to enter a name until the user decides to quit by entering a blank name. The program should then search for the entered name within a predefined list of names and ...
codefeedback
You are tasked with creating a Python script that monitors a directory for changes and automatically reloads a web application when any HTML files in the directory are modified. You should implement a function that takes the directory path as input and continuously monitors it for changes. When an HTML file is added, r...
codefeedback
You are tasked with implementing a function to decode an image from a file in a C++ program. The function `DecodeImageFromFile` takes three parameters: the file path of the image, the width, and the height. The function should read the image file and decode it into the specified dimensions. However, the provided code s...
codefeedback
You are tasked with implementing a hash grid data structure that supports encoding and decoding of key-value pairs. The `HashEncoder` class provides methods for encoding and decoding data using a hash grid. The hash grid is a two-dimensional grid where each cell can store multiple key-value pairs. The `HashEncoder` cla...
codefeedback
You are tasked with implementing a download service for a wallpaper application called EarthWallpaper. The download service should be able to asynchronously download images from the internet and save them to the local storage. The provided code snippet outlines the beginning of the `DownloadService` class, which is exp...
codefeedback
You are working for a cybersecurity company that is developing a tool to recover corrupted files. Your task is to implement a function that takes a user's credentials and a password and returns a command line to execute a recovery process. You are given the following code snippet as a starting point: ```python def fi...
codefeedback
You are tasked with implementing a function that determines whether a given React component is being rendered on the server or the client. The function should return `true` if the component is being rendered on the server (i.e., when `window` is not defined), and `false` if it is being rendered on the client (i.e., whe...
codefeedback
You are tasked with creating a function that parses a given HTML code snippet and extracts the attributes of the anchor (`<a>`) tag. The function should return a dictionary containing the attributes and their corresponding values. The HTML code snippet to be parsed is as follows: ```html <div class="kt-subheader__tool...
codefeedback
You are working on a project that involves implementing a neural network generator using PyTorch. The given code snippet shows a class `Generator` that inherits from `BaseGenerator` and contains an `__init__` method. The `__init__` method initializes the generator with a series of layer configurations. Each configurati...
codefeedback
You are tasked with implementing a function that will parse a given HTML snippet and count the number of nested `<div>` elements within it. The function should return the total count of nested `<div>` elements. You are given the following HTML snippet as an example: ```html <div> <div> <div> </...
codefeedback
You are tasked with implementing a Python function that processes a list of strings and returns a dictionary containing the frequency of each word in the list. The function should ignore case sensitivity and consider only alphanumeric characters when counting the frequency of words. Additionally, the function should ex...
codefeedback
You are tasked with creating a program that simulates a simple game of rock-paper-scissors. The program should allow a user to input their choice (rock, paper, or scissors), generate a random choice for the computer, determine the winner based on the choices, and display the result. Your program should consist of the ...
codefeedback
You are tasked with implementing a function `takeRightWhile` that takes an array and a predicate function as input and returns a new array containing the elements from the end of the original array until the predicate function returns false. The original array should not be modified. If the predicate function is not pr...
codefeedback
You are tasked with implementing a function to parse and save information from a dictionary into a specific string format. The function should take a dictionary as input and return a string containing the key-value pairs in the format "[key1]value1|[key2]value2|...". However, the provided code snippet seems to have som...
codefeedback
You are tasked with creating a Python program to scrape job listings from the StackOverflow Job site and save the results to a CSV file. The code snippet provided initializes the output file and begins the scraping process. Your task is to complete the program by implementing the scraping logic and writing the job deta...
codefeedback
You are tasked with creating a Python function that manages the creation of directories for machine learning model storage. The function should take in the name of the model and create a new directory for that model within the specified directory. If a directory with the same name already exists, the function should ap...
codefeedback
You are tasked with creating a TypeScript class that simulates a simple repository for managing "Like" entities. The provided code snippet is a starting point for the repository class. Your task is to extend this class and implement additional functionality to manage the "Like" entities. Your task is to implement the ...
codefeedback
You are tasked with creating a Python Flask application that interacts with an external API to retrieve and display data. Your application should have a route that accepts a user's input, makes a request to an external API, processes the response, and returns the data to the user in JSON format. Your Flask application...
codefeedback
You are tasked with simulating the behavior of an Enigma machine rotor in a Python program. The Enigma machine was a cipher device used during World War II for encryption and decryption of secret messages. Each rotor in the machine had a specific wiring configuration, a ring setting, a starting position, and turnover p...
codefeedback
You are tasked with designing a system that integrates Amazon Web Services (AWS) Simple Queue Service (SQS) with AWS Lambda functions and Lambda destinations. Your goal is to create a system that efficiently processes messages from an SQS queue and routes the results to different destinations based on specific criteria...
codefeedback
You are tasked with implementing a virtual machine (VM) that can execute a set of instructions. The VM is responsible for interpreting and executing the instructions provided to it. The instructions are represented as a sequence of opcodes and operands. Each opcode represents a specific operation, and the operands prov...
codefeedback
You are working on a system that handles frequency inversion for a signal processing application. The code snippet provided is a part of a method in a class that manipulates an array representing the frequency inversion. The method `setUIntElement` is used to set a specific element in the array to a given value. The pa...
codefeedback
You are tasked with creating a Python function that processes messages from an Amazon Simple Queue Service (SQS) and updates a DynamoDB table with the message data. The function should extract the message body from the SQS event, parse it as JSON, and then update the DynamoDB table with the extracted data. Write a Pyt...
codefeedback