instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a custom UIView subclass that allows touches to pass through certain areas, referred to as "holes," in the view. The code snippet provided is a part of the implementation of the `point(inside:with:)` method in the custom UIView subclass. The method checks if a given point is inside any ... | codefeedback |
You are tasked with implementing a program to analyze the frequency of terms in a given field. The program should read the field terms and determine the count of each term. The field terms are obtained from a document and are stored in a data structure called `ordCounts`. Additionally, the program should handle differe... | codefeedback |
You are tasked with creating a Swift function that takes an array of integers as input and returns the sum of all the even numbers in the array. If the input array is empty or contains no even numbers, the function should return 0.
Your task is to implement the `sumOfEvenNumbers` function, which takes an array of inte... | codefeedback |
You are tasked with creating a Python function that interacts with the Twitter API to retrieve a user's timeline and extract specific information from the tweets. The function should take a Twitter username as input and return a list of tuples, where each tuple contains the tweet text and the number of likes for that t... | codefeedback |
You are tasked with implementing a function that extracts the text content within HTML `<span>` tags. Your function should take a string of HTML code as input and return a list of all the text content within the `<span>` tags.
Function Signature: `def extract_span_content(html: str) -> List[str]`
**Input**
- The inpu... | codefeedback |
You are tasked with simulating a simple event-driven system using Python. The system is designed to handle function requests and execute them based on specific event types. Your goal is to implement the missing parts of the code to properly handle function requests and trigger the corresponding events.
You are provide... | codefeedback |
You are given a set of points in a 2D plane. Your task is to write a function to determine if a given set of four points form a convex quadrilateral. A convex quadrilateral is a four-sided figure in which all interior angles are less than 180 degrees and the line segments do not intersect each other.
You are provided ... | codefeedback |
You are tasked with implementing a program that simulates a simple calendar system for tracking events and appointments. The program should allow users to add, remove, and view events for specific dates. Each event will have a title and a description. The program should also provide the ability to view all events for a... | codefeedback |
You are tasked with creating a Python program that sends an email using the SMTP protocol. Your program should prompt the user for their email address, password, the recipient's email address, and the message to be sent. After gathering this information, the program should establish a secure connection with the SMTP se... | codefeedback |
You are tasked with implementing the Sieve of Eratosthenes algorithm to generate the first 1229 prime numbers. The Sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to a specified integer. The algorithm works by iteratively marking the multiples of each prime number starting from 2, which a... | codefeedback |
You are working on a project that involves applying patches to various files in a codebase. Your task is to write a Python function that can automate the process of applying patches to the corresponding files. The function should take in a list of patch URLs and apply each patch to the appropriate file in the codebase.... | codefeedback |
You are tasked with creating a Python function that will modify the CPU settings on a Linux system. The function should disable the Intel P-state driver if it exists, set the maximum frequency for all CPU cores, and disable the NMI watchdog. You will need to use the `glob`, `os`, and `open` functions to achieve this.
... | codefeedback |
You are tasked with creating a function that extracts all the unique page names from a given HTML snippet. The page names are embedded within anchor tags (<a>) with href attributes. The function should return a list of unique page names without the file extensions (e.g., ".php").
Function Signature: `def extract_page_... | codefeedback |
You are tasked with implementing a Python class that can efficiently find and store calibration values for different parameters in a scientific data processing system. The class should be able to handle the addition and retrieval of calibration values for various parameters.
Your task is to implement the `CalibFinder`... | codefeedback |
You are working on a project that involves controlling a radio frequency module (RFM) and a LED strip. The code snippet provided is part of a larger program that initializes the RFM and then checks its status to determine whether it was initialized successfully. If the RFM initialization was successful, the LED strip i... | codefeedback |
You are tasked with creating a program that simulates a simple file system navigation. The program should be able to handle commands to change file permissions and navigate through directories.
Your program should support the following commands:
1. `chmod <permissions> <filename>`: This command changes the permissions... | codefeedback |
You are tasked with implementing a collision detection system for a 2D game. The game world consists of various entities, each with a rectangular bounding box representing their position and size. The `collider` module provides functions for detecting collisions between these entities.
The `collider` module contains t... | codefeedback |
You are given a Python code snippet that involves a function `recover_secret` and a list of shares. The `recover_secret` function takes a list of shares as input and returns the secret that was used to generate those shares. Each share is a string containing a number and a hexadecimal value separated by a hyphen. The l... | codefeedback |
You are tasked with implementing a video classifier using bidirectional LSTM (Long Short-Term Memory) neural networks. LSTM networks are a type of recurrent neural network (RNN) that are well-suited for processing and classifying sequential data, such as videos. The bidirectional aspect allows the network to effectivel... | codefeedback |
You are tasked with creating a Python function that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player can move up, down, left, or right within the grid. The grid is represented as a 2D list where each cell conta... | codefeedback |
You are tasked with implementing a hierarchical sigmoid (hsigmoid) function for a multi-class classification problem. The hsigmoid function is used to efficiently compute the loss and gradients in a hierarchical softmax setting. The function takes input data, weights, labels, and biases as input and produces the pre-ou... | codefeedback |
You are working on a file management system and need to create a program that can compress and decompress files using the ZIP algorithm. Your task is to write a Python function that takes a list of file paths and a destination directory as input and creates a ZIP archive of the specified files. Additionally, you need t... | codefeedback |
You are tasked with implementing a simple text compression algorithm. The algorithm should take a string as input and return a compressed version of the string based on the frequency of characters. The compression should be achieved by replacing consecutive repeated characters with the character followed by the count o... | codefeedback |
You are tasked with creating a Python program that simulates a simple command-line interface for a virtual pet game. The virtual pet, named "Pypet," needs to be fed, played with, and put to sleep to keep it happy and healthy. Your program should provide a command-line interface for users to interact with the virtual pe... | codefeedback |
You are tasked with implementing a secure authentication system for a web application. The system should include functions for validating and logging out a user. The provided code snippet includes two functions, `auth_is_valid` and `auth_logout`, which are responsible for generating the appropriate response for these a... | codefeedback |
You are tasked with implementing a Python class that manages a thread bundle and handles cleanup operations upon completion. The class should include a setup method that initializes the thread bundle and sets up cleanup operations using the `addCleanup` method. Additionally, the setup method should create a threading e... | codefeedback |
You are tasked with creating a C# program that analyzes and optimizes a given source code file. The program should read the source code, parse it using specific options, and then perform various optimizations on the code. Your task is to implement the optimization logic based on the provided code snippet.
Your program... | codefeedback |
You are tasked with implementing a class that represents a Kubernetes container specification. The class should have fields for resources, volume mounts, termination message path, image pull policy, and ports. Your goal is to create the class with appropriate data types and methods to manipulate these fields.
You need... | codefeedback |
You are working on a project that involves compiling and packaging a set of source code files written in C#. Your task is to create a script that automates the compilation and packaging process. The script should perform the following steps:
1. Compile all the C# source code files in the current directory into executab... | codefeedback |
You are tasked with creating a Python script that extracts the version number from a given string. The version number follows the semantic versioning format, which consists of three non-negative integers separated by periods (e.g., "1.2.3"). The version number may also include an optional pre-release version and build ... | codefeedback |
You are tasked with implementing a Python program to optimize hyperparameters for a machine learning model using a genetic algorithm. The genetic algorithm will be used to find the optimal values for the hyperparameters based on the given constraints and objectives.
You are given a set of hyperparameters and their def... | codefeedback |
You are tasked with creating a reinforcement learning agent to play a simple game. The game environment is provided, and you will need to implement the agent using a given model. The game environment is interactive and can be visualized using the `env.render()` function. The agent's actions are determined by the model'... | codefeedback |
You are tasked with implementing a custom view in a mobile application that can display either an image with accompanying text or just text. The view has two main components: an image view and a label. The view can be in one of two states: text-only or image-with-text. The state is determined by an enum `ViewState` wit... | codefeedback |
You are working on a continuous integration (CI) pipeline for a software project. As part of the pipeline, you need to write a script that automates the deployment process to a build repository under certain conditions. The script should handle encryption and decryption of sensitive files and ensure secure access to th... | codefeedback |
You are working on a project to create a memory game for children. The game involves shuffling a list of numbers and saving the game state to a file. You need to write a Python function to accomplish this task.
Write a Python function called `save_game_state` that takes two parameters:
- `sums` (list of integers): A l... | codefeedback |
You are tasked with implementing a custom property wrapper in Swift that allows for easy access to the width and height properties of a UIView. The custom property wrapper should provide a convenient way to access these properties and ensure that they are always up to date with the actual width and height of the UIView... | codefeedback |
You are tasked with creating a web application that manages job listings. The application displays a table of job details, including salary, quantity, creation date, and action buttons for viewing, deleting, and updating the job status. The job status is represented by a button that toggles between "Active" and "Deacti... | codefeedback |
You are tasked with implementing a C++ class that represents a collection of coils used in industrial control systems. The class should support operations for filling addresses and removing filled data, as well as comparing individual coils for equality.
Your task is to complete the implementation of the `coils` class... | codefeedback |
You are working on a Python library that interfaces with a cloud infrastructure platform. As part of this library, you need to implement a custom asynchronous function for retrieving a pool of resources from the cloud. The function should return a collection of values representing the resources obtained from the pool.
... | codefeedback |
You are given an array `nums` of integers. Your task is to write a function that calculates the total count of subarrays in `nums` such that the difference between consecutive elements in each subarray is the same.
For example, given the array `nums = [1, 3, 5, 7, 9]`, the subarrays with the same difference between co... | codefeedback |
You are tasked with implementing a Python function that simulates the installation of external Homebrew taps from a text file. Homebrew is a package manager for macOS, and taps are external repositories that extend Homebrew's functionality. The code snippet provided is a starting point for this task.
Your task is to c... | codefeedback |
You are working on a weather data processing application that involves manipulating meteorological data using Google Earth Engine (GEE) JavaScript API. Your task is to create a function that calculates the wind speed gradient and converts the pressure from Pascal (Pa) to kilopascal (kPa) using the given code snippet as... | codefeedback |
You are given a PHP code snippet that contains conditional statements to determine whether a given number is even or odd and whether it is greater than or less than 100. Your task is to write a function that accomplishes the same logic as the code snippet.
Write a PHP function called `numberComparison` that takes an i... | codefeedback |
You are tasked with implementing a function to aggregate markers and perform specific actions based on the aggregated data. The function takes in a list of previously processed markers and returns a dictionary of the markers to be aggregated, the updated list of processed markers, and a dictionary specifying the action... | codefeedback |
You are tasked with implementing a sequential graph mapper in Swift. The `SequentialGraphMapper` class is responsible for executing a list of graph mappers sequentially. Each graph mapper is an instance of a class that conforms to the `GraphMapping` protocol. The `GraphMapping` protocol likely includes a method for map... | codefeedback |
You are tasked with creating a program that extracts phone numbers from HTML code. The HTML code contains multiple `<p>` tags with phone numbers inside `<i>` tags. Your task is to write a function that takes the HTML code as input and returns a list of phone numbers found within the `<i>` tags.
For example, given the ... | codefeedback |
You are tasked with implementing a custom smart pointer class similar to `eastl::unique_ptr` in C++. The custom smart pointer should manage the lifetime of a GLFW window and ensure proper cleanup upon destruction. Your task is to create a class template `CustomUniquePtr` that mimics the behavior of `eastl::unique_ptr` ... | codefeedback |
You are working on a scientific computing project using the MFEM library in C++. As part of your project, you need to solve a normal equation system using the Preconditioned Conjugate Gradient (PCG) iterative solver and check the weighted norm of the residual for the Discontinuous Petrov-Galerkin (DPG) least square pro... | codefeedback |
You are tasked with implementing a class that manages charging constraints for electric vehicles. The class should handle both non-specific and specific constraints, ensuring that they are applied correctly based on the given rules.
You are provided with a partial code snippet that includes a class definition and an e... | codefeedback |
You are tasked with implementing a timed hosted service in C# using the .NET Core framework. Your goal is to create a service that runs a specific task at regular intervals. You will need to utilize the Timer class and asynchronous programming to achieve this.
Your task is to complete the implementation of the TimedHo... | codefeedback |
You are tasked with implementing a loading activity manager in Swift. The manager should allow for setting a superview and edge insets for the loading activity, as well as providing a method to reset these settings. Additionally, the manager should be implemented as a singleton using the shared instance pattern.
Your ... | codefeedback |
You are tasked with implementing a Python class that manages imports and from-imports for a GUI application. The provided code snippet initializes a QScrollArea and sets its layout to QVBoxLayout. Additionally, it initializes a dictionary named `import_widget_assignment` with two empty dictionaries, 'imports' and 'from... | codefeedback |
You are tasked with implementing a function that determines whether two floating-point numbers are almost equal within a specified number of units in the last place (ULP). The ULP is the distance between two consecutive floating-point numbers, and the function should compare the input numbers within a certain ULP toler... | codefeedback |
You are tasked with creating a Python function that simulates a simple file system. Your function should be able to reset the file system and create a package folder with a specified name. The file system should maintain a hierarchical structure, allowing for the creation of subfolders within the package folder.
Your ... | codefeedback |
You are tasked with implementing a function that simulates the refraction of a ray through different materials in a ray tracing system. The given code snippet is part of a larger ray tracing program and contains a function `SlRefractContext` that is responsible for creating a new trace context for the refracted ray.
T... | codefeedback |
You are tasked with creating a Python function that processes NetCDF files in a given directory and extracts specific information from the file names. NetCDF files are commonly used in the scientific community to store multidimensional data such as climate model output.
You are provided with a code snippet that define... | codefeedback |
You are tasked with implementing a Python class to manage instances of games for a CFC (Canadian Football Corporation) score predictor system. The class should handle the storage and manipulation of game data, including the date of the game and other relevant details. Your task is to create a class called `GameManager`... | codefeedback |
You are tasked with developing a command-line argument parser for a computer vision application. The parser should handle various options related to checkpoint management and belief propagation algorithm parameters. Your task is to implement a Python function that uses the `argparse` module to define and parse the comm... | codefeedback |
You are tasked with designing a data structure to efficiently store and retrieve financial transaction data. The data structure should support storing transactions with a timestamp and an amount, and should also allow for efficient retrieval of the current total amount at any given timestamp.
Design a Java class `Tran... | codefeedback |
You are tasked with implementing a protocol for controlling smart bulbs in a home automation system. The protocol defines several methods that need to be implemented by the smart bulb controller. The methods are as follows:
1. `willBulbFound()`: A method that will be called when a smart bulb is discovered in the netwo... | codefeedback |
You are tasked with implementing a function that prepares a row iterator for a given query. The row iterator will be used to iterate through the results of the query and process each row individually. The query is of type `QueryType`, and the function signature is as follows:
```swift
public func prepareRowIterator(_ ... | codefeedback |
You are tasked with implementing a custom module resolution system for a JavaScript project. The system should mimic the behavior of the `export` and `import` statements in ES6 modules. Specifically, you need to handle the resolution of the default export from a given module path.
Your task is to create a function tha... | codefeedback |
You are tasked with implementing a logging system for a Python application. The given code snippet includes a function `log_info` that configures the logging level and output destination. The `log_info` function takes a boolean parameter `debug`, which determines whether the logging level should be set to "DEBUG" or "S... | codefeedback |
You are tasked with creating a Python function that processes an image file and returns the predicted result using a pre-trained machine learning model. Your function should handle the HTTP POST request and respond with the prediction result in JSON format. Additionally, you need to ensure that the function handles cas... | codefeedback |
You are tasked with creating a Django REST framework view for managing the stock of raw materials in a manufacturing plant. Your task is to implement a custom view that allows for the creation, retrieval, updating, and deletion of raw material stock data. The view should be designed to handle HTTP methods such as GET, ... | codefeedback |
You are tasked with implementing a 2D and 3D measurement library in Rust. The library should provide functionality to calculate the area and perimeter of 2D shapes and the volume and surface area of 3D shapes. To achieve this, you need to define traits for 2D and 3D shapes and implement these traits for specific shapes... | codefeedback |
You are tasked with simulating a series of amplifiers to find the optimal phase settings that produce the highest output signal. Each amplifier is represented by an `Amp` class, and the amplifiers are connected in series. The amplifiers use an Intcode program to process input signals and produce output signals. The pha... | codefeedback |
You are working on a project management tool that integrates with GitHub. Your task is to create a function that takes a GitHub issue and generates an image preview of the issue content. The function should use the provided libraries and configurations to accomplish this task.
You have access to the following componen... | codefeedback |
You are tasked with implementing a similarity checker for a set of documents. The similarity between two documents is determined by comparing their content and calculating a similarity score. To achieve this, you need to create a program that reads in a set of documents, processes their content, and then computes the s... | codefeedback |
You are working on a testing framework for an API client in Swift. The code snippet provided contains test functions for different scenarios of the `missionType` endpoint. Each test function calls the `test_missionType_endpoint` method with specific parameters to test different aspects of the endpoint.
Your task is to... | codefeedback |
You are tasked with creating a Python class that manages ratings for different champions in a popular online game. The class should have the ability to add, update, and retrieve ratings for each champion. Additionally, it should be able to calculate the average rating for a specific champion and the overall average rat... | codefeedback |
You are tasked with developing a middleware plugin for a web framework. The middleware should be designed to log the time taken for each request to process and respond. The time should be logged in milliseconds and stored in a separate log file for analysis. Your task is to implement the middleware class and integrate ... | codefeedback |
You are tasked with implementing a custom hashing algorithm in Rust. The algorithm to be implemented is the WyHash hashing algorithm, which is a fast, non-cryptographic hash function designed for speed and good distribution. Your task is to complete the implementation of the `Hasher` trait for the `WyHash` struct.
The... | codefeedback |
You are working on a project that involves implementing a custom pooling layer for a neural network. The provided code snippet is a part of the implementation for this custom pooling layer. The `call` method of the pooling layer is shown, where the input tensor `inputs` undergoes max pooling with argmax operation using... | codefeedback |
You are tasked with creating a program to manage bank accounts. The program should include a function to delete a bank account, which involves the user inputting the account number and name. The account number must be a 7-digit number that does not start with 0 and is on the valid account list. The account name should ... | codefeedback |
You are tasked with creating a Python function that simulates a simple banking system. The function should allow users to withdraw, deposit, and check their balance. The function should also keep track of the transaction history for each user.
Create a class `BankAccount` with the following methods:
- `__init__(self, ... | codefeedback |
You are tasked with implementing a function that calculates the weighted average of a document's term frequencies using inverse document frequency (IDF) values. The function takes in a dictionary `document_tokens` containing word IDs as keys and their respective term frequencies as values, and a list `data` containing ... | codefeedback |
You are tasked with implementing a function that processes a given HTML snippet and extracts the options within a select element. The select element may contain multiple option elements, and your function should return a list of the values and labels of these options.
You are given the following HTML snippet as an exa... | codefeedback |
You are tasked with creating a C# program that interacts with Microsoft Azure's StorSimple service to manage storage resources. Your program should be able to authenticate with Azure, retrieve a list of StorSimple devices, and perform basic operations on these devices.
Your program should perform the following tasks:
... | codefeedback |
You are tasked with implementing a local search algorithm for optimizing resource allocation in a scheduling problem. The algorithm iteratively explores neighboring solutions to improve the fitness of the current solution. The fitness of a solution is determined by certain criteria, and the algorithm aims to find the b... | codefeedback |
You are tasked with implementing a simple CSV parser in Rust. Your task is to write a function that reads a CSV file and returns a vector of records, where each record is represented as a vector of fields. The CSV file will have a header row, and the fields will be separated by commas. You should ignore any leading or ... | codefeedback |
You are tasked with implementing a state space representation for a simple environment in Python. The state space representation will be used to track the state of the environment and provide methods for transitioning between states.
You are provided with a partial implementation of the `Environment` class in the file... | codefeedback |
You are tasked with implementing a level generator for a game. The provided code snippet is a partial implementation of a `GeometricalLevelGenerator` struct that implements the `LevelGenerator` trait. The `GeometricalLevelGenerator` struct has a method `random` that is supposed to generate a random number based on some... | codefeedback |
You are tasked with implementing a function to convert a base64 string to its binary representation. Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. The provided code snippet contains a partial implementation of the `base64_to_binary` function in TypeScript. Your task i... | codefeedback |
You are tasked with implementing a parameter modification system for a remote procedure call (RPC) framework. The provided code snippet is a simplified representation of a class `ModifyParameter` that extends the `Rpc` class. The `ModifyParameter` class has two methods: `getParameters` and `withParameters`. The `getPar... | codefeedback |
You are tasked with creating a program to generate potential usernames for a specific platform, based on a given list of permutations and a format string. The format string contains a placeholder `{permutation}` that will be replaced with each permutation from the list to form the usernames. Your task is to implement a... | codefeedback |
You are given a string containing alphanumeric characters. Your task is to create a program that categorizes the characters in the string into three lists: lowercase letters, uppercase letters, and mixed characters (non-alphabetic characters or digits). Additionally, you need to count the occurrences of lowercase lette... | codefeedback |
You are tasked with implementing a simple parser for a custom configuration file format. The configuration file contains key-value pairs, where the keys are alphanumeric strings and the values are obtained from a specific format. Each key-value pair is separated by a colon, and the pairs are separated by commas. The va... | codefeedback |
You are tasked with implementing a rate-limiting filter for a network application. The filter is responsible for controlling the rate at which incoming requests are processed. The provided code snippet is a part of the unit test for this filter.
The code snippet includes a mock setup using Google Mock, where a method ... | codefeedback |
You are tasked with creating a Python script that organizes and analyzes data from multiple NetCDF files. The NetCDF files contain temperature and pressure data from various locations. Your script should calculate the average temperature and pressure for each location and then identify the location with the highest ave... | codefeedback |
You are tasked with implementing a data structure to manage cells in a grid-based system. The grid is represented by rows and columns, and each cell has a region index, a row offset, and a column value. Your goal is to create a method that updates the row count and returns a new cell based on the given parameters.
You... | codefeedback |
You are tasked with implementing a thread-safe `LockableVector` class in C++. The `LockableVector` class should extend the functionality of the standard `std::vector` by providing thread-safe operations for adding, removing, and accessing elements.
Your task is to complete the implementation of the `LockableVector` cl... | codefeedback |
You are tasked with implementing a function that calculates the cost and loss for a student-teacher model in a semi-supervised learning scenario. The function takes several input parameters and performs specific operations to compute the cost and loss. Your task is to complete the implementation of the `criterion` func... | codefeedback |
You are tasked with implementing a Python class that simulates a simple banking system. The class should allow users to create accounts, deposit funds, withdraw funds, and check their balance. Additionally, the class should keep track of the total number of accounts created.
Your task is to complete the implementation... | codefeedback |
You are tasked with developing a Python script to process genetic data. The script will take command-line arguments and perform specific operations based on the provided inputs. Your task is to implement the functionality to process the command-line arguments and set up sample details based on the given arguments.
The... | codefeedback |
You are tasked with creating a Python function that can parse and extract information from a list of Django migration operations. Each operation in the list is represented as a tuple containing the following elements:
1. The operation type, which can be "migrations.AlterField" or "migrations.CreateModel".
2. The model ... | codefeedback |
You are tasked with implementing a custom exception handling mechanism for a specific scenario. Given the provided code snippet, you need to create a Java program that demonstrates the use of custom exception handling to catch and rethrow exceptions.
Your program should define a custom exception class, handle exceptio... | codefeedback |
You are tasked with creating a program that processes a given text file to extract and display the copyright information. The copyright information is always located within the first 20 lines of the file and follows a specific format. The copyright notice is denoted by the presence of the word "Copyright" (case-insensi... | codefeedback |
You are tasked with implementing a custom Quick Settings Tile for a mobile application. Quick Settings Tiles are used in the Android operating system to provide convenient access to certain features or settings. Each tile can have different states and associated icons and labels.
Your task is to create a function that... | codefeedback |
You are tasked with implementing a session management system for a real-time application. The system needs to handle the state transitions of individual sessions and track the time when certain events occur. The provided code snippet is a part of the session management logic, where the state of a session is being updat... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.