instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function that calculates the mesh grid for a given set of parameters. The function should take in the following inputs: - `vinf_span`: A list representing the range of free-stream velocities - `alpha_lim`: A list representing the range of angles of attack - `num_contours`: An integer ...
codefeedback
You are working for a data visualization company that specializes in creating interactive visualizations for agricultural data. Your task is to create a Python function that takes a pandas DataFrame containing agricultural data and generates JSON visualization files for each subcategory in the dataset. The input DataF...
codefeedback
You are tasked with implementing a simple neural network using the PyTorch library. Your goal is to create a feedforward neural network with one hidden layer to classify handwritten digits from the MNIST dataset. The MNIST dataset consists of 28x28 pixel grayscale images of handwritten digits (0-9). Each image is repre...
codefeedback
You are tasked with implementing a Swift protocol and a concrete class to manage asset manifests for photos. An asset manifest is a list of resources associated with a photo, such as the URLs of the available images. The protocol `AssetManifestRepositoryProtocol` defines a method `fetchManifest(for url: URL)` that shou...
codefeedback
You are tasked with creating a Python program to process seismic data from a file containing information about seismometers. The program should read the data from the file, filter the seismic data using high-pass and low-pass filters, and then display the filtered data. The code snippet provided initializes the high-p...
codefeedback
You are tasked with creating a Python function that loads a machine learning model using the Keras library and makes predictions on a given dataset. The function should handle exceptions related to model loading and prediction, and provide appropriate error messages. You are given a code snippet that includes the `loa...
codefeedback
You are tasked with implementing a function that processes a list of dependencies and operations to generate a sequence of operations. Each dependency is a tuple containing two strings: the module name and the version. Each operation is a string representing a specific action. The goal is to create a sequence of operat...
codefeedback
You are tasked with creating a middleware for a web application using the Laravel framework. The middleware should restrict access to certain routes based on the user's authentication status. Your task is to implement a middleware that checks if a user is authenticated before allowing access to specific routes. The m...
codefeedback
You are tasked with implementing a function that calculates the visual rectangle of a layout box model object in a web rendering engine. The function takes an ancestor layout box model object, a reference to a physical rectangle, map coordinates flags, and visual rectangle flags as input parameters. Your goal is to wri...
codefeedback
You are tasked with creating a Python function that interacts with the Spotify API to search for music tracks. The function should take in the track name, artist, and an optional type parameter, and then make a request to the Spotify API to search for the specified track by the given artist. The Spotify API endpoint fo...
codefeedback
You are tasked with optimizing a Java method that performs a specific operation on a byte buffer. The method `put` takes two parameters: a `Blackhole` object and a `BenchmarkState` object. The `BenchmarkState` object contains a field `bytes` representing the number of bytes to be processed, and a `ByteBuffer` object na...
codefeedback
You are tasked with implementing a class `CreditCard` that validates credit card numbers using the Luhn algorithm. The Luhn algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers. The algorithm is as follows: 1. From the rightmost digit (excluding the ch...
codefeedback
You are tasked with creating a web application that generates and serves bar and line charts based on user input. The application should accept a string of comma-separated numbers and an optional title for the chart. The bar chart should be generated using the input numbers, and the line chart should be generated using...
codefeedback
You are tasked with implementing a function that simulates a simple CPU instruction execution. The CPU has a set of registers, a memory bus, and supports various operations. The provided code snippet is part of a larger CPU simulation program and contains a mix of method calls, bitwise operations, and conditional logic...
codefeedback
You are tasked with implementing a function that binds a popover to a UI element. The function should return an object containing properties and methods to control the popover's behavior. The function signature is as follows: ```typescript function bindPopover( popupState: PopupState ): { id: string | undefined ...
codefeedback
You are tasked with creating a custom annotation processor in Java that processes a specific annotation used in a Spring Boot application. The annotation, `@MapperScan`, is similar to the existing `@MapperScan` annotation in MyBatis, and it is used to specify the package to scan for MyBatis mapper interfaces. Your cus...
codefeedback
You are tasked with creating a script to automate the installation of a specific software package from a Git repository. The script should clone the repository if it doesn't exist locally, or update it if it does. Additionally, the script should create a build directory within the repository and change the working dire...
codefeedback
You are tasked with creating a function to handle update alerts for a mobile application. The function `createAlert` takes two parameters: `type`, which is an enum of type `UpdateAlertType`, and `vc`, which is an optional `UIViewController`. The function should return an `UIAlertController` instance or `nil` based on t...
codefeedback
You are tasked with creating a script to automate the build process for a C++ project using CMake and Make on a Unix-based system. The project has the following directory structure: ``` project/ ├── extern/ │ └── bin/ │ └── macosx/ │ └── cmake/ │ └── bin/ │ └── ccmake ...
codefeedback
You are tasked with implementing a multi-stage data processing pipeline using Rust. The pipeline consists of several stages, each performing a specific transformation on the data before passing it to the next stage. Your goal is to create a program that sets up and executes this pipeline, demonstrating the use of Rust'...
codefeedback
You are tasked with implementing a neural network model using the PyTorch library. The model consists of several layers and is designed to perform forward propagation on input data. Your goal is to complete the implementation of the `Model` class by defining the layers and the forward propagation method. The `Model` c...
codefeedback
You are tasked with implementing a unit test for the function `ParseDifferentialCorrectionAge` in the `NMEAParser.cpp` file. The function `ParseDifferentialCorrectionAge` takes a string `CorrectionAge` as input and returns a parsed value representing the age of the differential correction data. Your task is to write a...
codefeedback
You are tasked with implementing a class method for calculating a discount based on a social bonus in a billing system. The given code snippet is a part of a larger class method that calculates the discount based on a fixed and variable amount. The method is part of a billing system that applies discounts based on cert...
codefeedback
You are tasked with implementing a Python program that simulates a simple multi-threaded task execution. The program should utilize the `multiprocessing` module to create multiple processes that execute a given task concurrently. However, there is a bug in the provided code snippet that prevents the program from runnin...
codefeedback
You are tasked with creating a Python function that performs Principal Component Analysis (PCA) on a given dataset and returns the transformed data with reduced dimensions. PCA is a statistical method used to reduce the dimensionality of the data while retaining most of its original information. The function should tak...
codefeedback
You are tasked with implementing a function that enhances an internationalization (i18n) library by adding a new feature. The i18n library provides support for localization and translation of text in different languages. The code snippet provided is a TypeScript function that creates an i18n instance and enhances it wi...
codefeedback
You are tasked with implementing a class that performs static code analysis on a given source code using a set of rules. The class should parse the source code, create an abstract syntax tree (AST), and then apply the specified rules to the AST to identify any violations. Your task is to complete the implementation of ...
codefeedback
You are tasked with simulating a distributed training setup for a machine learning model using a simplified version of the code snippet provided. The code snippet is responsible for spawning worker processes on multiple GPUs and an evaluation process on a separate GPU using the `tmux` terminal multiplexer. Your task i...
codefeedback
You are tasked with implementing a password hashing and salting algorithm in Java. The algorithm should use a configurable salt length and hash length. The salt and hash lengths should be set and retrieved using getter and setter methods. The hashing algorithm should take a plaintext password as input, generate a rando...
codefeedback
You are tasked with implementing a C++ program that utilizes serialization libraries to store and retrieve data. The program should be able to handle different serialization libraries and gracefully handle the absence of certain libraries. Your task is to implement a function `serializeData` that takes a string `data`...
codefeedback
You are tasked with creating a Python function that processes financial data and calculates certain key metrics. The function will take a dictionary `a` as input, containing financial data, and should handle potential errors in the data gracefully. The function should calculate the following metrics: 1. `H52`: The fift...
codefeedback
You are tasked with creating a Python program that simulates a simple file system. The file system will consist of directories and files, and you need to implement operations to create, delete, and list the contents of the file system. Your program should support the following operations: 1. Create a directory 2. Crea...
codefeedback
You are working on a software library for signal processing, and you need to implement a function that applies a recursive operation and constructs sparse indices based on certain criteria. The code snippet provided is part of the interface for these operations. Your task is to implement the functions `ApplyRecur` and ...
codefeedback
You are given a code snippet that calculates the weighted distance between two points in a 2D plane. The code snippet takes in the coordinates of two points `(x1, y1)` and the weights `px`, `py`, and `dd`, and then computes the weighted distance between a given point `(x, y)` and the point `(x1, y1)` using the formula:...
codefeedback
You are tasked with creating a program that processes configuration data in the HOCON (Human-Optimized Config Object Notation) format. HOCON is a configuration file format used by Akka and other typesafe projects. It is similar to JSON but allows for more human-friendly configuration files. Your program should read a ...
codefeedback
You are tasked with creating a Python class for reading and processing data from the CMRC2018 dataset. The CMRC2018 dataset contains Chinese machine reading comprehension passages and questions. Your task is to implement a CMRCReader class that can read the dataset files, process the data, and provide methods for acces...
codefeedback
You are tasked with implementing a class to manage the volume control of a media player. The class should have the following functionalities: 1. `set_volume(volume_level)`: A method to set the volume level to the specified value. 2. `increase_volume()`: A method to increase the volume level by 1 unit. 3. `decrease_vol...
codefeedback
You are tasked with creating a Python command-line interface (CLI) for a gym management system. The CLI should allow users to perform various operations such as adding members, scheduling classes, and viewing gym statistics. To achieve this, you need to implement the necessary commands and functionalities using the `fi...
codefeedback
You are tasked with creating a Python class for calculating lattice observables in a theoretical physics simulation. The class should include methods for calculating Wilson loops and other observables, as well as a method for aggregating and returning various metrics related to the observables. Your task is to impleme...
codefeedback
You are tasked with implementing a simplified version of a file descriptor set (FDSet) and a class for performing I/O multiplexing using the select system call in C++. Your task is to complete the implementation of the `ISelect` class, which will provide a simplified interface for managing file descriptors and perform...
codefeedback
You are tasked with creating a program to download a specified number of music files from an online source. The program should prompt the user to input the number of music files to download (between 1 and 100), and then proceed to download the corresponding music files. The music files are to be saved in a folder named...
codefeedback
You are tasked with creating a C# program to manage subscriptions to an EventGrid topic. The program should take in a key for EventGrid topic access and generate a URI string based on the host and number of clients. It should then create a subscription metadata object with specific properties and values. Your task is ...
codefeedback
You are tasked with creating a program to analyze search results from a web service. The program will retrieve search results for a given keyword and then perform various checks on the results. You are given a code snippet that demonstrates part of the process. The snippet includes the keyword "qq" and makes a request...
codefeedback
You are tasked with implementing a class that simulates a simple vending machine. The vending machine should be able to dispense items based on the user's input and handle the change returned to the user. Your task is to implement the `VendingMachine` class with the following functionalities: 1. Initialize the vending...
codefeedback
You are given a Swift class `MergeSort` that contains a static method `sort` to perform the merge sort algorithm. Your task is to complete the implementation of the `sort` method to sort an array of integers in ascending order. The merge sort algorithm follows these steps: 1. Divide the unsorted array into n subarrays...
codefeedback
You are tasked with implementing a function to perform template matching on an image using a given needle image. Template matching involves finding instances of the needle image within the larger haystack image. The function should return the coordinates of all the matches found with a confidence level above a specifie...
codefeedback
You are tasked with creating a simple routing system for a mobile application. The application uses the VIP (View, Interactor, Presenter) architecture, and you need to implement the routing logic for a specific scene in the app. You are provided with a Swift code snippet that outlines the initial structure for the rou...
codefeedback
You are tasked with implementing a file ordering algorithm for a build system. The build system processes a set of input files and needs to determine the order in which these files should be processed. The input files are represented as a directed acyclic graph (DAG), where each file is a node and the dependencies betw...
codefeedback
You are working on a bioinformatics project and need to process FASTQ files to extract and combine sequence and quality information. The FASTQ format is a text-based format for storing both a biological sequence and its corresponding quality scores. Each record in a FASTQ file consists of four lines: a sequence identif...
codefeedback
You are tasked with implementing a class for converting and running a machine learning model using TensorRT. TensorRT is a high-performance deep learning inference library developed by NVIDIA. Your goal is to complete the implementation of the `_TrtModelHandlerBase` class by adding the missing methods and attributes. ...
codefeedback
You are tasked with implementing a Python class that manages a set of service actions. The class should allow adding new actions, retrieving specific actions, and executing actions with specific requests. You need to implement the `ServiceManager` class with the following specifications: - The class should have an att...
codefeedback
You are working on a project to develop a RESTful web service for managing automobile resources. The code snippet provided is a part of the implementation for this service. The code includes a method for updating an automobile resource and another method for deleting an automobile resource. The methods are part of a JA...
codefeedback
You are tasked with implementing a simple observer pattern in Python. 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. In this problem, you will need to create an `O...
codefeedback
You are tasked with implementing a function that simulates a simple DNS lookup. The function should take a domain name as input and return the corresponding IP address. The provided code snippet is a starting point for the function, but it needs to be completed to achieve the desired functionality. You need to impleme...
codefeedback
You are tasked with creating a Flask web application that serves as a simple file-sharing platform. The application should allow users to upload files, view a list of uploaded files, and download files. You need to implement the file upload, file listing, and file download functionality using Flask. Your task is to co...
codefeedback
You are tasked with creating a program that counts the occurrences of words in a given list and then sorts the words in alphabetical order along with their respective counts. You are given a list of words and are required to implement a function `count_and_sort_words` that takes in a vector of strings `words` and retu...
codefeedback
You are tasked with implementing a Python function that performs image resizing and mask interpolation using PyTorch. The function takes an input image, a target dictionary containing masks, and specific size constraints. The function resizes the image and interpolates the masks accordingly. Your task is to complete th...
codefeedback
You are working on a data processing task that involves reshaping and extracting data from a given input. The input data is represented as a list of elements, and you need to perform specific operations to transform and extract subsets of this data. Your task is to implement a function that takes the input list and per...
codefeedback
You are tasked with implementing a Python function that reads data from a file, performs a specified operation, and writes the result to another file. Your function should be able to handle different data types and operations based on the input parameters. You are given the following code snippet as a starting point: ...
codefeedback
You are tasked with implementing a reinforcement learning algorithm for an agent to learn to play a game. The algorithm uses a combination of actor and entropy loss to train the agent's policy network. The provided code snippet is a part of the training process, where the softmax probabilities of the network's output l...
codefeedback
You are tasked with implementing a modified version of the bubble sort algorithm. The modified algorithm will sort an array of integers in ascending order, but with a twist. In each pass of the algorithm, if two adjacent elements are out of order, they will swap positions only if their sum is a prime number. If the sum...
codefeedback
You are tasked with implementing a function to calculate the connected domin score for a pair of images. The connected domin score is a measure of the similarity between two images based on the connected components in their binary representations. The function `count_connected_domin_score` takes four parameters: `max_t...
codefeedback
You are working on a chatbot application that requires connecting to a server using a specific token and server address. The bot token and server address are stored in the variables `BOT_TOKEN` and `SERVER_ADDRESS` respectively. The `BOT_TOKEN` contains a sensitive password, and the `SERVER_ADDRESS` is a tuple consisti...
codefeedback
You are given a class `Matrix` representing a 2D matrix of integers. The class has a method `findMaxSubMatrix` that should find the submatrix with the maximum sum of elements within a given matrix. The method signature is as follows: ```java public int[] findMaxSubMatrix(int[][] matrix) ``` The input `matrix` is a 2D...
codefeedback
You are tasked with implementing a client-server communication protocol for sending and receiving file paths over a network. The client sends the length of the file path as an unsigned short followed by the actual path to the server. The server responds with a single byte indicating success or failure, and in case of f...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The system should be able to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry. The program should be implemented using object-oriented principles in Python. Your task is to create a `BankAcc...
codefeedback
You are given a series of 3D points in the form of (x, y, z) coordinates. Your task is to write a program to calculate the distance between each pair of points and identify the pair of points with the shortest distance. The input will be provided as a list of tuples, where each tuple represents a 3D point in the forma...
codefeedback
You are tasked with implementing a Captive Portal class for a network management system. The Captive Portal is responsible for handling HTTP requests and managing network registration. The class has been partially implemented with the following code snippet: ```cpp CaptivePortal::CaptivePortal(const char* ip) : _h...
codefeedback
You are tasked with implementing a function to find all prime numbers up to a given integer N. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your task is to write a function that returns a vector containing all prime numbers up to N. Your function signature sh...
codefeedback
You are tasked with implementing a TypeScript type definition for a floating navigation menu style props and class keys. The provided code snippet outlines the initial structure for the type definition. Your goal is to complete the type definition by incorporating the necessary properties and ensuring type safety. Com...
codefeedback
You are working on a project to analyze data collected from a satellite orbiting a planet. The satellite periodically records various parameters such as latitude, longitude, altitude, temperature, and pressure. The recorded data is stored in a structured format, and you need to write a program to process and visualize ...
codefeedback
You are working on a system that involves running two Python scripts, `service.py` and `submit.py`, with specific command-line arguments. Your task is to write a Python function that simulates the behavior of the given code snippet. The function should take a list of command-line arguments as input and execute the two ...
codefeedback
You are tasked with implementing a function that converts a field specification into a specific type based on the provided input. The field specification is a tuple containing the attribute name and the field value. The function `_convert_field_from_spec` takes the attribute name and the field specification as input an...
codefeedback
You are given a code snippet that defines a `Point` class and a function `cross` to calculate the 2D cross product of two vectors. Your task is to implement a function that sorts an array of `Point` objects in counter-clockwise order with respect to a given reference point. You need to write a function `sortPoints` th...
codefeedback
You are tasked with creating a program to process user login information and manage access tokens. The program should read a series of lines from a file, concatenate them into a single string, and then deserialize the string into a `TokenModel` object using JSON. After obtaining the access token from the deserialized o...
codefeedback
You are tasked with creating a Python program that simulates a simple game. The game involves a player navigating through a series of obstacles and reaching the end goal. The player's progress is tracked by a class called `GameTracker`, which has methods for moving the player, checking for obstacles, and determining if...
codefeedback
You are working on a distributed storage system that utilizes a threaded server to handle storage operations. The provided code snippet is a part of the system and includes a method call and the main execution logic. Your task is to implement a class `StorageService` that provides the functionality for the `storage.pu...
codefeedback
You are tasked with implementing a block decryptor benchmarking function for the Magma encryption algorithm. The Magma algorithm is a symmetric key block cipher that operates on 64-bit blocks and uses a 256-bit key. The provided code snippet is a macro invocation that sets up the benchmarking for the Magma block decryp...
codefeedback
You are tasked with creating a program that processes an image to detect and count the number of circles present in it. To achieve this, you will need to utilize the OpenCV library in Python. The program should take an input image, apply circle detection, and then output the count of circles detected. Your task is to ...
codefeedback
You are tasked with creating a Python function that processes XML data related to operating systems. The function should take in an XML string representing OS information and return a dictionary containing the OS name and type. The XML data will have the following structure: ```xml <os_section> <os_desc></os_desc>...
codefeedback
You are tasked with creating a script to automate the installation and configuration of a software package called DPDK (Data Plane Development Kit) on a Linux system. DPDK is a set of libraries and drivers for fast packet processing. The script should handle different versions of DPDK and apply necessary patches, confi...
codefeedback
You are tasked with implementing a JavaScript function that simulates the behavior of the `Object.create` method. The `Object.create` method creates a new object with the specified prototype object and properties. Your task is to create a function `customCreate` that takes in a prototype object and returns a new object...
codefeedback
You are tasked with creating a function that takes an array of integers and returns the sum of all the even numbers in the array. If the input array is empty or does not contain any even numbers, the function should return 0. Function Signature: ```swift func sumOfEvenNumbers(_ numbers: [Int]) -> Int ``` For example...
codefeedback
You are working on a project that involves deep learning and GPU acceleration. You have a Python script that utilizes the PyTorch library for deep learning tasks. In the script, you encounter the following code snippet: ```python shuf_fts = shuf_fts.cuda() ``` Explain the significance of this code snippet and the ope...
codefeedback
You are tasked with creating a Python program that utilizes the `apscheduler` library to schedule and execute a function at regular intervals. The program should also incorporate a custom logging module to record the execution of the scheduled function. Your task is to implement a Python program that accomplishes the ...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The system should be able to create and manage bank accounts, allowing users to deposit, withdraw, and check their balance. Additionally, the program should support transferring funds between accounts. Your task is to implement the `BankAcc...
codefeedback
You are tasked with implementing a money management system in Swift. The system includes a `MoneyViewModel` (moneyVM) that handles the management of money records. The code snippet provided is a part of the `MoneyViewModel` class. The `moneyReocod` is an optional array of money records, and `refreshGroup` is a new arra...
codefeedback
You are tasked with implementing a feature detection algorithm called FAST (Features from Accelerated Segment Test). The algorithm works by identifying corners or keypoints in an image. The provided code snippet defines a struct with two fields: `patch_size` and `fast_threshold`. The `patch_size` represents the size of...
codefeedback
You are tasked with creating a Python program to manage various business processes for a company. The program should include modules for payroll disbursements, purchase management, sales processing, and tax calculations. Each module should contain relevant functions and classes to handle the specific business process. ...
codefeedback
You are tasked with creating a script to automate the deployment of a web application using Docker and PostgreSQL. The script should utilize a `docker-compose` file to run a specific Docker container and wait for the PostgreSQL database to be ready before proceeding. The relevant components and variables are as follow...
codefeedback
You are tasked with implementing a Python function that applies a given function to all keys in a nested dictionary or a list of dictionaries. The function should be applied recursively to all levels of nesting within the data structure. If the input data is not a dictionary or a list of dictionaries, the original obje...
codefeedback
You are tasked with creating a PHP function that processes a list of pages and generates a nested HTML list representing the page hierarchy. Each page has an ID, a title, and a parent ID. The function should take the list of pages as input and return the HTML representation of the page hierarchy. The page list is repr...
codefeedback
You are tasked with implementing a Java class that simulates a ticker source for a music tempo tool. The class should implement the `TickerSource` interface and utilize a `BeatFunction` to generate beats at specific intervals. The `BeatMackTickerSource` class has been provided with a constructor that takes a `BeatFunct...
codefeedback
You are tasked with implementing a class that simulates a simple banking system. The class should support basic operations such as account creation, deposit, withdrawal, and balance inquiry. Additionally, the class should enforce a minimum balance requirement for each account. Your task is to implement the `BankAccoun...
codefeedback
You are tasked with creating a program that can efficiently determine the position of a specific HTML tag within a given HTML document. The program should take the HTML document as input and return the position of the specified tag within the document. The position should be represented as the line number and the chara...
codefeedback
You are tasked with implementing a custom namespace management system in C++. The system should allow for the creation, retrieval, and deletion of namespaces, as well as the addition and retrieval of variables within these namespaces. Each namespace can also have sub-namespaces, forming a hierarchical structure. Your ...
codefeedback
You are given a snippet of code that contains a method closing brace `}` without its corresponding opening brace. Your task is to write a program that can identify the missing opening brace and insert it at the correct position. You need to implement a function/method called `findMissingBrace` that takes a string repr...
codefeedback
You are tasked with creating a Java program that simulates a simple messaging system using the concept of channels and topics. The program should utilize the Spring framework and Apache Kafka for message handling. Your task is to implement a class that represents a message handler for entities. The handler should be r...
codefeedback
You are tasked with designing a load balancer management system. The system involves a `MarkLBActiveInDB` class responsible for marking a load balancer as active in the database and a `LoadBalancerRepository` class for updating the load balancer's provisioning status. Additionally, there is a `ListenerRepository` class...
codefeedback
You are tasked with implementing a Python function to calculate the permutation number of a given string. The permutation number is the position of the string when all its permutations are sorted lexicographically. For example, the permutation number of "abc" is 1, "acb" is 2, "bac" is 3, "bca" is 4, "cab" is 5, and "c...
codefeedback