instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the balance. Additionally, the class should keep track of the number of transactions made on the account.
Your task is to implement the `BankAccount` c... | magicoder |
You are tasked with implementing a function that processes a dictionary of objects and extracts their coordinates. The function should handle cases where certain keys may not exist in the dictionary. The coordinates are obtained using the `get_coord()` method of the objects associated with the keys "N" and "O". If the ... | magicoder |
You are tasked with implementing a simple Python program that simulates a basic banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. The program should be implemented using object-oriented programming principles.
Your task is to complete the implementa... | magicoder |
You are tasked with creating a Python program that calculates the truncated value of a given floating-point number. The truncated value of a number is the integer part of the number without considering its decimal part. For example, the truncated value of 3.14 is 3, and the truncated value of -2.718 is -2.
Write a Pyt... | magicoder |
You are tasked with implementing a file adapter in Rust that can be used in both native and web assembly (WASM) environments. The file adapter should provide a unified interface for reading and writing files, and it should be able to handle the differences in file system access between native and web assembly environme... | magicoder |
You are tasked with implementing a function to calculate the mean of a list of numbers. The mean of a list of numbers is calculated by finding the sum of all the numbers in the list and then dividing the sum by the total number of elements in the list.
Write a Python function called `calculate_mean` that takes a list ... | magicoder |
You are given a PHP array `$input` that contains a nested structure of keys and values. The keys are strings, and the values can be either integers or arrays with the same structure. Your task is to write a function `flattenArray($input)` that takes this nested array as input and returns a flattened array where the key... | magicoder |
You are tasked with implementing a class to manage member flags for a data structure. The member flags can be set to indicate whether a member is optional, must-understand, a key, or default. Additionally, the class should handle the data type of the member.
Your task is to create a C++ class `MemberFlags` with the fo... | magicoder |
You are tasked with creating a program that simulates a basic command-line interface (CLI) for navigating a file system. Your program should support two commands: `ls` and `cd`. The `ls` command should list the contents of the current directory, and the `cd` command should change the current directory to the specified ... | magicoder |
You are tasked with implementing a TypeScript class that represents a simple identification card. The class should have a constructor that takes in two private properties: `identification` of type string and `name` of type string. Additionally, the class should have a method `getDetails` that returns a string containin... | magicoder |
You are tasked with implementing a Python function that processes the output of a machine learning model and calculates the evaluation metrics for a binary classification task. The function takes in the predicted labels, target labels, and the loss from the model's output and returns the evaluation metrics.
The functi... | magicoder |
You are tasked with writing a script to automate the creation of a cluster and partition in a distributed computing environment. The script should use the provided list of agents and execute specific commands to set up the cluster and partition.
Given the following code snippet as inspiration:
```bash
AGENTS2="ag.14.... | magicoder |
You are tasked with implementing a function to verify a digital signature using a given public key and a magic number. The function should return a slice of the input data if the signature is valid, or an error message if the signature is too short or invalid.
You are given the following code snippet as a starting poi... | magicoder |
You are tasked with implementing a simple event system in a game development scenario. The provided code snippet is a part of a game script that handles user interactions with buttons in the game environment. The script uses Unity's C# API for handling button clicks. The `hit` variable represents a raycast hit on a gam... | magicoder |
You are tasked with implementing a Python function that validates a list of software requirements based on a given version number. The requirements are specified up to the minor version to allow bugfixes to be automatically applied. The function should return a list of requirements that are satisfied by the given versi... | magicoder |
You are working on a computer vision project and need to implement image augmentation using the `albumentations` library in Python. The `albumentations` library is a popular choice for performing a variety of image augmentation techniques such as rotation, flipping, scaling, and more. Your task is to create a function ... | magicoder |
You are tasked with creating a simple calculator application using Python and PyQt. The application should have two input spin boxes for entering numbers and a label to display the result of the addition operation. The label should also display the text "+" between the input numbers. Your task is to implement the neces... | magicoder |
You are tasked with creating a database migration for a hotel management system using Laravel's migration feature. The migration should create a table for rooms with the following specifications:
- The table should be created in the 'mysql_front' database connection.
- It should have an 'id' field as the primary key.
... | magicoder |
You are tasked with creating a password validation function for a web application using Django. The function should adhere to the password validation settings specified in the `AUTH_PASSWORD_VALIDATORS` list. The settings are defined as a list of dictionaries, each containing a set of rules for password validation. Eac... | magicoder |
You are tasked with implementing a simple PIN input system for a digital lock. The system should accept a 4-digit PIN and perform certain actions based on the input. You are given a code snippet that handles the digit input and checks the length of the PIN. Your task is to complete the implementation by adding the nece... | magicoder |
You are tasked with creating a Python function that processes a collection of image files in a specified directory. The function should read each image file, perform a specific operation, and then save the processed image to a new directory. You are given a code snippet that demonstrates how to iterate through the imag... | magicoder |
You are tasked with creating a Python function to update the internet availability status of apartments based on their distance from a GPS location. You are given a code snippet that includes a function to calculate the distance between two GPS coordinates and a function to update the internet availability status of ap... | magicoder |
You are tasked with implementing a simple scene transition system in Unity using C#. The provided code snippet is a starting point for the implementation. Your task is to complete the implementation by adding the necessary code to smoothly transition between scenes.
You need to implement the following functionalities:... | magicoder |
You are tasked with implementing a function that processes a batch of data for cloud synchronization. The function should take a list of data items and upload them to the cloud in batches, ensuring that each batch does not exceed a specified maximum size. Additionally, the function should handle any potential errors th... | magicoder |
You are tasked with implementing a simplified version of a trade API for a cryptocurrency exchange. The provided code snippet is a partial implementation of the `trade_api` method within a Python class. Your task is to complete the implementation of the `trade_api` method by adding the necessary logic to handle the tra... | magicoder |
You are working on a statistical analysis project and need to write a Python function to calculate the variance-covariance matrix for a set of external variables. The variance-covariance matrix is a square matrix that contains the variances of the variables on the main diagonal and the covariances between each pair of ... | magicoder |
You are tasked with creating a Python class to manage cryptocurrency trading fees for different exchanges. The class should allow for the retrieval and manipulation of fee information for various trading pairs on different exchanges.
You are provided with a code snippet that contains some initial configuration setting... | magicoder |
You are tasked with implementing a Python function to determine whether a given set of cards forms a valid "Set" according to the rules of the Set card game. In the game of Set, each card has four features: color, shape, number, and shading. A set of three cards is considered valid if, for each feature, the three cards... | magicoder |
You are given a Python function that computes the relative entropy of two time series. The function takes in two time series `xs` and `ys`, where `ys` can be a sequence or a `numpy.ndarray`. The function also takes parameters `b` and `local`, and returns the local or global relative entropy as a float or `numpy.ndarray... | magicoder |
You are working on a project that involves managing a large number of JavaScript files and libraries. Your task is to write a script that organizes these files into separate categories based on their file extensions. The script should categorize the files into three groups: "helpers" for files with the ".js" extension,... | magicoder |
You are given a function `solution(n)` that takes an integer `n` as input and returns the sum of all positive integers less than `n` that are multiples of 3 or 5. For example, if `n` is 10, the function should return the sum of 3, 5, 6, and 9, which is 23.
Write a function `solution(n)` to solve the problem.
Function... | magicoder |
You are working for a biotechnology company that is conducting research on the production of certain genes under different temperature conditions. The company has collected data on the production levels of each gene under two different temperature conditions and the associated induction costs. Your task is to write a P... | magicoder |
You are tasked with creating a Python class that represents settings for limiting the number of trials in an automated machine learning (AutoML) process. The class should include a field for the maximum number of trials and a method for creating an instance of the class from a dictionary of data.
Your task is to imple... | magicoder |
You are tasked with implementing a simple configuration management system in Rust. The system should allow users to define and access common configuration settings for a variety of components. To achieve this, you need to create a `ConfigManager` struct and implement methods to set and retrieve common configuration set... | magicoder |
You are tasked with implementing a custom view in Swift that displays an image and a title label. The provided code snippet is a part of a custom view class. The `titleLabel` is a `UILabel` instance that is configured with a bold system font, white text color, and centered text alignment. The `imageView` is an instance... | magicoder |
You are tasked with creating a Python function that reads configuration values from a .env file and performs specific operations based on the retrieved values. The .env file contains key-value pairs in the format `KEY=VALUE`, where each key represents a configuration parameter and its corresponding value. The code snip... | magicoder |
You are working on a caching system for fetching and storing Gists from GitHub. You have been given a code snippet that includes two functions: `set_cache` and `fetch_gist`. Your task is to complete the implementation of the `fetch_gist` function and handle the case when the response status code is not 200.
The `set_c... | magicoder |
You are tasked with creating a JavaScript module that exports a schema object. The schema object will define the structure and constraints for a specific data model. Your task is to implement the schema object with the following requirements:
The schema object should have a property named "fields" which is an array of... | magicoder |
You are tasked with creating a Python class for interfacing with a measurement instrument. The class should have methods for measuring resistance and frequency. The `measureResistance` method should take in the board and switch numbers, and optionally the range and resolution, and return the measured resistance. The `m... | magicoder |
You are tasked with creating a Bash script to process a batch of image files and generate tiled features for each image. The script should take input parameters for the input directory, output directory, and tile size. The script should use ImageMagick to process the images and create tiled features based on the specif... | magicoder |
You are tasked with designing a database schema for a simple task management system. The system should allow users to register and update tasks, and it should track the user who registered and updated each task. To achieve this, you need to create a database schema with appropriate foreign key constraints.
Your task i... | magicoder |
You are tasked with implementing a function that simulates the behavior of the `export` keyword in JavaScript. The `export` keyword is used to export functions, objects, or primitive values from a module so that they can be imported and used in other modules. Your task is to create a function that takes in an object re... | magicoder |
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... | magicoder |
You are tasked with implementing a function that processes an array of objects representing different types of prosthetic limbs. Each object contains a "value" representing the type of prosthetic limb and a "thumb" property representing a thumbnail image associated with that type. Your goal is to create a function that... | magicoder |
You are tasked with creating a Python class decorator that adds a prefix to the fields of a form. The decorator should take the prefix as an argument and modify the field names accordingly. Your task is to implement the `add_prefix` decorator and apply it to the `Meta` class of the `SubscribeUserForm` class. The `Subsc... | magicoder |
You are working on a plugin system for a software application. The system allows users to define plugins using key-value pairs, where the key represents the plugin name and the value represents the plugin functionality. The plugin functionality can be a single value or a list of values.
Your task is to implement a fun... | magicoder |
You are tasked with implementing a clocked flip-flop using the provided trait `Clocked`. The `Clocked` trait defines methods for handling rising and falling edges of a clock signal. Your goal is to create a specific implementation of this trait for a D flip-flop, a fundamental building block in digital circuit design.
... | magicoder |
You are tasked with implementing a Python class to represent a simulation model for a 1+1+1D Discrete Fracture Network (DFN). The provided code snippet gives a partial representation of the model, including the dimensionality and thermal properties. Your task is to complete the implementation of the `DFNModel` class by... | magicoder |
You are tasked with implementing a function that takes in a list of strings representing key names and returns the most frequently occurring key name. If there are multiple key names with the same highest frequency, return the one that appears first in the list. If the input list is empty, return None.
The function si... | magicoder |
You are tasked with creating a Python function that processes a list of resources and returns a modified version of the list. Each resource is represented as a dictionary with various attributes. The function should remove certain attributes from each resource based on a provided list of exclusions.
Write a function c... | magicoder |
You are tasked with creating a Python function that calculates the distance between two geographic coordinates using the Haversine formula. The Haversine formula is used to calculate the distance between two points on the surface of a sphere given their longitudes and latitudes. You are given a list of geographic coord... | magicoder |
You are tasked with creating a simple command-line utility that processes a given input string and performs a specific operation on it. Your program should take a single input string and apply a transformation to it based on a set of rules. The transformation involves counting the occurrences of each character in the i... | magicoder |
You are tasked with creating a Python class to handle connections to a DVRIP (Digital Video Recorder Internet Protocol) client. The DVRIPClient class should establish a TCP connection to a specified host and port, and then authenticate using a given username and password. Your task is to implement the DVRIPClient class... | magicoder |
You are tasked with creating a command-line interface (CLI) tool for managing and checking files within a directory. The tool should be able to perform various operations such as checking the existence of files, verifying file types, and generating reports based on the file contents.
Your task is to implement a functi... | magicoder |
You are tasked with creating a Rust program that simulates a simple computer system. The computer system consists of several modules, each responsible for a specific aspect of the system. The provided code snippet shows the modules that are part of the system:
```rust
//! which is represented as steps of computation m... | magicoder |
You are tasked with implementing a method to find the next prime number after a given starting point. You need to create a Python class `PrimeGenerator` with a method `newmeth(self, start)` that takes an integer `start` as input and returns the next prime number greater than `start`. You should use the Sieve of Eratost... | magicoder |
You are tasked with implementing a reinforcement learning algorithm using the Twin Delayed Deep Deterministic Policy Gradient (TD3) approach. TD3 is an off-policy algorithm for continuous action spaces, which aims to learn a deterministic policy that maximizes the expected cumulative reward. In this problem, you will f... | magicoder |
You are tasked with creating a Python script that parses a given source code file and extracts the name and email of the author from the copyright notice. The copyright notice is in the format shown in the code snippet below:
```python
# Copyright and Distribution
#
# Part of SimplePyGA: Simple Genetic Algorithms in... | magicoder |
You are tasked with implementing a distributed training system for a machine learning model. The system consists of multiple replicas running on different ranks, and communication between replicas is facilitated using broadcast operations. Additionally, each replica needs to consolidate its state dictionary and update ... | magicoder |
You are tasked with creating a PHP class that processes a given string and number. The class should have a method that performs a specific operation on the string based on the number provided. Your task is to implement the method `processString` in the `StringProcessor` class.
The `StringProcessor` class should have t... | magicoder |
You are tasked with implementing a custom data structure in C# that represents a const-terminated auto string pointer. The struct LPCTSTR is defined with the StructLayout attribute set to LayoutKind.Sequential and implements the IConstTerminatedAutoStringPointer interface. Your goal is to create a C# class that uses LP... | magicoder |
You are tasked with implementing a simple shell script that processes a given file and performs specific operations based on the content of the file. The file contains a series of commands, each on a new line. Your task is to write a shell script that reads each line of the file and executes the corresponding command. ... | magicoder |
You are given a Rust code snippet that defines a macro and a `Copy`-annotated struct. Your task is to implement a function that uses the macro to extract the field value from a reference to the struct.
The macro is defined as follows:
```rust
macro_rules! extract_field {
($field:ident, _) => $field,
}
```
The `C... | magicoder |
You are working on a system that processes and updates lists of data based on certain conditions. The code snippet provided is a part of a larger system and is responsible for filtering and updating lists based on specific criteria. The code snippet includes a conditional block that iterates through `LIST1` and appends... | magicoder |
You are tasked with implementing a function to check and fix a given directory path. The function should ensure that the directory path ends with a forward slash ("/"). If the given directory path does not end with a forward slash, the function should append it to the path and return the corrected directory path.
Writ... | magicoder |
You are tasked with implementing a function that takes a string as input and returns a modified version of the string. The modification involves replacing each character in the string with its corresponding URL-encoded value. The URL-encoded value for a character is represented as a '%' followed by the ASCII code of th... | magicoder |
You are tasked with creating a function that parses HTML code and extracts the content within specific HTML tags. Your function should take in the HTML code as a string and the tag name as a parameter, and return a list of all the content within the specified tags.
For example, given the following HTML code snippet:
`... | magicoder |
You are tasked with creating a Python program that simulates a simple library management system. The system should allow users to add, remove, and display books in the library. Each book will have a title, author, and genre. Additionally, the program should provide the functionality to search for books by title or auth... | magicoder |
You are tasked with simulating the behavior of a robot in a game environment. The robot has the ability to shake trees to collect resources. The robot can sense the nearest neutral tree and attempt to shake it to collect resources. However, the shaking action may fail due to various reasons. Your task is to implement a... | magicoder |
You are tasked with implementing a binary search tree (BST) in Python. A binary search tree is a binary tree in which for each node, the left child is less than the parent and the right child is greater than the parent. You need to implement the deletion operation for the BST.
You are given a code snippet that handles... | magicoder |
You are tasked with implementing a function to parse and normalize JSON data. The function should handle potential errors during processing and include relevant information in the response object.
Write a function `normalizeJSONData` that takes in a parameter `data` and returns an object with the following properties:... | magicoder |
You are tasked with creating a simple web application using Node.js and Express. Your application should have a controller for handling TikTok-related functionality. The TikTokController should handle requests related to fetching, creating, updating, and deleting TikTok videos. To achieve this, you need to implement th... | magicoder |
You are tasked with implementing a custom DispatchQueue extension in Swift that provides a convenient way to execute a closure on a specific dispatch queue. The extension should include a method that takes a DispatchLevel enum value and a closure, and then dispatches the closure to the corresponding DispatchQueue type.... | magicoder |
You are tasked with creating a Swift program to process user data from a JSON file. The program should define a structure to represent user information and implement a method to decode the JSON data into instances of this structure. Additionally, the program should include a function to filter users based on a specifie... | magicoder |
You are tasked with creating a Python function that generates a custom JavaScript callback for a Bokeh Slider widget. The custom JavaScript callback should update the value of a target widget based on the value of the Slider. The function should take the target widget and the JavaScript code as input and return the Cus... | magicoder |
You are tasked with implementing a function that reads the first line of a file and returns it as a string. You are given a code snippet that partially implements this functionality using Rust's standard library. Your task is to complete the implementation of the function `read_first_line` by filling in the missing cod... | magicoder |
You are tasked with creating a Python function that processes a list of migration operations and extracts specific information from it. Each operation in the list is an instance of `migrations.AlterModelOptions` with different configurations. Your goal is to extract the model name and the permissions associated with ea... | magicoder |
You are tasked with implementing a function to manage time zone settings in a web application using Python and Django. The function `set_timezone(request)` is responsible for updating the time zone setting based on user input. The function checks if the HTTP request method is POST, and if so, it updates the time zone i... | magicoder |
You are working on a data processing pipeline for aggregating and manipulating netCDF files. The code snippet provided is a part of this pipeline and involves file manipulation using the `glob` and `subprocess` modules in Python. Your task is to understand the code and identify potential issues or improvements.
Given ... | magicoder |
You are tasked with creating a Python function that processes a requirements file and extracts the required packages for installation. The function should read the contents of the file, filter out any commented lines, and return a list of required packages.
You are given a code snippet that attempts to read the conten... | magicoder |
You are tasked with implementing a simple dependency injection mechanism in a Java application using the Spring framework. Your goal is to create a class that utilizes the `@Autowired` and `@Qualifier` annotations to inject an `EntityManager` instance into a private field. The `@Qualifier` annotation is used to specify... | magicoder |
You are tasked with implementing a Python function that retrieves the current authenticated user from a user database. The function should take a token as input and return the corresponding user if the token is valid. If the token is invalid or does not correspond to any user, the function should return `None`.
You ar... | magicoder |
You are given a string `s` consisting of lowercase English letters. Your task is to write a function or method to determine the frequency of each letter in the string and return the result as a dictionary where the keys are the letters and the values are their respective frequencies.
For example, given the string `s =... | magicoder |
You are tasked with creating a Python function that interacts with Google BigQuery to retrieve query results in a paginated manner. The function should take a BigQuery service object, a query string, and a page token as input, and return a list of results obtained from the query. The function should handle pagination b... | magicoder |
You are tasked with implementing a file compression and decompression utility using the Brotli compression algorithm. Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding, and 2nd order context modeling.
Your task ... | magicoder |
You are working on a web application that manages proposal spaces for various events. The application uses a database to store information about these proposal spaces. The database schema is managed using Alembic, a database migration tool for SQLAlchemy.
Your task is to create a Python function that generates a SQL q... | magicoder |
You are given a square matrix `a` of size `n x n` and an integer `k`. Your task is to write a program to extract specific elements from the matrix and print them in a specific order.
You need to perform the following steps:
1. Extract elements from the matrix `a` based on the following rules:
- Take the elements fr... | magicoder |
You are tasked with implementing a custom data structure that represents a functional programming concept. The structure should support various operations and functionalities related to functional programming. Your task is to design and implement a class or module that encapsulates this functionality.
Your custom data... | magicoder |
You are tasked with creating a Python script to automate the process of generating and publishing content for a website. The script should load data, generate works and a timeline, build the HTML files, and then publish the output to a remote server using rsync over SSH.
Your task is to implement the Python script to ... | magicoder |
You are tasked with implementing a class that performs data reconstruction using a specific algorithm. The class has a property `reconstructed_data_vector` that needs to be defined. The algorithm for reconstructing the data vector is as follows:
1. The input data vector is a list of integers.
2. The reconstructed data... | magicoder |
You are tasked with implementing a function to validate user session tokens in a TypeScript application. The user session token is represented by the `UserSessionToken` type, which contains the following fields:
- `id`: a string representing the user's unique identifier
- `role`: a number representing the user's role
-... | magicoder |
You are given a list of integers representing the scores of a game. The game has a rule that whenever a score of 0 is encountered, the game ends and the player's final score is calculated. The final score is the product of all the non-zero scores encountered before the first 0. Your task is to write a function to deter... | magicoder |
You are tasked with implementing a function to calculate the CIGAR (Concise Idiosyncratic Gapped Alignment Report) operations for sequence alignment. The CIGAR string is a compact representation of sequence alignment, commonly used in bioinformatics. The CIGAR string consists of a series of operation-length pairs, wher... | magicoder |
You are tasked with implementing a function that calculates the total number of injuries in a sports team over a given period of time. The function takes in an array of integers representing the number of injuries each day. However, the team has a recovery rate, meaning that the number of injuries on a given day is inf... | magicoder |
You are tasked with implementing a class that manages resource bundle information for a refactoring tool. The class should handle the setting of an accessor package and the determination of a resource bundle name based on a given class reference.
You are provided with a code snippet that demonstrates part of the funct... | magicoder |
You are tasked with implementing a message processing system for a file management application. The system should handle incoming messages and perform specific actions based on the message content. Your task is to complete the implementation of the `_process_message` method in the given Python class.
The `_process_mes... | magicoder |
You are tasked with implementing a custom sorting algorithm for a list of user objects based on their first name, last name, and username. Each user object has attributes `first_name`, `last_name`, and `username`. The sorting should follow the order: first by `first_name`, then by `last_name`, and finally by `username`... | magicoder |
You are tasked with creating a Python function that calculates the angle between two lines and plots the angle on a graph. The function `get_angle_plot` takes in two lines, a radius, color, origin, and the lengths of the x and y axes. It then calculates the angle between `line1` and the x-axis and plots the angle on a ... | magicoder |
You are working with a dataset containing bibliographic information from the DBLP (Digital Bibliography & Library Project) in RDF (Resource Description Framework) format. The dataset includes information about publications, authors, and their relationships. Your task is to write a SPARQL query to retrieve the distinct ... | magicoder |
You are tasked with designing a routing system for a web application using Laravel framework. The given code snippet represents the routes defined in the `web.php` file of a Laravel application. Each route maps to a specific controller method and may have additional attributes like route names.
Your task is to create ... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.