instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Python function that parses a configuration dictionary and returns a `Config` object. The `Config` object should contain specific attributes based on the keys and values in the input dictionary. If a key is missing or its value is `None`, default values should be used. Additionally, the f... | codefeedback |
You are tasked with creating a Rust function that simulates the decoding of a file to obtain a movie object using the Android Graphics Movie API. The function `decodeFile` takes an environment reference `__jni_env` and a file path `arg0` as input and returns a result containing either a movie object or an error. The fu... | codefeedback |
You are tasked with implementing a Python function that emulates the behavior of the `scatter_nd` function from TensorFlow in PyTorch. The `scatter_nd` function takes three parameters: `indices`, `updates`, and `shape`. The `indices` parameter is a tensor containing the indices at which the `updates` tensor will be sca... | codefeedback |
You are tasked with implementing a GitHub action that enforces a rule allowing only organization members and collaborators to approve certain actions. The provided code snippet is part of the implementation and contains relevant context information and initial processing steps.
Your task is to complete the implementat... | codefeedback |
You are tasked with implementing a logging system for a Python application. The application has a function `load_infrastructure` that is responsible for loading various infrastructure modules using entry points. The function uses the `logging` module to create a logger named "karp" and logs information about the loaded... | codefeedback |
You are tasked with implementing a cache system for storing and retrieving topological metadata in a containerized environment. The provided code snippet is a Java class `BasicContainer` that extends a `Container` and includes a static `TopoMetaLRUCache` instance called `TOPO_META_CACHE`.
Your task is to design and im... | codefeedback |
You are working on a web application that visualizes performance metrics for a machine learning model. The code snippet provided is a part of the application's frontend logic written in Rust using the Pinwheel and Tangram UI libraries. The `main` function initializes the application and sets up event listeners for two ... | codefeedback |
You are tasked with implementing a constraint propagation algorithm for a scheduling problem. The code snippet provided demonstrates the usage of the algorithm and the expected output. The `domains` vector contains pairs of DataType objects representing the minimum and maximum values for each domain. The Scheduler clas... | codefeedback |
You are tasked with creating a function that parses a TypeScript interface and extracts the names of all the properties defined within it. The function should return an array of property names in the order they appear in the interface.
Write a function `extractPropertyNames` that takes a string representing a TypeScri... | codefeedback |
You are tasked with implementing a Vector class in Python that supports basic operations such as indexing, length retrieval, and multiplication by another Vector or a scalar.
Your task is to complete the implementation of the Vector class by adding the following methods:
1. `__getitem__(self, index: int) -> int`: This... | codefeedback |
You are tasked with implementing a packet management system for a network simulation. The system should handle the creation, transmission, and reception of packets between network nodes. Each packet has a unique identifier and a time-to-live (TTL) value, indicating the maximum number of network hops it can traverse bef... | codefeedback |
You are tasked with implementing a message repository class that utilizes Doctrine ORM for managing message entities. The provided code snippet is part of a test case setup for the message repository class. Your task is to complete the implementation of the message repository class and ensure that it correctly interact... | codefeedback |
You are tasked with creating a Python function that generates a parameter file for a spectroscopic analysis tool called MOOG. The function should allow the user to customize various parameters and optionally display the parameter file on the screen. Your task is to implement the `param_file` function according to the f... | codefeedback |
You are tasked with implementing a method for updating a record in a database using a PHP class. The method should take in the record ID, an array of updates, an array of key-value pairs for a specific field, and a boolean flag for whether to publish the changes. Your task is to write a PHP method that accomplishes thi... | codefeedback |
You are tasked with creating a Python function that removes all lines containing a specific string from a given file. Your function should take two parameters: the string to be removed and the file name. The function should open the file, remove the lines containing the specified string, and save the modified content b... | codefeedback |
You are tasked with creating a Python function that calculates the topocentric distance between an observer on Earth and a celestial object, given the observer's location and the celestial object's coordinates. The function should take into account the observer's latitude, longitude, and the celestial object's right as... | codefeedback |
You are tasked with implementing a function that converts a given Metal texture (MTLTexture) to a Core Graphics image (CGImage) in a Swift environment. The function should take the Metal texture and a completion block as input and return the corresponding Core Graphics image.
The function signature is as follows:
```s... | codefeedback |
You are tasked with implementing a memory management system for a custom deployment scheduler. The scheduler is responsible for allocating and deallocating resources for various deployments. However, the system has a strict requirement that no garbage collection (GC) should be performed during the deployment process. T... | codefeedback |
You are working on a project that involves visualizing geographical data using the `geoplotlib` library in Python. As part of this project, you need to create a program that reads a CSV file containing geographical data and generates a 2D histogram based on the data. The `geoplotlib` library provides functions for visu... | codefeedback |
You are tasked with implementing a Python class method that formats a given string with indentation based on the value of the class attribute `self.i`. The method should also have an optional parameter `auto_break` which, if set to `True`, will automatically insert a line break after the formatted string. Your task is ... | codefeedback |
You are tasked with creating a Python function that simulates a simplified version of a swing-up control problem in a gym environment. The swing-up control problem involves controlling a pendulum to swing from a downward position to an upright position. The code snippet provided initializes the environment for the swin... | codefeedback |
You are tasked with implementing a module system for a JavaScript application. The code snippet provided is an example of a module export statement in JavaScript. When using the `export` keyword in JavaScript, it allows the module to export functions, objects, or primitive values to be used in other modules. The `expor... | codefeedback |
You are tasked with implementing a Python class that inherits from an abstract model and defines a specific type of neural network layer. Your goal is to complete the implementation of the class `BayesianConv2Pool2` by adding the necessary methods and attributes to create a Bayesian convolutional layer followed by a ma... | codefeedback |
You are tasked with implementing a sentiment analysis bot using a pre-trained model and GloVe word embeddings. The bot is loaded from a saved model file and then used to analyze responses from a data source. Additionally, the GloVe word embeddings are loaded using a GloVeLoader class. Your task is to complete the imple... | codefeedback |
You are tasked with creating a custom error page in a Django web application. The provided code snippet is a view function in a Django application that renders a custom error page for HTTP status code 500 (Internal Server Error). The `view_500` function takes a `request` object and returns the rendered error page with ... | codefeedback |
You are tasked with creating a shell script that automates the process of creating multiple directories and files within them. Your script should take in a list of directory names as arguments and for each directory, create the directory itself and then create three files within it. The names of the files should be "fi... | codefeedback |
You are tasked with implementing a Python function that evaluates and checks the correctness of a given lambda calculus expression. Lambda calculus is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. The given express... | codefeedback |
You are tasked with implementing a sorting algorithm for a hierarchical data structure. The data structure consists of nodes, each of which has a title and may have children nodes. The goal is to sort the children of each node based on their titles. The sorting should be performed in a specific context, determined by a... | codefeedback |
You are tasked with creating a program that simulates a simplified version of a dialog system using asynchronous programming in C#. The program should utilize the provided code snippet as a starting point and implement the necessary logic to handle user input and generate appropriate responses.
Your task is to create ... | codefeedback |
You are tasked with creating a Python program to control a robot equipped with a distance sensor. The robot is programmed to move forward until it detects an obstacle within a certain range, at which point it should stop and print the distance reading. Your program should continuously read the distance sensor and stop ... | codefeedback |
You are given a set of n distinct keys, each with an associated frequency of occurrence. Your task is to construct an optimal binary search tree (OBST) using these keys such that the total search cost is minimized. The search cost for a key is the depth of the key multiplied by its frequency. The depth of a key in the ... | codefeedback |
You are tasked with implementing a function that validates the declaration of a HashMap in a programming language. The HashMap must adhere to specific rules, and any deviation from these rules should result in an exception being raised. The code snippet provided is a part of the validation process for declaring a HashM... | codefeedback |
You are tasked with implementing a generic service factory trait and its associated implementation for a specific service builder. The provided code snippet outlines the trait implementation and its associated constraints.
Your task is to create a generic service factory trait and implement it for a specific service b... | codefeedback |
You are tasked with implementing a TypeScript class that manages the lifecycle of a resource. The class should handle the creation, deletion, and retrieval of the resource, while also maintaining metadata about these operations. Your task is to complete the implementation of the class and write methods to manage the re... | codefeedback |
You are tasked with designing a file browser management system for a cloud storage service. The system should allow users to open or activate a file browser dialog for a specific account and server repository. The `FileBrowserManager` class contains a method `openOrActivateDialog` that takes an `Account` object and a `... | codefeedback |
You are tasked with creating a script to automate the setup of a Kubernetes configuration file on a Windows system. The script should check for the existence of the Kubernetes configuration file, create it if it does not exist, and then copy the Windows configuration to the appropriate location. You are provided with a... | codefeedback |
You are tasked with implementing a file patching algorithm to update a web application. The patching process involves applying a difference file to an existing version of the application to produce an updated version. The difference file is provided in the form of a ZIP archive, and the existing version of the applicat... | codefeedback |
You are tasked with implementing a currency conversion system in Swift. Your goal is to create a struct that represents a currency and a function to convert an amount from one currency to another.
You are provided with a code snippet that defines the `GHS` (Ghana Cedi) currency as a struct conforming to the `CurrencyP... | codefeedback |
You are tasked with implementing a logging system for a software application. The logging system should support writing log messages to a file and provide a mechanism for managing log levels. The log levels include DEBUG, INFO, WARNING, and ERROR, with DEBUG being the lowest and ERROR being the highest level. Additiona... | codefeedback |
You are tasked with implementing a function to calculate the distance correlation between two arrays, `x` and `y`. Distance correlation is a measure of dependence between two random variables and is based on the idea of comparing the distances between all pairs of points in the joint space of the variables. The given c... | codefeedback |
You are tasked with implementing a C++ class that simulates a simple bank account. The class should have the following functionalities:
1. A default constructor that initializes the account balance to 0.
2. A parameterized constructor that allows the initial balance to be set.
3. A copy constructor that performs a deep... | codefeedback |
You are tasked with creating a script to automate the generation of protocol buffer files for a project. Protocol buffers are a language-agnostic, efficient, and automated mechanism for serializing structured data. The provided code snippet is the beginning of a shell script (`build-gen-proto.sh`) that will handle the ... | codefeedback |
You are tasked with simulating a staking pool system for a cryptocurrency platform. The system involves depositing funds, staking them, and rebalancing the pool. Your goal is to implement a function that calculates the user's balance after a series of deposit, stake, and rebalance operations.
You are provided with the... | codefeedback |
You are tasked with implementing a function that calculates the distance between two geographical coordinates using the Haversine formula. The Haversine formula is used to calculate the distance between two points on the Earth given their latitude and longitude in decimal degrees. The formula is as follows:
```
a = si... | codefeedback |
You are tasked with implementing a class that manages a grid system for a mapping application. The provided code snippet includes a property and a method related to the grid step unit, which determines the spacing between grid lines on the map. Your task is to create a Swift class that encapsulates the grid functionali... | codefeedback |
You are tasked with implementing a custom data loader for a machine learning model. The data loader should be able to handle both training and testing datasets, and it should support batching and shuffling of the data.
You are given a code snippet that initializes and returns the train and test data loaders using the ... | codefeedback |
You are given a directed graph represented as an adjacency list. Each node in the graph is labeled from 0 to n-1, where n is the number of nodes. Your task is to implement a depth-first search (DFS) algorithm to traverse the graph and determine the order in which the nodes are visited.
Write a function `dfs` that take... | codefeedback |
You are tasked with creating a Python function that processes files within a specified directory and its subdirectories. The function should calculate the total size of all files with a specific file extension within the given directory and its subdirectories.
You are provided with a code snippet that sets the `HOST_D... | codefeedback |
You are tasked with creating a program that manages a simple task list using Python. The program should allow users to add tasks, mark tasks as completed, view all tasks, and save the task list to a file using serialization. To achieve this, you need to implement a Task class with appropriate attributes and methods, as... | codefeedback |
You are tasked with writing a script to automate the download and deployment of a specific OS image for Kubernetes nodes. The script should utilize the provided environment variables to download the image from the specified location and then deploy it to a target environment.
The environment variables are as follows:
... | codefeedback |
You are working on a project to develop a system that can detect drowsiness in individuals by analyzing facial landmarks. The system uses the concept of Eye Aspect Ratio (EAR) and Mouth Aspect Ratio (MAR) to determine if a person is yawning. The code snippet provided is a part of the system's implementation. The `shape... | codefeedback |
You are working on a data processing module for a biological experiment. The module receives experimental data and processes it based on predefined setups. The setups are defined in a dictionary `exp_to_setup`, where the keys are experiment names and the values are the corresponding setups. Additionally, there is a lis... | codefeedback |
You are tasked with implementing a logo resolver class in PHP that utilizes an interface to provide the path for a customer's logo. The `LogoResolver` class should implement the `ResolverInterface` and utilize the `LogoPathProviderInterface` to retrieve the path for the customer's logo. Your task is to complete the imp... | codefeedback |
You are given an array of integers `arr` and an integer `k`. Your task is to determine whether there are more than `k` subarrays in `arr` whose sum exceeds a given `max_sum`. A subarray is a contiguous sequence of elements within the array.
Write a function `is_greater_than_k(max_sum, k, arr)` that takes in three para... | codefeedback |
You are tasked with creating a function that processes a list of screenshots taken from a mobile application and returns the average color of all the pixels in the screenshots. Each screenshot is represented as a 2D array of RGB values, where each pixel is represented as an array of three integers (R, G, B). The functi... | codefeedback |
You are tasked with implementing a custom scrollable key-value grid view in a mobile application. The key-value grid view should display a set of key-value pairs in a scrollable manner. Each key-value pair should be displayed as a separate item within the grid view. The keys and values should be provided as input data ... | codefeedback |
You are tasked with implementing a custom generator function in Python that processes incoming frames and yields values based on certain conditions. The generator function should follow a specific sequence of operations and handle potential exceptions.
Your task is to complete the implementation of the `process_frames... | codefeedback |
You are tasked with creating a Python class that manages and executes operating system commands. Your task is to implement the `os_commands` class with the following requirements:
1. The class should have a class variable `instance_counter` that keeps track of the number of instances created.
2. The `__init__` method ... | codefeedback |
You are tasked with implementing a simple in-memory cache system in Swift. The cache should have the ability to store key-value pairs and evict the least recently used item when the cache reaches its maximum capacity. You need to implement the `LRUCache` class with the following methods:
1. `init(_ capacity: Int)`: In... | codefeedback |
You are tasked with creating a Python package management system that can handle versioning and dependency resolution. Your system should be able to install, uninstall, and list packages, as well as handle dependencies between packages.
You need to implement a class `PackageManager` with the following methods:
- `insta... | codefeedback |
You are tasked with simulating a simplified version of a streaming service's backend system. The system manages streams of content and needs to update and initialize streams based on incoming JSON data. Your task is to implement the logic for updating and initializing streams based on the provided JSON data.
You are g... | codefeedback |
You are tasked with simulating the Monty Hall problem, a famous probability puzzle. The Monty Hall problem is based on a game show scenario where a contestant is presented with three doors. Behind one door is a valuable prize, while the other two doors conceal goats. The contestant selects a door, and then the host, wh... | codefeedback |
You are working on a job scheduling system that uses the `qsub` command to submit jobs to a cluster. Each job is associated with a specific range of data processing. The command follows the format:
```
qsub -V -cwd -q <queue_name> -S /bin/bash -N <job_name> runOne.sh <script_name> <start_range> <end_range>
```
Where:
-... | codefeedback |
You are tasked with implementing a custom decorator in TypeScript that logs the execution time of a method. Decorators are a powerful feature in TypeScript that can be used to modify or extend the behavior of classes, methods, or properties at design time. In this problem, you will create a decorator called `logExecuti... | codefeedback |
You are tasked with implementing a notification system in Python. The system should allow for the registration of notifiers for specific notification IDs and the triggering of notifications to the registered notifiers. You are provided with a partial implementation of the `NotificationManager` class, which includes a `... | codefeedback |
You are tasked with implementing a C++ template meta-programming problem related to logical disjunction. The code snippet provided demonstrates the usage of a `disjunction` meta-function and a `STATIC_REQUIRE` macro to perform compile-time assertions.
Your task is to create a C++ template meta-programming problem that... | codefeedback |
You are tasked with implementing a stack data structure in Swift using a protocol-oriented approach. The stack should support the following operations: push, pop, peek, and reset. Additionally, you need to create a coordinator rule protocol that defines the behavior for coordinating different stack operations.
Your ta... | codefeedback |
You are given a Java interface `BimBoom` with two abstract methods: `long bim(long v)` and `String boom(String s)`. Your task is to implement a class `BimBoomImpl` that implements the `BimBoom` interface and provides the following functionalities:
1. The `bim` method should return the sum of the input `v` and the leng... | codefeedback |
You are tasked with implementing a custom macro in Rust that generates implementations for a trait for multiple types. The macro should generate code that allows the trait to be implemented for each specified type.
Your task is to complete the implementation of the `impl_trait` macro. The macro should take a list of t... | codefeedback |
You are tasked with implementing a custom asynchronous queue class in Python. The class should support the following functionalities:
1. Initialization: The class should be initialized with a set of keyword arguments using the `super()` function. It should also store a URL generated using the `Router.get_url()` method... | codefeedback |
You are tasked with implementing a memory statistics tracking system in C++. The given code snippet provides a partial implementation of the `StatisticsMemory` class, which is responsible for managing memory statistics and flushing memory data to a target.
Your task is to complete the implementation of the `Statistics... | codefeedback |
You are tasked with implementing a function to extract a hash index from a given occupancy bitboard using a magic number. In chess programming, a magic bitboard is a technique used to efficiently implement move generation for sliding piece attacks (rooks, bishops, and queens). The magic number is a precomputed constant... | codefeedback |
You are given a code snippet that is part of a function `f` which takes several parameters: `idxL`, `idxR`, `num`, `l`, `r`, and `pw`. The function is designed to calculate a value `ans` based on the input parameters. The function iterates through a loop and performs some arithmetic operations to update the value of `a... | codefeedback |
You are tasked with implementing a BsonParser in Rust, which is capable of parsing a byte stream into a BsonDocument. Bson (Binary JSON) is a binary-encoded format for representing JSON-like documents. The BsonParser should be able to convert a byte stream into a BsonDocument if the input is formatted correctly.
Your ... | codefeedback |
You are tasked with implementing a simplified version of a Latent Structured Output Support Vector Machine (Latent SOSVM) in C++. The Latent SOSVM is a machine learning algorithm used for structured prediction tasks, where the output is a complex structure rather than a single label. In this problem, we will focus on t... | codefeedback |
You are tasked with implementing a Python function that loads a model based on the provided configuration parameters. The function should read the configuration file, extract the necessary parameters, and then use them to initialize the model with the appropriate settings. Your task is to complete the `load_model` func... | codefeedback |
You are working on a security application that needs to monitor the app names allowed by Exposure Notifications on an Android device. To achieve this, you decide to use Frida, a dynamic instrumentation toolkit, to interact with the Android device and retrieve the necessary information.
Your task is to write a Python s... | codefeedback |
You are tasked with creating a Bash script that processes a sequence of numbers and generates a specific output based on the input. The script should take a sequence of numbers as input and produce a JSON object as output. The JSON object should contain the following fields:
- "hops": The input sequence
- "name": A des... | codefeedback |
You are tasked with implementing a diagnostic fixer for a code editor. The code snippet provided is part of a method that takes a `Document`, an immutable array of `Diagnostic` objects, a `SyntaxEditor`, and a `CancellationToken` as parameters. The method iterates through the `diagnostics` and performs some operations ... | codefeedback |
You are tasked with implementing a custom `forEach` function in Swift that iterates over an array of items and applies a given closure to each item. The `forEach` function should take an array of items and a closure as input, and it should apply the closure to each item in the array.
The signature of the `forEach` fun... | codefeedback |
You are tasked with creating a custom template tag in Django to display a list of the most recent articles on a website. The tag should take an optional parameter to specify the number of articles to display. Additionally, you need to create another custom template tag to display an archive of all published articles.
... | codefeedback |
You are tasked with creating a Python function that determines the absolute path of a file given its relative path and the current working directory. Your function should take in the relative path as a string and return the absolute path as a string. You can assume that the relative path is valid and does not contain a... | codefeedback |
You are tasked with creating a script to automate the configuration of Redis server instances on a Linux system. The script should read a list of Redis configuration files from a specified directory and start a Redis server for each configuration file. Additionally, the script should set the maximum number of pending c... | codefeedback |
You are tasked with implementing a function that processes an HTTP response and constructs an appropriate error message based on the response status and any encountered errors. The function should handle reading the response body, checking the response status, and constructing an error message if necessary.
You are pr... | codefeedback |
You are tasked with implementing a custom data loader for a machine learning model using PyTorch. The data loader should be designed to handle a specific dataset and ensure that the loss can be computed accurately. Additionally, you need to initialize a neural network and allocate it to a specified device.
Your task i... | codefeedback |
You are working on a computer vision project and need to implement a mean Average Precision (mAP) evaluation metric for object detection. The mAP is a popular metric used to evaluate the performance of object detection algorithms. It measures the precision-recall curve and computes the average precision across multiple... | codefeedback |
You are tasked with implementing a function to calculate the sum of a list of numbers based on certain conditions. The function `sumListWork` takes in four parameters: `allowRepetitions` (a boolean indicating whether repetitions are allowed), `workingBase` (an integer representing the base for the sum calculation), and... | codefeedback |
You are tasked with creating a program that simulates a simple file path resolver. The program should take a file path as input and resolve it to the corresponding executable file path based on a predefined mapping.
You are given a mapping of file extensions to their corresponding executable file paths in a PHP associ... | codefeedback |
You are tasked with creating a scheduling system for a company that manages employee shifts. The system should be able to assign employees to different shifts based on their availability and the company's scheduling requirements. To achieve this, you need to implement a class called `ShiftScheduler` that will handle th... | codefeedback |
You are tasked with creating a secure authentication system for an admin panel. The code snippet provided is a part of the authentication process in a PHP application using the Laravel framework. The `Admin` model represents the administrators of the system. The snippet shows a query to check the existence of an admin ... | codefeedback |
You are tasked with implementing a custom word entry enumerator class in C++ that interfaces with a MySQL database. The class should be able to iterate through word entries retrieved from the database and store them for further processing.
Your task is to complete the implementation of the `WordEntryEnumerator_MySQL` ... | codefeedback |
You are tasked with creating a Python function that identifies and prints all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take two integer inputs, `start` and `end`, representing the inclusive range wit... | codefeedback |
You are tasked with creating a Python class that simulates a lazy bucket for uploading data to a cloud storage service. The class should have methods for uploading data from both strings and files. Additionally, the class should be tested using the `unittest` framework to ensure that the appropriate methods are called ... | codefeedback |
You are tasked with implementing a function to delete a node from a binary search tree. The function should take the root of the tree and the value of the node to be deleted as input, and return the root of the modified tree.
A binary search tree (BST) is a binary tree where for each node, all elements in its left sub... | codefeedback |
You are tasked with implementing a thread-safe dictionary data structure in C++. The dictionary should support the following operations:
1. Insertion of a key-value pair.
2. Retrieval of a value given a key.
3. Removal of a key-value pair.
4. Checking if a key exists in the dictionary.
You are provided with a partial ... | codefeedback |
You are tasked with creating a Python function that simulates a database migration process. In database migration, alterations to the structure of a database are defined in a series of scripts, and these alterations are applied to the database in a specific order. Each alteration script contains a set of operations to ... | codefeedback |
You are tasked with implementing a game move validation system. The game has a set of legal moves, and the user's input needs to be validated against these legal moves before being processed. The code snippet provided is a part of the move validation function. The function takes user input, validates it against the leg... | codefeedback |
You are tasked with implementing a complex number class in Python. A complex number is a number that comprises a real part and an imaginary part. The class should support addition of two complex numbers using the `+` operator.
You are given a code snippet that represents the addition of two complex numbers. Your task ... | codefeedback |
You are tasked with implementing a function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take two parameters, `start` and `end`, representing the inclusive range within whic... | codefeedback |
You are tasked with implementing a Python function that constructs a neural network backbone for semantic segmentation. The backbone is chosen based on the input parameters and is responsible for extracting features from the input image. The function should return the appropriate backbone model based on the specified a... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.