instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a kernel regression algorithm to predict the values of a target function based on a given set of input-output pairs. The algorithm involves generating a sample dataset and then using a design matrix to perform the regression.
You are provided with two functions:
1. `generate_sample(xm... | codefeedback |
You are tasked with creating a Python script that processes a HXL (Humanitarian Exchange Language) dataset to generate aggregate counts for specified column tags. HXL is a lightweight data standard for humanitarian information exchange. Your script should accept command-line arguments and process the input dataset from... | codefeedback |
You are tasked with creating a program that simulates a simple image processing application. The program should be able to apply a set of image filters to a given image. For this problem, you will implement a class that represents an image filter and apply it to an image.
You are given a code snippet that sets up the ... | codefeedback |
You are tasked with implementing a collision detection algorithm for two rectangular objects in a 2D space. The given code snippet provides the framework for detecting collisions between the two objects based on their physical maps. The physical maps are represented as 2D arrays, where each element corresponds to a spe... | codefeedback |
You are given a program that manipulates sets of integers. The program uses two sets, `v` and `u`, and performs operations on them. Your task is to understand the operations and write a function to replicate the behavior of the given code snippet.
The given code snippet is part of a larger program. The relevant part o... | codefeedback |
You are tasked with implementing a custom `equal` function that compares two ranges for equality. The `equal` function should take two ranges as input and return `true` if the ranges are equal, i.e., if they have the same elements in the same order, and `false` otherwise. The ranges can be of any type that supports ite... | codefeedback |
You are tasked with implementing a function to generate a data table based on the given parameters. The function `tu.gen_data_table` takes in several arguments: the number of rows `T`, a list of column names `Zv`, and a list of column distributions `Zc`. Each column distribution is represented by a list of distribution... | codefeedback |
You are tasked with implementing a function that takes a list of HTTP request objects and returns a dictionary containing the shared view contexts present in all the requests. Each request object is represented as a dictionary with keys representing the context variables and their corresponding values. The shared view ... | codefeedback |
You are working on a natural language processing (NLP) project and need to implement a masked softmax function for a neural network model. The function should compute the softmax of a given input vector, taking into account a binary mask that specifies which elements of the input vector should be considered in the comp... | codefeedback |
You are tasked with creating a Python function that generates a launch configuration for running experiments in a reinforcement learning framework. The function should take input parameters and produce an encoded affinity configuration for parallel processing, as well as a script and variants for the experiments.
You ... | codefeedback |
You are tasked with implementing a simple test runner for a processor architecture simulator. The test runner is responsible for executing a series of test cases for different instructions supported by the processor architecture. Each test case is identified by a unique string, and the test runner is expected to execut... | codefeedback |
You are tasked with creating a program to manage a pizza factory. The factory uses an abstract factory pattern to create different types of pizzas. Each pizza type requires specific ingredients such as dough, sauce, and cheese, which are created by an ingredient factory. Your task is to implement the classes and method... | codefeedback |
You are tasked with creating a program that simulates a simplified version of a package manager tool. The program should be able to handle the installation and updating of packages, as well as running a linter tool to check for code quality.
Your program should support the following commands:
1. `install <package>`: I... | codefeedback |
You are tasked with implementing a function `drop_cap` that takes a string as input and returns a modified version of the string with the following rules:
- The first letter of the string should be capitalized.
- Any word in the string that is longer than two characters should have its first letter capitalized.
- All o... | codefeedback |
You are tasked with creating a Django view that displays a user's friends in a web application. The `Friend` model is provided by the `friendship` app, and the `mark_safe` function from `django.utils.safestring` is used to mark a string as safe for HTML output.
Your task is to implement a Django view function that ret... | codefeedback |
You are tasked with implementing a Python class that processes and stores data related to an application monitoring system. The class should have methods to add new data and retrieve specific information. Below is a partial implementation of the class:
```python
class ApplicationData:
def __init__(self):
s... | codefeedback |
You are tasked with implementing a custom `StringBuilder` class in C++. The `StringBuilder` class should provide functionality to build and manipulate strings efficiently.
Your task is to complete the implementation of the `StringBuilder` class by adding the following member functions:
1. `append(const char* s)`: Thi... | codefeedback |
You are tasked with implementing a custom memory management system for a simple programming language. The system should support the allocation and deallocation of memory blocks and handle memory leaks by automatically releasing memory when it is no longer in use.
Your task is to create a class `MemoryManager` with the... | codefeedback |
You are tasked with implementing a Python class for evaluating generative models using pre-trained classifiers. The class, `GenerativeModelMetric`, is responsible for defining several metrics using pre-trained classifier inception v1 or v3. The class has an `__init__` method that takes in parameters such as `image_form... | codefeedback |
You are tasked with creating a Python program that simulates a simple game of rock-paper-scissors. The program should allow a user to play against the computer. The game should consist of a series of rounds, and the winner of each round should be determined based on the classic rules of rock-paper-scissors: rock beats ... | codefeedback |
You are tasked with implementing a custom learning rate scheduler for a deep learning model. The learning rate scheduler will adjust the learning rate of the optimizer at specified milestones during training. The learning rate will be adjusted according to a specified function and parameters.
You are given a code snip... | codefeedback |
You are tasked with creating a script that automates the user management process for a development environment. The script should take user input and use it to create a new user with specific configurations. Additionally, the script should then execute a command with the newly created user's privileges.
Write a Bash s... | codefeedback |
You are tasked with implementing a Particle Swarm Optimization (PSO) algorithm to optimize a given objective function. PSO is a population-based stochastic optimization algorithm inspired by the social behavior of birds flocking or fish schooling. In this problem, you will focus on the update mechanism of the PSO algor... | codefeedback |
You are tasked with implementing a class that manages the disposal of resources based on a given disposal policy. The disposal policy is represented by an enum called `DisposalPolicy`, which has three possible values: `Automatic`, `Manual`, and `Custom`. The class should handle the disposal of resources according to th... | codefeedback |
You are tasked with implementing a simple messaging system using local classes in Java. Your task is to create a class `MessageService` that allows users to send and receive messages. The `MessageService` class should have the following functionalities:
1. `sendMessage(String message, String recipient)`: A method that ... | codefeedback |
You are tasked with implementing a custom exception class and handling a specific exception scenario in Python. Your goal is to create a `ConfigException` class and modify the given code snippet to raise this exception when a `KeyError` is encountered.
Your task is to complete the following steps:
1. Create a `Config... | codefeedback |
You are given a 2D grid representing a map with obstacles. Each cell in the grid can be either empty (denoted by 0) or blocked by an obstacle (denoted by 1). You are also given the starting position (row, col) in the grid. Your task is to implement a function `explore` that recursively counts the number of reachable em... | codefeedback |
You are tasked with creating a program that can analyze the frequency of words in a given text. Your program should take a string of text as input and output a list of unique words along with their frequencies in descending order. For the purpose of this problem, a word is defined as any sequence of characters separate... | codefeedback |
You are tasked with implementing a function to retrieve nearby users based on their geographical coordinates. The given code snippet provides a partial implementation of the `get_nearby_users` function, which is intended to return a list of users located within a specified radius from a given longitude and latitude. Th... | codefeedback |
You are tasked with implementing a JSON parsing and conversion function for a custom application. The function should be able to handle various JSON structures and convert them into the appropriate data types. Your task is to create a JSON parsing and conversion function that can handle a specific JSON input and conver... | codefeedback |
You are tasked with creating a script to automate the deployment of a Docker container with specific environment variables and volume mounts. Your script should take two command-line arguments: the container name (`CNAME`) and the tag (`TAG`) for the Docker image. The script should then use `sudo` to run a Docker conta... | codefeedback |
You are tasked with implementing a control system for a software application. The control system uses a set of constants and bitwise operations to manage various settings. Your goal is to implement the `setKeepLazy` method, which sets the "KeepLazy" bit in the control integer and returns the updated value. Additionally... | codefeedback |
You are tasked with implementing a function to encode a list of integers into a string based on a specific encoding scheme. The function `encodeChars` takes an array of integers as input and returns a string based on the following rules:
- If the integer is positive, it represents the ASCII value of a character to be i... | codefeedback |
You are tasked with creating a Python class that can convert images from one format to another. Your class should be able to handle the conversion of images in various formats, such as JPEG, PNG, GIF, etc. The class should also provide methods for resizing and rotating the images.
Your task is to implement the `ImageC... | codefeedback |
You are tasked with creating a Python script that checks for the presence of a specific module and handles the case where the module is not found. Your script should import the module and, if it fails to do so, raise a custom exception with a descriptive error message. Additionally, the script should handle any other e... | codefeedback |
You are tasked with creating a Python class that simulates a command line interface. The class should have a method to execute commands, with the option to clear the screen before executing the command. Your task is to implement the `CommandLineInterface` class with the given specifications.
```python
import os
class... | codefeedback |
You are tasked with implementing a caching mechanism for web content retrieval. The provided code snippet outlines a simplified version of a caching class that retrieves and stores web content. The class has a method `get_content(url)` that takes a URL as input and returns the content of the webpage. The class also has... | codefeedback |
You are tasked with creating a Rust program that involves serializing and deserializing data using the `serde_yaml` crate. Your goal is to implement a custom serialization and deserialization process for a struct, while also handling a specific scenario involving skipping a field during serialization.
You are provided... | codefeedback |
You are tasked with implementing a simple data structure to store and manipulate decimal numbers. Your goal is to create a Rust program that defines a `NumberItem` struct and provides methods to perform basic operations on decimal values.
The `NumberItem` struct should have the following properties:
- `value`: A field... | codefeedback |
You are tasked with implementing a text matching system using two different strategies: AC Automaton and Trie Tree. The system should be able to efficiently match a given set of patterns against a given input text and return the positions of all matches.
You are given an enum `MatchStrategy` with two options: `AcAutom... | codefeedback |
You are tasked with implementing a text filtering system for a messaging application. The `applyTextFilter` function takes a `filterValue` as input and should apply the specified text filter to the messages. The text filter can be a string containing one or more filter rules separated by a delimiter. Each filter rule c... | codefeedback |
You are tasked with creating a Python class to manage instances and volumes in a cloud environment. The class should provide methods to perform various operations such as creating instances, attaching volumes, associating public IPs, and displaying setup results.
You are provided with the following code snippet as a s... | codefeedback |
You are tasked with implementing a priority queue for managing speech priorities in a communication system. The speech priorities are represented by the enum `SpeechPriority`, which is ordered from highest to lowest priority. The priority queue should support the following operations:
1. `enqueue(priority, speech)`: Ad... | codefeedback |
You are working on a computer vision project and need to implement a function to normalize an image using a specific formula. The formula for normalizing the image is given by:
\[ \frac{{\text{{meanSubtractedImage}}}}{{\sqrt{\sum_{i=1}^{n} \text{{meanSubtractedImage}}^2}}} \]
Where:
- \(\text{{meanSubtractedImage}}\)... | codefeedback |
You are tasked with creating a command-line utility that processes a series of commands related to a static site generator. The utility should support the following commands:
1. `jekyll build`: This command triggers the static site generator to build the site.
2. `jekyll build --drafts`: This command triggers the stat... | codefeedback |
You are tasked with creating a program that analyzes a given code snippet to identify and count the occurrences of specific patterns. The code snippet will consist of a series of lines, each containing a mix of alphanumeric characters, punctuation, and whitespace. Your program should be able to identify and count the o... | codefeedback |
You are tasked with implementing a simple observer pattern in C++. The observer pattern is a behavioral design pattern that defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Your goal is to create a class that allows observ... | codefeedback |
You are tasked with implementing a Python class method that processes input graphs based on a specified message function. The method should handle two different scenarios for obtaining edge vectors based on the chosen message function.
You are given a code snippet from the method as follows:
```python
input_graphs = e... | codefeedback |
You are given a Python code snippet representing a list of database comparisons. Each comparison is represented as an object with attributes `id`, `state`, `time`, and `comparison_type_id`. The `time` attribute is a `datetime` object representing the time of the comparison. Your task is to write a function that takes t... | codefeedback |
You are tasked with creating a Python function that simulates the dependency resolution process for a series of migrations in a Django project. In Django, migrations are used to propagate changes made to the models in a database schema. Each migration can depend on one or more other migrations, and it's essential to re... | codefeedback |
You are tasked with implementing a simplified version of a graphics application using the ImGui library. The application uses ImGui for creating a user interface and rendering tools for manipulating a 3D model view. Your goal is to create a class that manages the model view and allows different tools to draw on it.
Yo... | codefeedback |
You are tasked with implementing a custom set data structure in Rust. The set should support adding elements, removing elements, checking for membership, and obtaining the size of the set. Additionally, you need to implement a method to create a new set that is the union of two existing sets.
Your task is to complete ... | codefeedback |
You are tasked with creating a PHP class that interacts with a database using the CodeIgniter framework. Your class should have methods to perform basic database operations such as inserting, updating, and retrieving data. Additionally, you need to ensure that the database connection is established when the class is in... | codefeedback |
You are tasked with implementing a simple game where a player navigates through a maze while avoiding traps. The game environment consists of a grid, and the player can move up, down, left, or right within the grid. The traps are randomly placed within the grid, and the density of traps is controlled by the `trap_densi... | codefeedback |
You are tasked with implementing a Python function that processes data from a scientific simulation software. The function should take in a list of data representations and return a dictionary containing specific information about the data representations.
The input to the function will be a list of dictionaries, wher... | codefeedback |
You are tasked with creating a Python utility to manage network interfaces and perform ARP spoofing for a security tool. The utility will handle various operations such as starting, stopping, and deleting ARP spoofing threads, as well as viewing the spoofed IP addresses as IPv4 addresses. Additionally, it will provide ... | codefeedback |
You are tasked with creating a PHP function that retrieves data from a MySQL database and processes it to generate a specific output. The function should connect to the database, execute a query to retrieve data from a table, and then process the retrieved data to generate a specific result.
Write a PHP function calle... | codefeedback |
You are tasked with implementing a custom encoding system for a command-line argument parser in Swift. The given code snippet is part of a larger program that encodes options and flags for command-line arguments. The `codingPath` is a property that represents the path to the current encoding context, and `key` is a var... | codefeedback |
You are tasked with creating a Python function that filters a pandas DataFrame based on a specified threshold and saves the filtered data to a new file. The function should take the DataFrame, the column name to filter on, and the threshold as input parameters.
The function should perform the following steps:
1. Filte... | codefeedback |
You are tasked with implementing a simple inventory management system for a fictional beverage company called Grog 2500. The company wants to keep track of the quantity of each beverage in stock and be able to perform operations such as adding new beverages, updating quantities, and retrieving the current stock levels.... | codefeedback |
You are tasked with implementing a custom version of the `grapheme_strpos` function in PHP. The `grapheme_strpos` function is used to find the numeric position of the first occurrence of a specified substring within a string. However, it differs from the standard `strpos` function in that it operates on a grapheme leve... | codefeedback |
You are tasked with creating a Python script to automate the process of retrieving and displaying a list of deleted Azure Cognitive Services accounts using the Azure CLI. The Azure CLI command `az cognitiveservices account list-deleted -o table` is used to list the deleted Cognitive Services accounts in a tabular forma... | codefeedback |
You are tasked with implementing a C++ function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take two integer parameters, `start` and `end`, representing the inclusive range... | codefeedback |
You are tasked with implementing a function to split a list of strings into individual phrases. Each string may contain multiple phrases separated by periods. Your task is to create a function `splitByPhrases(lines)` that takes a list of strings `lines` as input and returns a dictionary where the keys are the indices o... | codefeedback |
You are tasked with creating a script to automate the installation of various Node.js packages and tools for frontend development. The script should check for the presence of Node.js and install a package manager before proceeding with the installation of several essential frontend development tools.
Your task is to w... | codefeedback |
You are tasked with creating a Python function that manipulates file paths. Your function should take a base directory path and a file name as input and return a modified file path. The modification involves handling the case where the file already exists in the specified directory. If the file exists, the function sho... | codefeedback |
You are tasked with implementing a function to calculate the sum of all the even Fibonacci numbers up to a given limit. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, typically starting with 0 and 1. The first few numbers in the Fibonacci sequence are 0, 1, 1, 2... | codefeedback |
You are tasked with creating a Python program that processes sound analysis data from a JSON file and generates a plot based on the specified key.
Your program should take the following command-line arguments:
- `-in` (or `--INPUT_FILE`): Path to the input sound analysis JSON file. Default value is "data/still_i_rise_... | codefeedback |
You are tasked with implementing a custom stack data structure in Python. The stack should support the following operations:
1. `push(val)`: Add an element `val` to the top of the stack.
2. `pop()`: Remove and return the element at the top of the stack. If the stack is empty, return None.
3. `peek()`: Return the elemen... | codefeedback |
You are working on a project that involves processing astronomical data using the FITS (Flexible Image Transport System) format. As part of this project, you need to create a function that generates a FITS World Coordinate System (WCS) object with specific properties.
Write a Python function `generate_fits_wcs` that t... | codefeedback |
You are tasked with simulating a simplified version of a GPIO (General Purpose Input/Output) event detection system. In this system, you will need to implement a class that allows users to register event detection on specific GPIO channels and associate callback functions to be executed when the event occurs.
Your tas... | codefeedback |
You are tasked with implementing a database schema in a Python application using the SQLAlchemy library. The schema includes a parent model and one or more related models. When any record in a related model is updated or deleted, the referential actions on the relations cascade to the parent model through multiple path... | codefeedback |
You are tasked with implementing a function that parses a list of JavaScript test cases and extracts the descriptions of the pending tests. Each test case is represented as a string in the format "it.todo('TODO: <description>')", where <description> is the pending test description enclosed in single quotes. Your functi... | codefeedback |
You are tasked with implementing a custom viewset for managing offensive messages in a Django REST framework application. The provided code snippet shows an incomplete implementation of the `OffensiveMessageViewSet` class, which is intended to be a subclass of `GenericViewSet`. The `OffensiveMessage` model and `Offensi... | codefeedback |
You are tasked with implementing a server program that can handle UDP datagrams. The provided code snippet initializes a socket for UDP communication and sets some socket options. Your task is to complete the server program by adding the necessary code to receive and process incoming UDP datagrams.
Your server program... | codefeedback |
You are tasked with implementing a multithreaded program that simulates a clock with open and close states. The program should have two threads: one for opening the clock and one for closing it. The opening thread should wait for 2 seconds before closing the clock, while the closing thread should wait for 3 seconds bef... | codefeedback |
You are tasked with implementing a class to manage named pipes in a multi-threaded environment. Named pipes are a form of inter-process communication, allowing processes to communicate with each other. Your task is to create a `NamedPipeSpec` class that encapsulates the behavior of a named pipe.
The `NamedPipeSpec` cl... | 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 turns have the same score, the player's score is doubled instead. Your task is to write a function that calculates the final score of the... | codefeedback |
You are tasked with implementing a class that filters and processes system configurations based on certain criteria. The class `SystemsManagerConfigurationSource` is responsible for managing system configurations and providing methods to filter and process them. Your goal is to implement the method `FiltersInitializedT... | codefeedback |
You are tasked with creating a script to automate the execution of certain programs based on user input. The script should prompt the user for input and then execute specific programs based on the user's choices.
You are given a code snippet from an existing script as inspiration:
```
make '-f' 'PhotoMake'
f... | codefeedback |
You are tasked with creating a Python class that implements a simple caching mechanism for storing and retrieving process details. The class should allow for the caching of process details and provide methods for adding, retrieving, and clearing the cache. The process details should be stored in a dictionary with the p... | codefeedback |
You are tasked with creating a program that processes a given source code file and generates a modified version of the file. The program should remove any trailing whitespace and comments from each line of the source code. Additionally, it should add a prefix and suffix to each line, and then write the modified lines t... | codefeedback |
You are tasked with creating a Python function that simulates a simplified version of the `nmap_ssh` tool used for scanning SSH services with corresponding NSE (Nmap Scripting Engine) scripts. Your function should take in the target host and port as input and execute the necessary Nmap commands to perform the SSH servi... | codefeedback |
You are tasked with creating a custom tab layout for a dashboard using React and Material-UI. The provided code snippet includes an interface definition and the use of the `makeStyles` hook from Material-UI. Your goal is to implement the tab layout component and apply the defined styles to achieve the desired dashboard... | codefeedback |
You are tasked with creating a Python class that simulates a network packet and provides methods to manipulate its attributes. The class should have the following attributes: `ctag`, `stag`, `dst`, `dryrun`, `hexdump`, `interface`, and `etype`. You need to implement the class constructor to initialize these attributes ... | codefeedback |
You are tasked with implementing a notification system that processes messages and sends notifications based on the method specified in the message. The system should be able to handle email notifications, with the potential for future expansion to include other notification methods such as phone text messages.
You ar... | codefeedback |
You are tasked with implementing a player movement and rotation system in a 3D game. The player's movement speed should be dynamically adjusted based on whether they are walking or running, and their direction of movement. Additionally, the player should smoothly rotate along the y-axis as they move. You are provided w... | codefeedback |
You are tasked with implementing a payment processing system using PHP and cURL. The given code snippet is a part of the payment processing logic. Your task is to complete the implementation by creating a function that constructs the payment request URL and sends it using cURL.
You are provided with the following info... | codefeedback |
You are tasked with implementing a simple asynchronous document indexing system using Rust's Tokio library. The system will receive documents, process them, and allow users to search for indexed documents. Your task is to implement the necessary data structures and functions to achieve this functionality.
You are prov... | codefeedback |
You are tasked with implementing a dynamic updater for a shape manipulation program. The program has a class with the following methods:
```java
public void setValue(String stringValue)
public Node makeDynamicUpdater()
```
The `setValue` method takes a string `stringValue` as input and sets the value of the shape usi... | codefeedback |
You are given a Java method that is intended to check if a given number is a prime number. However, the method is incomplete and contains a code snippet that needs to be filled in. Your task is to complete the method by filling in the missing code snippet to correctly determine whether the given number is a prime numbe... | codefeedback |
You are tasked with implementing a custom URL routing system for a web application using Python and Django. The provided code snippet is a part of the URL configuration in a Django project. The `urlpatterns` list contains a single URL pattern defined using the `path` function. The pattern is associated with a view set ... | codefeedback |
You are working on a simulation program for modeling the velocity and mass distribution of celestial bodies in space. The given code snippet is a part of the program that calculates the incremental mass at different radii and plots it against the radius. Your task is to complete the program by implementing the missing ... | codefeedback |
You are given a Java class representing a simple data structure. Your task is to complete the class by implementing a method that calculates the sum of all the elements in a given array. The method signature is as follows:
```java
public int calculateSum(int[] arr)
```
The method should take an integer array `arr` as... | codefeedback |
You are working on a software project that involves various task management components. One of the key functionalities is to handle interactions, execute jobs, and manage the restart of an office application. The code snippet provided includes imports from different modules related to these functionalities. Your task i... | codefeedback |
You are tasked with implementing a simple plugin system for a chatbot application. The chatbot has a `bot` object, and the plugin system allows for adding various functionalities to the bot. Each plugin is a separate module that can be dynamically loaded into the bot. The `bot.add_plugin` function is used to add a new ... | codefeedback |
You are tasked with creating a Bash script that processes command-line arguments to perform specific actions based on the input. The script should handle two options: `-l` and any other input. When the script is invoked with the `-l` option, it should enter a loop, and for any other input, it should display a usage mes... | codefeedback |
You are tasked with implementing a function to perform a long-range scan in a space exploration game. The function `l_range_scan` takes two parameters: `the_game`, a mutable reference to the game state, and `sout`, a mutable reference to a writer for output. The function returns a `StResult` representing the success or... | codefeedback |
You are tasked with implementing a custom neural network architecture for image classification using PyTorch. The provided code snippet is a partial implementation of a Convolutional Neural Network (CNN) class. Your task is to complete the implementation of the CNN class by defining the forward pass method and ensuring... | codefeedback |
You are tasked with developing a Flask web application that includes various configuration settings for the application, such as database connection, secret key, email server settings, language options, and other parameters. The code snippet provided includes a partial configuration file for the application. Your task ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.