instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
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 highest and lowest scores.
Write a function `calculate_average_score(scores)` that takes in a list of integers `scores` (2 <= len(scores) <= 100) and returns... | codefeedback |
You are tasked with creating a test case for a web application using the CodeceptJS testing framework. The provided code snippet is a part of a test script written in CodeceptJS, a popular end-to-end testing framework for Node.js. The script is designed to automate the testing of a web page, specifically interacting wi... | codefeedback |
You are tasked with creating a PHP class that manages a collection of books. The class should allow for adding new books, removing existing books, and retrieving information about the books in the collection. Additionally, the class should provide a method to calculate the average rating of all the books in the collect... | codefeedback |
You are tasked with implementing a function that calculates the shortest path between two nodes in a graph using the Breadth-First Search (BFS) algorithm. The graph is represented using an adjacency list.
You are given the following function signature:
```python
def shortest_path_bfs(graph: Dict[int, List[int]], start... | codefeedback |
You are tasked with implementing a stochastic differential equation (SDE) solver for a specific SDE. The SDE is given by the following equation:
\[ dX_t = -0.5a^2 X_t dt - a\sqrt{1 - (X_t)^2} dW_t \]
where \( X_t \) is the stochastic process, \( a \) is a constant, \( dt \) is the differential time increment, and \( dW... | codefeedback |
You are given a grid with m rows and n columns. You are initially located at the top-left corner of the grid. You need to reach the bottom-right corner of the grid. In each step, you can move either down or right. You need to find the total number of unique paths to reach the bottom-right corner.
Write a function `uni... | codefeedback |
You are tasked with implementing a function that calculates the contrast ratio between two given colors. The contrast ratio is a measure of the difference in luminance or color that makes text or images distinguishable from the background. The formula for calculating the contrast ratio between two colors is defined as:... | codefeedback |
You are tasked with implementing a TypeScript type checker for a simplified version of the `PropType` interface used in React for defining the types of component props. The `PropType` interface can have different types of elements, such as primitive types, arrays, objects, and intersections.
Your task is to define a T... | codefeedback |
You are tasked with implementing a custom data structure called `Indexable` that supports slicing, assignment, and deletion operations. The `Indexable` data structure should behave similarly to Python's built-in list data structure, but with some custom behavior.
The `Indexable` data structure should support the follo... | codefeedback |
You are tasked with implementing a class for solving optimization problems using the Conjugate Gradient method. The class `Conj` is designed to handle functions for automatic differentiation, particularly in the context of PyTorch. Your goal is to complete the implementation of the `solve` method within the `Conj` clas... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm to train an agent to navigate a grid-based environment. The environment is represented by a map, and the agent uses the SARSA (State-Action-Reward-State-Action) algorithm with softmax policy to learn an optimal policy. The code snippet provided demonst... | codefeedback |
You are tasked with implementing a generic function that retrieves a scalar value from a given position in an array. The function should handle potential errors by returning the retrieved value if successful, or `nil` if an error occurs.
You are provided with the following code snippet as a reference:
```swift
let pos... | codefeedback |
You are tasked with simulating the behavior of a text entry field with specific operations. You are given a code snippet that demonstrates a series of actions performed on a text entry field and the corresponding assertions made on the displayed text. Your task is to implement a program that can accurately simulate the... | codefeedback |
You are working on a genetic algorithm for optimizing solutions to a problem. The algorithm involves creating mutant solutions based on existing ones and evaluating their fitness. You are given a code snippet that represents a part of the genetic algorithm process. Your task is to implement a function that generates a ... | codefeedback |
You are tasked with implementing a function to retrieve the number of processes in a local communicator using the Message Passing Interface (MPI) library. The provided code snippet is part of a larger codebase for a parallel message passing library called pMR. Your task is to complete the implementation of the `getLoca... | codefeedback |
You are given a Python function `max_in_channel(batch)` which takes a 3D NumPy array `batch` representing a batch of images. Each image in the batch is represented as a 3D array with dimensions (height, width, channels). The function is intended to find the maximum value in every channel for each image in the batch and... | codefeedback |
You are tasked with creating a script to automate the deployment of a Node.js application using PM2. PM2 is a process manager for Node.js applications that allows you to manage application processes, monitor their status, and easily restart them if necessary. Your script should perform the following tasks:
1. Change t... | codefeedback |
You are tasked with implementing an efficient primality check function that can determine whether a given number is prime or not. However, the twist is that you need to use the "almost certain" primality check method, which is a probabilistic algorithm that provides a high degree of certainty in identifying prime numbe... | codefeedback |
You are tasked with implementing a CUDA kernel for IPv6 route lookup. The IPv6 route lookup is a critical operation in networking, where the kernel is responsible for efficiently searching a routing table to determine the appropriate next hop for a given IPv6 destination address. Your goal is to design and implement a ... | codefeedback |
You are tasked with implementing a custom metric calculation for a neural network validation process. The given code snippet is a part of a larger neural network training and validation process. The code snippet is responsible for updating and recording the validation metrics during the validation step of the training ... | codefeedback |
You are tasked with implementing a queue system for sending emails in a Laravel application. The code snippet provided is a simplified version of a Laravel route setup. When a user visits the `/test-queues` route, an email is queued to be sent using Laravel's built-in mail functionality. Your task is to create a queue ... | codefeedback |
You are tasked with creating a Python script that processes data from multiple CSV files and performs specific operations on the data. The script should read all CSV files from a specified directory, extract relevant information, and then output the processed data to a new CSV file.
The script should perform the follo... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. The program should read the text file, identify the specified words, and then output the count of each word. Additionally, the program should handle any punctuation marks or special characters that may be ... | codefeedback |
You are tasked with creating a simple testing framework for a serverless runtime environment. The runtime environment allows users to define and invoke functions, and the testing framework should verify the correctness of these functions. The provided code snippet is a part of the testing framework and demonstrates the... | codefeedback |
You are tasked with creating a script to automate the execution of a command-line tool called `infracost`. The script should read the value of a variable `infracost_cmd`, append the `--usage-file` flag followed by the value of another variable `usage_file`, and then store the resulting command in a file called `infraco... | codefeedback |
You are tasked with creating a Python class that performs data validation and serialization for a health check system. The system monitors various nodes and their health status, recording the time of the check, the status, and additional information. Your task is to implement a class that uses the Marshmallow library t... | codefeedback |
You are tasked with creating a Python function that simulates the process of purchasing rubber ducks from an e-commerce website using Selenium. The function should handle the selection of different types of rubber ducks and ensure that the same type of duck is not purchased more than once. The function should return a ... | codefeedback |
You are tasked with implementing a function that calculates the total number of unique ways to climb a staircase. You are given a set of distinct steps that can be taken at a time, and the staircase has a total of n steps. You can climb the staircase by taking one or more steps at a time, and the order in which you tak... | codefeedback |
You are tasked with creating a program to manage a shopping cart for a group of users. The program should allow users to add, remove, and view items in their cart. Each user's cart will be identified by their first and last name. The program should also provide an option to view all the items in all the carts.
You are... | codefeedback |
You are tasked with creating a program that parses and extracts metadata from an HTML file. The metadata is contained within the `<meta>` tags and `<title>` tag. The metadata includes the character set, viewport settings, description, author, and keywords. Your program should extract this information and store it in a ... | codefeedback |
You are tasked with creating a script that automates the generation of documentation for a research paper repository. The script should utilize the `scribble` tool to convert a source file written in Scribble language into both Markdown and HTML formats. The Markdown file should be named `README.md` and placed in the `... | codefeedback |
You are tasked with creating a program that analyzes a given software license text to extract and count the occurrences of unique words. The software license text is a multi-line string containing the license terms and conditions. Each word is separated by whitespace and punctuation marks should be ignored.
Write a fu... | codefeedback |
You are tasked with creating a Python class that manages a machine learning model. The class should have properties for accessing the learning model and for determining whether the learning process should be initiated. Additionally, the class should include an internal method for reading a bibliography file. Your task ... | codefeedback |
You are tasked with implementing a function to generate a 64-bit random bitboard with a few set bits. A bitboard is a data structure commonly used in chess engines to represent the state of the game board. It uses a 64-bit integer to represent the 64 squares on a chessboard, with each bit indicating the presence or abs... | codefeedback |
You are tasked with implementing a class hierarchy for an employee management system. The system should support different types of employees, such as salesmen, managers, and engineers. Each employee type has a unique identifier associated with it. Your task is to design and implement the necessary classes and methods t... | codefeedback |
You are working on a project that involves importing various modules and packages in Python. Your task is to create a function that analyzes the imported modules and returns a dictionary containing the count of unique modules imported from each package.
Write a function called `analyze_imports` that takes no parameter... | codefeedback |
You are tasked with implementing the `mix_columns` function for a block cipher algorithm. The `mix_columns` function operates on a 4x4 matrix of bytes, representing a state in the cipher. The function applies a specific transformation to each column of the matrix. The provided code snippet shows a high-level overview o... | codefeedback |
You are tasked with implementing a Python function that takes a list of integers as input and returns the maximum sum of a contiguous subarray within the input list.
You need to implement the function `max_subarray_sum` with the following signature:
```python
def max_subarray_sum(nums: List[int]) -> int:
pass
```... | codefeedback |
You are tasked with implementing a Python function that performs a local Moran's I analysis on a given set of observations. The function should take in the observations, weights matrix, and other optional parameters, and return the observed local G values, corresponding p-values, and Monte Carlo p-values for each obser... | codefeedback |
You are tasked with implementing a function that takes a list of integers and returns a new list with each integer squared. However, there is a catch - you are not allowed to use the built-in `map` function or list comprehensions. You must implement the mapping functionality from scratch using a higher-order function.
... | codefeedback |
You are tasked with implementing a car factory system that produces different types of cars. The system should have the ability to create various car models with specific features. Your task is to extend the provided `AbstractCarFactory` class and implement the creation of two specific car models: "Sedan" and "SUV". Ea... | codefeedback |
You are tasked with creating a custom permission class for a Django REST framework API. The custom permission class, named `IsOwner`, should restrict access to objects based on whether the requesting user is the owner of the object. The permission should allow safe methods (GET, HEAD, OPTIONS) for all users, but only a... | codefeedback |
You are tasked with creating a Rust macro that processes a given input and generates a specific output. The macro should take a list of integers as input and produce a new list where each element is the square of the corresponding element in the input list. For example, if the input list is `[1, 2, 3]`, the macro shoul... | codefeedback |
You are tasked with implementing a custom memory allocator for a specific data structure. The data structure, `Struct`, is defined as follows:
```cpp
struct Struct {
int data1;
char data2;
double data3;
};
```
Your goal is to create a memory allocator that can efficiently allocate memory for instances of ... | codefeedback |
You are tasked with creating a program to classify handwritten digits using the popular MNIST dataset. The MNIST dataset consists of 28x28 pixel grayscale images of handwritten digits (0-9). Your goal is to build a classifier using the Support Vector Machine (SVM) algorithm to accurately predict the digit represented b... | codefeedback |
You are tasked with simulating a simple board game using Python. The game involves two players, each with a position on a circular board with 10 spaces numbered from 1 to 10. The players take turns rolling a six-sided die and moving their positions accordingly. The game ends when one of the players reaches a certain sc... | codefeedback |
You are tasked with implementing a user repository class in Swift that interacts with a Core Data persistent store. The provided code snippet includes a partial implementation of a `UserRepository` class and a `NSPersistentContainer` setup. Your task is to complete the implementation of the `UserRepository` class by ad... | codefeedback |
You are tasked with implementing a custom date handling class in C#. The class should have a property `ClientDate` of type `DateTimeOffset`, which represents the date and time of a client's request. However, there is a requirement to add a validation rule to ensure that the `ClientDate` property cannot be set to a date... | codefeedback |
You are tasked with creating a Rust library that provides a unified HTTP client interface for making requests using either the `isahc` or `reqwest` libraries based on different features. The code snippet provided shows a part of the library's source code, where the HTTP client is conditionally imported based on the ena... | codefeedback |
You are given a list of integers representing the strength of different characters. The strength of a character is denoted by an integer value. You need to calculate the cumulative strength of all characters up to each position in the list and return the sum of these cumulative strengths modulo 10^9 + 7.
For example, ... | codefeedback |
You are given a directed graph represented by a list of edges. Each edge is a tuple (source, destination) where source and destination are integers representing the nodes. Your task is to implement a function to detect if the given graph contains a cycle.
Write a function `bool HasCycle(List<Tuple<int, int>> edges)` t... | codefeedback |
You are tasked with implementing a Python class for managing datasets and plotting options. The class should have the ability to load datasets from a file and store the selected dataset and application options. Your task is to complete the implementation of the class by adding methods for loading datasets, selecting ap... | codefeedback |
You are tasked with implementing a Java class that represents a simplified version of a programming language's abstract syntax tree (AST) node for a method reference. The class should contain methods to retrieve the referenced element and to determine if the method reference is inside an anonymous context.
Your task i... | codefeedback |
You are tasked with creating a Python function that interacts with the Twitter API to retrieve and process user information. The function will take in a list of user IDs and return a dictionary containing the user IDs as keys and their corresponding screen names as values. You are provided with a code snippet that sets... | codefeedback |
You are tasked with creating a Java class that manages connections to a database. Your class, `DatabaseManager`, should have methods to establish a connection, execute a query, and close the connection. The class should handle exceptions gracefully and ensure that resources are properly released.
Your task is to imple... | codefeedback |
You are tasked with creating a Python program that simulates a simple game of rock-paper-scissors. The game should allow a user to input their choice (rock, paper, or scissors), and then randomly generate a choice for the computer. After both choices are made, the program should determine the winner based on the classi... | codefeedback |
You are tasked with creating a script to manage the expiration of repository whitelists in a CernVM-FS (CVMFS) storage system. The provided code snippet is part of a larger script and contains logic for checking the expiration date of the whitelist and recreating it if necessary. Your task is to implement a function th... | codefeedback |
You are tasked with creating a Python program that generates SVG drawings based on a set of given parameters. The program should be able to create various shapes and apply different styling attributes to them. Your task is to implement a class called `SVGShape` with the following methods:
1. `__init__(self, shape_type... | codefeedback |
You are tasked with implementing a function that calculates the absolute path to an instance's private path/area. The private path/area is represented as a string containing a sequence of directory names separated by slashes. The function should return the absolute path by resolving any relative paths (e.g., "..") and ... | codefeedback |
You are tasked with implementing a simple key-value store using the Rust programming language. The key-value store will be backed by a file in the Content Addressable Storage (CAR) format. The provided code snippet is a partial implementation of the `get` method for this key-value store. Your task is to complete the im... | codefeedback |
You are tasked with creating a script to automate the setup of a chroot environment for a Linux system. The chroot environment is a way to run a program with a different root directory than the current one. The script should perform the following tasks:
1. Check if the rootfs directory exists. If it does not exist, th... | codefeedback |
You are tasked with implementing a class for ending a transform feedback operation in a graphics library. The class, `GLOperationEndTransformFeedback`, is responsible for managing the end of a transform feedback process in OpenGL. It contains properties and a constructor for setting up the necessary objects and buffers... | codefeedback |
You are tasked with implementing a data structure to efficiently store and retrieve plant names based on their characteristics. The data structure should support adding new plant names, removing existing ones, and searching for plant names based on specific characteristics.
Your task is to implement a class `PlantData... | codefeedback |
You are tasked with creating a Python script that processes command-line arguments using the `argparse` module. Your script should accept a custom command-line option `--install-dir` and use the provided directory path or the default value if not specified. Additionally, the script should perform a specific action base... | codefeedback |
You are tasked with implementing a Connect Four game using Python. Connect Four is a two-player connection game in which the players first choose a color and then take turns dropping colored discs from the top into a vertically suspended grid. The pieces fall straight down, occupying the lowest available space within t... | codefeedback |
You are tasked with implementing a complex number class in C++. The complex number class should support the following operations: addition, subtraction, multiplication, division, and output stream insertion. The class should also have a default constructor that initializes the complex number to (0, 0) and a parameteriz... | codefeedback |
You are tasked with implementing a service class in Angular that handles requests to an external API for retrieving medical diagnostic codes. The service class should be responsible for making HTTP requests to the API and processing the response data. Additionally, it should handle the cleanup of any pending requests w... | codefeedback |
You are working on a simulation model for an ecosystem, which involves tracking the pools of various species. Each species has different pools such as spool, rpool, and dissolved. You have a function that is supposed to append these pools to a list `y0` based on the species index. However, the code snippet provided see... | codefeedback |
You are tasked with implementing a custom error handling mechanism in Rust for a system that interacts with various hardware components. The system has different types of hardware errors, such as `PwmConfigurationError` and `UartConfigError`, and you need to define a custom error type `AppError` that can represent thes... | codefeedback |
You are working on a project to control a motor using a library called EPOS. The code snippet provided is a part of the Python script that interacts with the EPOS library. Your task is to complete the implementation of a function to close the EPOS motor and retrieve its current.
You are given the following incomplete ... | codefeedback |
You are tasked with creating a program that processes a given license file and extracts relevant information from it. The license file follows a specific format, and your program needs to parse the file and extract the name, copyright year, version, and license type.
The license file format is as follows:
```
# The MI... | codefeedback |
You are tasked with implementing a Python program that interacts with a gRPC-based blockchain network. The program will be responsible for querying and updating the blockchain ledger using the provided gRPC client library.
Your task is to create a Python class `BlockchainClient` that encapsulates the functionality to ... | codefeedback |
You are tasked with implementing a data encryption and decryption system using the following specifications. The encryption method takes a byte array of data, a password, and the number of hash passes as input and returns the encrypted version of the data. The password is hashed using SHA-256 and the resulting binary i... | codefeedback |
You are tasked with creating a Python program to process and display vector field images using the PySimpleGUI library. The given code snippet demonstrates a part of the program that generates and displays a vector field image. Your task is to complete the program by implementing the necessary functions to process and ... | codefeedback |
You are working on a project that involves processing synthetic aperture radar (SAR) data from ICEYE satellites. Your task is to write a Python function to extract specific information from the SAR data files and perform some computations. The code snippet provided gives a glimpse of the existing codebase and the main ... | codefeedback |
You are tasked with implementing a data recording system for a robotic vehicle that navigates a track with multiple sensors. The sensors are labeled from `SENSOR_TRACK_EDGE_4` to `SENSOR_TRACK_EDGE_16`. Each sensor records the distance from the vehicle to the edge of the track. Your goal is to process the sensor data a... | codefeedback |
You are tasked with creating a PowerShell function to determine the sharing permissions for a SharePoint site. The function should take in the site URL as a parameter and return a boolean value indicating whether non-owners of the site are allowed to share content.
Write a PowerShell function named `Get-PnPSharingForN... | codefeedback |
You are tasked with creating a SwiftUI view that represents a customized letter "Q" inside a circle. The letter "Q" should be displayed in a specific font and color, and the circle should have a gray stroke with a specified line width. Your task is to implement the SwiftUI code to achieve this visual representation.
Y... | codefeedback |
You are tasked with creating a PHP class that interacts with a database to retrieve and manipulate branch information. The class should include methods for reading all branches and retrieving email addresses based on a given union name.
Your task is to complete the PHP class `BranchController` by implementing the foll... | codefeedback |
You are tasked with implementing a function that processes a set of playing cards and determines the highest poker hand that can be formed from the given cards. The function should take a list of playing cards as input and return the highest poker hand that can be formed.
Each playing card is represented as a string w... | codefeedback |
You are tasked with creating a Python class that interacts with a ZeroMQ connector for MetaTrader 4 (MT4) trading platform. The ZeroMQ connector allows communication between Python and MT4 for real-time trading and data exchange. Your task is to implement a Python class that utilizes the `DWX_ZeroMQ_Connector` from the... | codefeedback |
You are tasked with implementing 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 log all transactions using a logger.
Your task is to complete the implementation of the `BankAcco... | codefeedback |
You are tasked with creating a program that processes a given Bash script and extracts specific information from it. The Bash script is used for testing in a project repository and contains comments, commands, and potentially other content. Your program needs to extract the following information from the script:
1. The... | codefeedback |
You are tasked with implementing a Python class method that processes image data for a computer vision application. The method is responsible for checking the jitter of the input images and logging a warning if the jitter exceeds a certain threshold. Additionally, the method needs to set up the input and output data st... | codefeedback |
You are tasked with implementing a function to count the occurrences of a specific value within an array. The function should take in an array of integers and the value to be counted, and return the number of times the value appears in the array.
You are given the following code snippet as a starting point:
```c
//pr... | codefeedback |
You are working on a system that handles email delivery using the SES (Simple Email Service) platform. The code snippet provided is a part of the system's functionality for handling recipient complaints. The `SESMailDelivery` model represents the delivery status of an email, and the `recipients_complaint` is a signal t... | codefeedback |
You are tasked with creating a Python program to simulate a simple dice game. The game involves rolling a standard six-sided die multiple times and keeping track of the outcomes. The program should allow the user to specify the number of dice rolls and then simulate the rolls accordingly. Additionally, the program shou... | codefeedback |
You are tasked with implementing a program that processes a list of time intervals and returns the maximum number of overlapping intervals at any point in time. An interval is represented by a pair of integers denoting the start and end times. The program should take a list of intervals as input and output the maximum ... | codefeedback |
You are tasked with implementing a command-line argument parser for a Python script. The script should accept two command-line arguments: `--input` and `--output`. The `--input` argument should specify the input file path, and the `--output` argument should specify the output file path. Once the arguments are parsed, t... | codefeedback |
You are tasked with implementing a user authentication system for a web application. The system should accept a username and password from the user, validate the credentials, and return a response indicating whether the authentication was successful or not. Additionally, the system should have the capability to handle ... | codefeedback |
You are tasked with implementing a stock market analysis algorithm that calculates moving averages and their differences. The algorithm processes a stock's closing prices to compute the short-term and long-term moving averages, and then calculates the difference between these averages. The algorithm uses the following ... | codefeedback |
You are tasked with creating a Python script to process text data and generate a JSON file based on certain criteria. The script will read a text file, filter out certain entries, and then create a JSON file containing the remaining entries.
You are given the following variables:
- `text`: A string representing the pa... | codefeedback |
You are tasked with implementing a function that calculates and returns the average accuracy for a given metric. The function takes in three parameters: `metric`, `hits`, and `misses`. If the `metric` is 'pointing', the function should calculate the average accuracy and return both the individual accuracies and the ave... | codefeedback |
You are tasked with implementing an autocomplete feature for a code editor. The editor provides code completion suggestions based on the context of the code being written. The code snippet provided is an example of the autocomplete suggestions that the editor should offer.
The code snippet shows a function `testQualif... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of a network security group manager. The function should be able to create and list security groups using the provided arguments. Additionally, the function should be tested using the `ddt` library with various input scenarios.
Write a Python f... | codefeedback |
You are working on a computer graphics project and need to implement a function for intrinsic camera projection and rasterization. The given code snippet is a part of the function that performs these operations using TensorFlow.
Intrinsic camera projection involves transforming 3D points into 2D image coordinates usin... | codefeedback |
You are tasked with implementing a command-line utility that interacts with a Redis database. The utility should support various options for input/output handling and data manipulation. Your task is to create a Python program that utilizes the `argparse` module to parse command-line arguments and perform the specified ... | codefeedback |
You are tasked with creating a Python program that simulates a simple web server. Your program should accept HTTP requests and respond with appropriate HTTP responses. Specifically, you need to implement a basic routing mechanism to handle different endpoints and return corresponding content.
Your program should inclu... | codefeedback |
You are given a list of integers representing the daily stock prices of a certain company. Your task is to write a function that calculates the maximum profit that can be obtained by buying and selling the stock within a certain number of days. The function should take two parameters: the list of stock prices and the n... | codefeedback |
You are tasked with implementing a Python class that handles authentication and coin type for a cryptocurrency trading platform. The class should have an `__init__` method that takes an `auth` object and an optional `coin` type. The `auth` object contains properties for ID, PIN, and secret, while the `coin` type is an ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.