source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 25,689 | Write a Python function `move_bullet` that simulates the movement of a bullet in a 2D game environment. The function should update the position of the bullet based on its current velocity and direction when the bullet is in motion. When the bullet is not in motion, the function should decrement the `bcount` variable by... | Here is the Python code to solve the given problem in the markdown block:
```python
def move_bullet(bullet_position: tuple, bullet_velocity: tuple, is_in_motion: bool, bcount: int) -> tuple:
"""
Simulates the movement of a bullet in a 2D game environment.
Args:
bullet_position (tuple): A tuple of t... |
magic_instruct_75k | 25,690 | Write a Python function to match a given URL to its corresponding handler class from a list of URL patterns. Each URL pattern is a tuple where the first element is the URL pattern (a string) and the second element is the handler class. The function should return the handler class if a match is found, otherwise it shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Type, Optional
def match_url_to_handler(url: str, url_patterns: List[Tuple[str, Type]]) -> Optional[Type]:
"""
Matches a given URL to its corresponding handler class from a list of URL patterns.
... |
magic_instruct_75k | 25,696 | Create a Python function to manage a collection of integers with basic operations for adding, removing, and retrieving elements. Additionally, the function should support finding the maximum and minimum elements in the collection. The function should be designed to handle a list of integers and provide the following op... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def manage_collection(collection: List[int], operation: str, value: Optional[int] = None) -> List[int]:
"""
Manages a collection of integers with basic operations for adding, removing, retrievi... |
magic_instruct_75k | 25,723 | Write a Python function to count the occurrences of each type of Django migration operation in a given list of operations. Each operation is represented as a string in the format "migrations.OperationName". The types of operations to count include "AddField", "RemoveField", "AlterField", and "CreateModel". The function... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_migration_operations(operations: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each type of Django migration operation in a given list.
Args:
operations (List[s... |
magic_instruct_75k | 25,725 | Write a Python function to simulate the interaction with the InterPlanetary File System (IPFS) using a provided shared library. The function should perform the following tasks:
1. Connect to the IPFS network.
2. Add a file to the IPFS network.
3. Retrieve the added file from the IPFS network.
4. Display the content of ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import hashlib
def interact_with_ipfs(file_content: str) -> Tuple[str, str]:
"""
Simulate the interaction with the InterPlanetary File System (IPFS) using a shared library.
Args:
file_conte... |
magic_instruct_75k | 25,733 | Implement the missing functions `find_fst_iv` and `find_fst_i` that are used to find the first element in a list that satisfies a given condition. The `find_fst_iv` function should return the first index of an element in the list that satisfies the given condition, and the `find_fst_i` function should return the first ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable, Any
def find_fst_iv(ol: List[Any], test_func: Callable[[Any, Any], bool], value: Any) -> int:
"""
Find the first index of an element in the list that satisfies the given condition.
Args:
... |
magic_instruct_75k | 25,749 | Write a Python function to organize the parameters of a neural network model into a dictionary based on their respective layers. The model consists of a text encoder, an embedding layer, and a hierarchical attention-based graph model (hiagm). The function should return a dictionary where each key corresponds to a layer... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def organize_params(text_encoder_params: List[Any], embedding_params: List[Any], hiagm_params: List[Any]) -> Dict[str, List[Any]]:
"""
Organizes the parameters of a neural network model into a... |
magic_instruct_75k | 25,754 | Write a Python function to simulate a simple notification system. The function should produce different types of notifications based on the status provided, and it should handle sound playback synchronously or asynchronously. Additionally, the function should have the option to raise an exception or send a warning when... | Here is the Python code to solve the given problem in the markdown block:
```python
def notify(status: str, sync: bool = False, raise_error: bool = False) -> str:
"""
Simulate a notification system that produces different types of notifications and handles sound playback.
Args:
status (str): A stri... |
magic_instruct_75k | 25,760 | Write a Python function to process a list of classifiers and return a dictionary containing the count of each unique main category. Each classifier is a string representing a category in the format "Category :: Subcategory". The function should ignore the subcategories and only consider the main categories for counting... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_classifiers(classifiers: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique main category from a list of classifiers.
Args:
classifiers (List[str]): A li... |
magic_instruct_75k | 25,762 | Write a Python function to resolve the version of a JAR file from a remote repository based on the provided version string. If the version is "RELEASE" or "LATEST", the function should simulate resolving the version using a custom function `resolve_version`. The function should also handle the conversion of group and a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def resolve_version(version: str) -> str:
"""
Simulate resolving the version of the JAR file.
Args:
version (str): The version string to resolve.
Returns:
str: The res... |
magic_instruct_75k | 25,775 | Write a Python function `generate_import_paths` that processes a list of Python module names and returns a dictionary containing the module names as keys and their corresponding import paths as values. The import paths should be constructed using the standard Python module import syntax.
The function should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_import_paths(module_names: List[str]) -> Dict[str, str]:
"""
Generates a dictionary of Python module names and their corresponding import paths.
Args:
module_names (List[s... |
magic_instruct_75k | 25,798 | Write a Python function to calculate the sum of all the digits in a given integer. The function should handle both positive and negative integers. The code should start with:
```python
def calculate_digit_sum(num: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_digit_sum(num: int) -> int:
"""
Calculate the sum of all the digits in a given integer.
Args:
num (int): The integer whose digits are to be summed.
Returns:
int: The sum of the digits of t... |
magic_instruct_75k | 25,807 | Write a Python function to update the number of cookies a person has in a given dictionary. The dictionary contains information about the number of cookies each person has, where the keys are the names of the people and the values are the number of cookies. The function should take the initial dictionary, a person's na... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def update_cookies(c: Dict[str, int], name: str, cookies: int) -> Dict[str, int]:
"""
Updates the number of cookies a person has in the given dictionary.
Args:
c (Dict[str, int]): The initia... |
magic_instruct_75k | 25,828 | Write a Python function to process a directory containing executable files. The function should iterate through each file in the specified directory, check if it is a regular file, readable, and executable, and if so, execute the file. The function should be named `execute_files` and should take the directory path as a... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
def execute_files(directory_path: str) -> None:
"""
Processes a directory containing executable files. Iterates through each file in the specified directory,
checks if it is a regular file, reada... |
magic_instruct_75k | 25,839 | Write a Python function to count the occurrences of each unique character in a given string, ignoring whitespace and treating characters in a case-insensitive manner. The function should return a dictionary where the keys are the unique characters and the values are their respective counts.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_unique_characters(input_string: str) -> dict:
"""
Counts the occurrences of each unique character in the input string, ignoring whitespace and case sensitivity.
Args:
input_string (str): The input string t... |
magic_instruct_75k | 25,842 | Write a Python function to calculate the total cost of a customer's purchase and format it as a currency value in Brazilian currency (R$). The function should take a list of item prices as input, calculate the total cost, and return the total cost formatted as a string with the Brazilian currency symbol "R$" followed b... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_and_format_cost(prices: List[float]) -> str:
"""
Calculate the total cost of a customer's purchase and format it as a currency value in Brazilian currency.
Args:
prices (List[f... |
magic_instruct_75k | 25,843 | Write a Python function to generate a random dataset for a classification problem. The function should produce a random stochastic matrix representing the input features and a random real-valued tensor representing the target labels. The function should have the following signature:
```python
import numpy as np
def g... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def generate_random_dataset(n_examples: int, n_features: int, n_classes: int, standardize: bool = False) -> tuple:
"""
Generate a random dataset for a classification problem.
Args:
n_examples (in... |
magic_instruct_75k | 25,845 | Write a Python function to process a list of tuples representing product data and return a dictionary containing the count of unique values for each category. Each tuple contains the product name as the first element and a list of categories as the second element. The function should ignore duplicate product names and ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def count_unique_categories(products: List[Tuple[str, List[str]]]) -> Dict[str, int]:
"""
Counts the number of unique categories for each product in the given list of product data.
Args... |
magic_instruct_75k | 25,854 | Write a Python function to calculate credit amounts for different types of customers based on the value of the `credit` variable. The function should return a dictionary with specific keys and values depending on whether the `credit` is "lnd" or not.
The function should start with:
```python
def calculate_credit(credi... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_credit(credit: str) -> dict:
"""
Calculate credit amounts for different types of customers based on the value of the `credit` variable.
Args:
credit (str): The type of credit. If "lnd", specific values... |
magic_instruct_75k | 25,860 | Write a Python function to interpret a sequence of commands for a remote control device and output the corresponding actions. The function should take a string of commands as input and return a list of corresponding actions. Each command in the input string should be mapped to its corresponding action using a predefine... | Here is the Python code to solve the given problem in the markdown block:
```python
def command_interpreter(commands: str) -> list:
"""
Interprets a sequence of commands for a remote control device and returns the corresponding actions.
Args:
commands (str): A string of commands to be interpreted.
... |
magic_instruct_75k | 25,878 | Write a Python function to extract the domain name from a given URL. The domain name is defined as the sequence of characters between the "http://" or "https://" and the next "/" in the URL. The function should handle URLs that always start with either "http://" or "https://" and contain at least one "/". The function ... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_domain_name(url: str) -> str:
"""
Extracts the domain name from a given URL.
The domain name is defined as the sequence of characters between the "http://" or "https://"
and the next "/" in the URL.
Arg... |
magic_instruct_75k | 25,882 | Write a Python function to calculate the average rating for each product from a given list of dictionaries. Each dictionary contains the product name, date, and rating. The function should return a dictionary with product names as keys and their average ratings as values.
The code should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def calculate_average_ratings(ratings: List[Dict[str, any]]) -> Dict[str, float]:
"""
Calculate the average rating for each product from a list of dictionaries.
Args:
ratings (List[Dic... |
magic_instruct_75k | 25,899 | Write a Python function `construct_output` that constructs an output dictionary based on certain conditions and input data. The function takes in two dictionaries, `summaries` and `processed_constraints`, and two other variables, `int_jac` and `int_hess`. The `processed_constraints` dictionary contains information abou... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_output(summaries: dict, processed_constraints: bool, int_jac: int, int_hess: int) -> dict:
"""
Constructs an output dictionary based on the given conditions and input data.
Args:
summaries (dict): A di... |
magic_instruct_75k | 25,904 | Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given a list of integers representing the daily stock prices. If it is not possible to make any profit, the function should return 0.
The function should start with:
```python
from typing import Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def maxProfit(prices: List[int]) -> int:
"""
Calculate the maximum profit that can be obtained by buying and selling a stock at most once.
Args:
prices (List[int]): A list of integers repres... |
magic_instruct_75k | 25,911 | Write a Python function to filter Reddit submissions based on a minimum upvotes limit and return a list of submissions that meet the criteria. Each submission is represented as an object containing information such as title, upvotes, and content. The function should return a list of submissions that have upvotes greate... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, NamedTuple
class Submission(NamedTuple):
title: str
upvotes: int
content: str
def send_simple(submissions: List[Submission], min_upvotes_limit: int) -> List[Submission]:
"""
Filters Reddit ... |
magic_instruct_75k | 25,917 | Write a Python function to perform a lookup in a dictionary and return the corresponding value for a given key. If the key is not found in the dictionary, the function should return a default value. The function should handle cases where the key is not present and should return the default value in such instances. The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def lookup(dictionary, key, default=None):
"""
Perform a lookup in a dictionary and return the corresponding value for a given key.
If the key is not found in the dictionary, return a default value.
Args:
dictio... |
magic_instruct_75k | 25,933 | Write a Python function to count the number of even numbers in a given list of integers. The function should return the count of even numbers. The code should start with:
```python
from typing import List
def count_even_numbers(src: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_even_numbers(src: List[int]) -> int:
"""
Counts the number of even numbers in a given list of integers.
Args:
src (List[int]): The list of integers to count even numbers from.
... |
magic_instruct_75k | 25,940 | Write a Python function to map the text of each button to its associated style from a list of button objects. Each button object has properties `Text` and `Style`. The function should return a dictionary where the keys are the button texts and the values are the associated styles.
The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def map_button_styles(buttons: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Maps the text of each button to its associated style from a list of button objects.
Args:
buttons (List... |
magic_instruct_75k | 25,953 | Write a Python function to simulate the execution of a set of instructions and determine the value of the accumulator when the program terminates. The program terminates when an instruction is about to be executed a second time. The instructions are provided as a list of strings, where each string represents an instruc... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_accumulator_value(instructions: List[str]) -> int:
"""
Simulate the execution of a set of instructions and determine the value of the accumulator
when the program terminates. The program ter... |
magic_instruct_75k | 25,955 | Write a Python function to estimate the executor memory for a batch processing application based on the total RAM of the system. The function should take the total RAM of the system as an integer input and return the estimated executor memory as a float. The estimation should be calculated using the formula:
```
execut... | Here is the Python code to solve the given problem in the markdown block:
```python
def estimate_executor_memory(total_ram: int) -> float:
"""
Estimate the executor memory for a batch processing application based on the total RAM of the system.
Args:
total_ram (int): The total RAM of the system in ... |
magic_instruct_75k | 25,956 | Write a Python function to find all prime numbers up to a given integer `n` using the Sieve of Eratosthenes algorithm. The function should return a list of all prime numbers less than or equal to `n`.
The code should start with:
```python
from typing import List
def sieve_of_eratosthenes(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sieve_of_eratosthenes(n: int) -> List[int]:
"""
Find all prime numbers up to a given integer `n` using the Sieve of Eratosthenes algorithm.
Args:
n (int): The upper limit to find all pri... |
magic_instruct_75k | 25,966 | Write a Python function to filter out duplicate vouchers from a given list of vouchers and return a list containing only the unique vouchers in the same order as they appear in the input list. A voucher is represented as a string and is considered unique if it does not appear more than once in the input list. The funct... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def getUniqueVouchers(vouchers: List[str]) -> List[str]:
"""
Returns a list of unique vouchers from the input list, maintaining the order of their first appearance.
Args:
vouchers (List[str]... |
magic_instruct_75k | 25,986 | Write a Python function to merge two sorted arrays into a single sorted array. The function should take in two arrays of integers, `arr1` and `arr2`, and return a new array containing all elements from both input arrays in sorted order. The function should handle arrays of different lengths and should not modify the in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def mergeSortedArrays(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Merges two sorted arrays into a single sorted array.
Args:
arr1 (List[int]): The first sorted array.
arr2 (L... |
magic_instruct_75k | 25,996 | Write a Python function to find the "source number" in a given list of integers. The source number is defined as the number that appears only once in the list, while all other numbers appear exactly twice. If no such number exists, the function should return 0.
The function should start with:
```python
from typing imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def src_number(nums: List[int]) -> int:
"""
Find the source number in a list of integers. The source number is the number that appears only once,
while all other numbers appear exactly twice. If no s... |
magic_instruct_75k | 26,002 | Write a Python function to extract the repository name and the star range from a given code snippet, and then perform the following operations:
1. Print the extracted repository name.
2. Print all the integers within the star range (inclusive of the upper and lower bounds) in ascending order, separated by a space.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def extract_and_print_repo_info(code_snippet: str):
"""
Extracts the repository name and the star range from a given code snippet,
and prints the repository name and all integers within the star range.
Args:
... |
magic_instruct_75k | 26,014 | Write a Python function to automate the cleanup of a specific file in a given directory. The function should remove a file named `server.pid` located in the specified directory. Additionally, the function should handle the case where the file does not exist and should not raise an error in that scenario.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def remove_pid_file(directory: str) -> None:
"""
Removes the file 'server.pid' from the specified directory if it exists.
If the file does not exist, the function does nothing and does not raise an error.
Arg... |
magic_instruct_75k | 26,017 | Write a Python function to update the production data of a power plant based on the given raw data and generation mapping. The raw data contains energy values produced by different sources, and the generation mapping specifies how these values should be aggregated into the production data. The function should take the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def update_production_data(raw_data: Dict[str, Dict[str, float]], GENERATION_MAPPING: Dict[str, str], initial_production: Dict[str, float]) -> Dict[str, float]:
"""
Updates the production data of a power... |
magic_instruct_75k | 26,030 | Write a Python function to process and update two dictionaries, `bokeh_sequences` and `bokeh_mappings`, with new data from two other dictionaries, `seqs` and `maps`. The function should update the original dictionaries and return them as a tuple. The code should start with:
```python
from typing import Dict, Tuple
def... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple
def process_bokeh_data(bokeh_sequences: Dict[str, list], bokeh_mappings: Dict[str, dict], seqs: Dict[str, list], maps: Dict[str, dict]) -> Tuple[Dict[str, list], Dict[str, dict]]:
"""
Updates the ... |
magic_instruct_75k | 26,036 | Write a Python function to generate a unique verification code of a specified length. The verification code should consist of uppercase letters, lowercase letters, and digits. The function should ensure that the generated code is unique for each invocation. The code should start with:
```python
import random
import str... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
from typing import Set
# Global set to store previously generated codes
generated_codes: Set[str] = set()
def generate_verification_code(length: int) -> str:
"""
Generates a unique verification code... |
magic_instruct_75k | 26,049 | Write a Python function to process ticket sales data and generate a report for primary and secondary market sales. The function should take in a list of tuples, where each tuple represents a ticket sale and contains three elements: the ticket type ("PRIMARY" or "RESALE"), the ticket number, and the ticket price. The fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def generate_sales_report(data: List[Tuple[str, int, int]]) -> str:
"""
Generates a report of ticket sales data for primary and secondary markets.
Args:
data (List[Tuple[str, int, int... |
magic_instruct_75k | 26,058 | Write a Python function to return a new list containing only the unique elements from the input list, preserving their original order. The function should efficiently handle the uniqueness check using a set to avoid the inefficiency of checking for the presence of an element in a list.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def unique_elements(input_list: List[int]) -> List[int]:
"""
Returns a new list containing only the unique elements from the input list, preserving their original order.
Args:
input_list (Li... |
magic_instruct_75k | 26,065 | Write a Python function to add a blank choice to the list of choices in a form field dictionary. The form field is represented as a dictionary, and the choices are represented as a list of tuples. Each tuple in the list represents a choice, where the first element is the choice value and the second element is the choic... | Here is the Python code to solve the given problem in the markdown block:
```python
def add_blank_choice(form_field: dict) -> list:
"""
Adds a blank choice to the list of choices in the form field dictionary.
Args:
form_field (dict): A dictionary representing the form field. It contains a key "choi... |
magic_instruct_75k | 26,067 | Write a Python function to calculate the frequency of each unique integer in a given list of integers. The function should handle the scenario where the input list is empty by returning an empty dictionary. The frequency of each integer should be calculated using the `Counter` class from the `collections` module.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
from collections import Counter
def calculate_frequency(input_list: List[int]) -> Dict[int, int]:
"""
Calculate the frequency of each unique integer in the given list.
Args:
input_list... |
magic_instruct_75k | 26,131 | Write a Python script to automate the build and signing process for a software project. The script should perform the following steps:
1. Copy the file "p-load.exe" to a directory specified by the variable `staging_dir`.
2. Sign the "p-load.exe" file using the `sign_tool` with the specified signing flags and the name "... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import shutil
import subprocess
import logging
def automate_build_and_signing(staging_dir: str, sign_tool: str, ms_build: str, sign_flags: str):
"""
Automates the build and signing process for a software project.
... |
magic_instruct_75k | 26,136 | Create a Python class that manages a collection of unique IDs. The class should provide methods to add a new ID to the collection and to retrieve the newest ID that was added. The IDs are generated using a `nextFreeId_` and a `nextStep_` variable. The `nextFreeId_` is the next available ID, and `nextStep_` is the step ... | Here is the Python code to solve the given problem in the markdown block:
```python
class UniqueIdManager:
def __init__(self, initial_id: int, step_size: int):
"""
Initialize the UniqueIdManager with the given initial ID and step size.
Args:
initial_id (int): The starting ID for... |
magic_instruct_75k | 26,148 | Implement a method `addLayer` for a `Layers` object that manages a collection of layers in a 2D game. Each layer is represented by a `LayerInfo` object containing a `layerName` and a `depth`. The `addLayer` method should add a new layer to the `Layers` object with the given `layerName` and `depth`, ensuring that the la... | Here is the Python code to solve the given problem in the markdown block:
```python
class LayerInfo:
def __init__(self, layerName: str, depth: int):
self.layerName = layerName
self.depth = depth
def __repr__(self):
return f"LayerInfo(layerName={self.layerName}, depth={self.depth})"
cla... |
magic_instruct_75k | 26,152 | Write a Python function to process parameter values for a lead-acid battery model. The function should take a dictionary of parameter values and a key to remove from the dictionary. It should then print the remaining parameter values and return a modified dictionary containing specific key-value pairs from the original... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def process_lead_acid_parameters(parameter_values: Dict[str, float], key_to_remove: str) -> Dict[str, float]:
"""
Processes parameter values for a lead-acid battery model by removing a specified key,
... |
magic_instruct_75k | 26,160 | Write a Python function to convert a given integer value into its equivalent representation in a specified base. The function `convert_to_base` takes two parameters: `value` (an integer) and `base` (an integer representing the base to which the value should be converted). The function should return a string representin... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_base(value: int, base: int) -> str:
"""
Convert a given integer value into its equivalent representation in a specified base.
Args:
value (int): The integer value to be converted.
base (int): ... |
magic_instruct_75k | 26,162 | Write a Python function to generate a URL mapping dictionary based on a given set of route configurations. The route configurations are provided as a list of tuples, where each tuple contains the route name and its corresponding URL pattern. The function should return a dictionary where the route names are the keys and... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def generate_url_mapping(route_configurations: List[Tuple[str, str]]) -> Dict[str, str]:
"""
Generates a URL mapping dictionary from a list of route configurations.
Args:
route_... |
magic_instruct_75k | 26,175 | Write a Python function to monitor the response status of an application and take appropriate action based on the status code. The function should handle the following scenarios:
1. If the status code is 200, the function should return "PASS: App is responding with 200".
2. If the status code is not 200, the function s... | Here is the Python code to solve the given problem in the markdown block:
```python
def monitor_app_status(status_code: int) -> str:
"""
Monitors the response status of an application and returns an appropriate message based on the status code.
Args:
status_code (int): The HTTP status code to be mo... |
magic_instruct_75k | 26,195 | Write a Python function to count the occurrences of each unique migration dependency in a given list of migration dependencies. Each migration dependency is represented as a string. The function should return a dictionary where the keys are the unique migration dependencies and the values are the counts of their occurr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_migration_dependencies(migration_list: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique migration dependency in the given list.
Args:
migration_list (L... |
magic_instruct_75k | 26,213 | Create a Python class `BankAccount` that represents a bank account with the following functionalities:
1. A method to create a new account with a unique account number and an initial balance.
2. A method to deposit a specified amount into the account.
3. A method to withdraw a specified amount from the account, ensurin... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
def __init__(self):
"""
Initialize the BankAccount class with an empty dictionary to store accounts.
"""
self.accounts = {}
def create_account(self, account_name, account_numbe... |
magic_instruct_75k | 26,223 | Write a Python function to count the number of occurrences of a specific marker in a given list of markers. The function should take in the list of markers and the specific marker to count, and return the number of occurrences of the given marker in the list. The function should be efficient and handle edge cases such ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_marker_occurrences(markers: List[str], specific_marker: str) -> int:
"""
Counts the number of occurrences of a specific marker in a given list of markers.
Args:
markers (List[str])... |
magic_instruct_75k | 26,226 | Write a Python function to calculate the sum of all even Fibonacci numbers up to a given limit. The Fibonacci sequence is defined as follows: F(0) = 0, F(1) = 1, and F(n) = F(n-1) + F(n-2) for n > 1. For example, the first few terms of the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on. Your function... | Here is the Python code to solve the given problem in the markdown block:
```python
def even_fibonacci_sum(limit: int) -> int:
"""
Calculate the sum of all even Fibonacci numbers up to and including the given limit.
Args:
limit (int): The upper limit for the Fibonacci sequence. The function should ... |
magic_instruct_75k | 26,246 | Write a Python program that implements a Caesar cipher encryption and decryption mechanism. The program should include two functions: `caesar_encrypt` and `caesar_decrypt`. The `caesar_encrypt` function should take a plaintext message and a shift value as input and return the encrypted message using the Caesar cipher. ... | Here is the Python code to solve the given problem in the markdown block:
```python
def caesar_encrypt(plaintext: str, shift: int) -> str:
"""
Encrypts the given plaintext using the Caesar cipher with the specified shift.
Args:
plaintext (str): The plaintext message to be encrypted.
shift (... |
magic_instruct_75k | 26,247 | Write a Python function to calculate the average percentage of positive COVID-19 tests, COVID-19 case counts, and COVID-19 deaths across all demographic cases in a given list. Each demographic case is represented as a dictionary with keys 'Race', 'COVID_TEST', 'COVID_COUNT', 'COVID_DEATHS', 'COVID_TEST_PCT', 'COVID_COU... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def calculate_average_percentage(case_demographics: List[Dict[str, float]]) -> Dict[str, float]:
"""
Calculate the average percentage of positive COVID-19 tests, COVID-19 case counts, and COVID-19 ... |
magic_instruct_75k | 26,250 | Write a Python function to process a list of dictionaries representing settings for a software application. Each dictionary contains the setting name and its corresponding value. The function should take this list of dictionaries as input and return a dictionary where the setting names are the keys and the setting valu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_settings(settings_list: List[Dict[str, any]]) -> Dict[str, any]:
"""
Processes a list of dictionaries representing settings for a software application.
Each dictionary contains the ... |
magic_instruct_75k | 26,288 | Write a Python function called `parse_script_variables` that takes a string representing a script as input and returns a dictionary containing the variable assignments. The script contains multiple lines with variable assignments in the format `#variable_name=filepath_or_directory/`. The variable names and file paths/d... | Here is the Python code to solve the given problem in the markdown block:
```python
def parse_script_variables(script: str) -> dict:
"""
Parses a script string to extract variable assignments and returns them in a dictionary.
The script contains multiple lines with variable assignments in the format `#vari... |
magic_instruct_75k | 26,302 | Write a Python function `perform_operation` that modifies a graph represented by an adjacency list based on the given operation identifier and input parameters. The graph is a dictionary where keys are vertex IDs and values are lists of adjacent vertex IDs. The function should perform one of the following operations:
1... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def perform_operation(graph: Dict[int, List[int]], identifier: str, input_vertex_id: int, data: List[str]) -> Dict[int, List[int]]:
"""
Perform an operation on the graph based on the given identifi... |
magic_instruct_75k | 26,316 | Write a Python function to count the frequency of each category in a given dataset. The dataset is a list of items, where each item belongs to a specific category. The function should return a dictionary where the keys are the unique categories present in the dataset, and the values are the frequencies of each category... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def CategoryFreqs(dataset: List[str]) -> Dict[str, int]:
"""
Counts the frequency of each category in the given dataset.
Args:
dataset (List[str]): A list of strings where each string ... |
magic_instruct_75k | 26,318 | Write a Python function to analyze a DNA sequence for the presence of specific resistance genes. The function should take a DNA sequence as input and return a list of resistance genes present in the sequence. The resistance genes to be checked for are CmR, KanR, and AmpR. The function should use helper functions `HasCm... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def HasResistance(seq: str) -> List[str]:
"""
Analyzes a DNA sequence for the presence of specific resistance genes and returns a list of those present.
Args:
seq (str): The DNA sequence to ... |
magic_instruct_75k | 26,343 | Write a Python function to convert a file size given in bytes into a human-readable format. The function should determine the most appropriate unit (bytes, kilobytes, megabytes, gigabytes, etc.) and round the result to two decimal places. The function should handle input as a string representing the size in bytes.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_file_size(size: str) -> str:
"""
Converts a file size given in bytes into a human-readable format.
Args:
size (str): The size of the file in bytes as a string.
Returns:
str: The size in a hu... |
magic_instruct_75k | 26,359 | Write a Python function to validate a non-fungible token (NFT) minting transaction based on the provided transaction information. The function should check if the transaction meets the following conditions:
1. The number of incoming transfers is exactly 1.
2. The number of outgoing transfers is exactly 1.
3. The amount... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def validate_nft_mint_transaction(txinfo: Tuple[List[Tuple[float, str, str, str]], List[Tuple[float, str, str, str]], List[Tuple[float, str, str, str]]]) -> bool:
"""
Validates an NFT minting tran... |
magic_instruct_75k | 26,361 | Write a Python function to process orders for an e-commerce platform based on the given order scene and URL type. The function should return a string indicating the processing details based on the provided parameters. The function should handle three types of order scenes and two types of URL links.
The function signa... | Here is the Python code to solve the given problem in the markdown block:
```python
def processOrder(order_scene: int, signurl: int) -> str:
"""
Processes an order based on the given order scene and URL type.
Args:
order_scene (int): The type of order scene. Possible values:
1 - Regular... |
magic_instruct_75k | 26,363 | Write a Python function to generate a `curl` command that creates a new sub-collection within a specified WebDAV collection. The function should take the server URL, WebDAV cell name, WebDAV box name, existing WebDAV collection name, and the new sub-collection name as parameters. The function should return the `curl` c... | Here is the Python code to solve the given problem in the markdown block:
```python
def generateCurlCommand(_server: str, _cell: str, _box: str, _collection: str, _subCollection: str) -> str:
"""
Generates a `curl` command to create a new sub-collection within a specified WebDAV collection.
Args:
_... |
magic_instruct_75k | 26,371 | Write a Python function to select the most suitable strategy from a list of default strategies based on the available data fields. Each strategy is represented as a list of required data fields. The function should select the strategy that has the most number of required data fields present in the input data fields. If... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
DEFAULT_STRATEGIES = [
['ror_name', 'ror_city', 'ror_country'],
['ror_name', 'ror_city'],
['ror_name', 'ror_country'],
['ror_city', 'ror_country'],
['ror_name'],
['ror_city'],
['ror_c... |
magic_instruct_75k | 26,381 | Write a Python function to format a configuration dictionary into a human-readable string summary. The configuration dictionary contains parameters related to a particle physics experiment, including `DQMStore`, `disableROOToutput`, and `filterTriggerType`. The function should ensure that the output string includes the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def format_configuration(config: Dict[str, any]) -> str:
"""
Formats a configuration dictionary into a human-readable string summary.
The configuration dictionary should contain the following keys:
... |
magic_instruct_75k | 26,418 | Create a Python class `ViewModifierManager` that manages a list of view modifiers. The class should support adding, removing, and retrieving view modifiers, as well as checking for the presence of a specific modifier. The class should include the following methods:
- `add_modifier`: Adds a new view modifier to the list... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Type
class ViewModifierManager:
"""
A class to manage a list of view modifiers.
Methods:
- add_modifier: Adds a new view modifier to the list.
- remove_modifier: Removes a view modifier fro... |
magic_instruct_75k | 26,428 | Write a Python function to generate a version string for a software build. The version string should consist of the latest tag from the version control system followed by a plus sign and the short SHA (Secure Hash Algorithm) of the commit. For example, if the latest tag is "v1.2" and the short SHA is "a1b2c3d", the ver... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_version_string(latest_tag: str, short_sha: str) -> str:
"""
Generates a version string for a software build by combining the latest tag from the version control system
with the short SHA of the commit.
Args... |
magic_instruct_75k | 26,433 | Write a Python function to count the number of packages falling within specific major version ranges from a list of software requirements. Each requirement is given in the format "package_name>=min_version,<max_version". The function should return a dictionary where the keys are the major version ranges (e.g., '1.x', '... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_package_versions(requirements: List[str]) -> Dict[str, int]:
"""
Counts the number of packages falling within specific major version ranges from a list of software requirements.
Args... |
magic_instruct_75k | 26,435 | Write a Python function to find the highest and lowest scores in a list of student scores, along with their respective positions in the list. The function should return a tuple containing the highest score, its position, the lowest score, and its position. The position should be zero-based, meaning the first element in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_highest_lowest_score(student_scores: List[int]) -> Tuple[int, int, int, int]:
"""
Finds the highest and lowest scores in a list of student scores along with their positions.
Args:
... |
magic_instruct_75k | 26,440 | Write a Python function to count the number of unique atoms in a 3D voxel grid representing a protein structure. Each atom is represented by its coordinates within the grid, and the grid is a 3D numpy array where each voxel can contain either a 0 (empty) or a positive integer (representing a unique atom). The function ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def count_unique_atoms(voxel_grid: np.ndarray) -> int:
"""
Count the number of unique atoms in a 3D voxel grid representing a protein structure.
Args:
voxel_grid (np.ndarray): A 3D numpy array re... |
magic_instruct_75k | 26,445 | Write a Python function to calculate the maximum profit that can be achieved by making a single buy and sell transaction from a given list of stock prices over a period of time. The buy must occur before the sell. The function should handle edge cases where no profit can be made or when the input list is empty.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_profit(prices: List[int]) -> int:
"""
Calculate the maximum profit that can be achieved by making a single buy and sell transaction from a list of stock prices.
Args:
prices (List[in... |
magic_instruct_75k | 26,457 | Write a Python function to sort a list of books based on a specified criterion and order. Each book is represented as a dictionary with keys: `title`, `price`, `releaseDate`, `publisher`, and `author`. The function should be able to sort the books by any of these keys in either ascending or descending order. The functi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def sort_books(books: List[Dict[str, Union[str, float, int]]], criterion: str, ascending: bool = True) -> List[Dict[str, Union[str, float, int]]]:
"""
Sorts a list of books based on a specif... |
magic_instruct_75k | 26,483 | Write a Python function to populate a NumPy array `Y_train` based on specific conditions applied to the rows of another NumPy array `X_train`. The conditions are as follows:
- If the sum of the elements in each row of `X_train` is less than 1, assign 0 to the corresponding index in `Y_train`.
- If the sum of the elemen... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def populate_Y_train(X_train: np.ndarray) -> np.ndarray:
"""
Populate the Y_train array based on the sum of elements in each row of X_train.
Args:
X_train (np.ndarray): A 2D NumPy array with floa... |
magic_instruct_75k | 26,485 | Write a Python function to find the index of the first occurrence of a substring `needle` in a string `haystack`. If `needle` is not found, return -1. If `needle` is an empty string, return 0.
The function should start with:
```python
def strStr(haystack: str, needle: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def strStr(haystack: str, needle: str) -> int:
"""
Returns the index of the first occurrence of `needle` in `haystack`.
If `needle` is not found, returns -1. If `needle` is an empty string, returns 0.
Args:
hays... |
magic_instruct_75k | 26,497 | Write a Python function to flatten a nested dictionary into a single-level dictionary using dot notation. The function should handle dictionaries where values are either other dictionaries or non-dictionary values. The keys in the resulting dictionary should be concatenated using dots to represent the nested structure.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def flatten_dict_with_dot_notation(d: Dict[str, Any]) -> Dict[str, Any]:
"""
Flattens a nested dictionary into a single-level dictionary using dot notation.
Args:
d (Dict[str, Any]): Th... |
magic_instruct_75k | 26,517 | Create a Python class `BankAccount` that simulates a simple banking system. The class should handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry. The class should also ensure the security of the banking operations by implementing the following:
1. Each account should have ... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
def __init__(self):
"""
Initializes the BankAccount class with an empty dictionary to store accounts
and a counter for generating unique account numbers.
"""
self.accounts =... |
magic_instruct_75k | 26,522 | Create a Python function to simulate the consumption of messages from a Kafka topic using the `kafka-console-consumer` command. The function should accept the following parameters:
1. `bootstrap_server`: The server and port for the Kafka bootstrap server.
2. `topic_name`: The name of the Kafka topic from which messages... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def consume_kafka_messages(bootstrap_server: str, topic_name: str, timeout_ms: int) -> List[str]:
"""
Simulate the consumption of messages from a Kafka topic using the `kafka-console-consumer` ... |
magic_instruct_75k | 26,532 | Write a Python function to convert a given integer into its English word representation. The function should support integers within the range of 0 to 999,999,999,999 (inclusive). The function should return the English word representation as a string.
The code should start with:
```python
def int_to_english(n: int) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
def int_to_english(n: int) -> str:
"""
Converts a given integer into its English word representation.
Args:
n (int): The integer to convert, within the range of 0 to 999,999,999,999 (inclusive).
Returns:
... |
magic_instruct_75k | 26,536 | Write a Python function to calculate the moving average of a stream of integers over a specified window size. The function should return a list of floating-point numbers representing the moving averages for each window. If the window size is larger than the length of the stream, the function should return an empty list... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_moving_average(stream: List[int], window_size: int) -> List[float]:
"""
Calculate the moving average of a stream of integers over a specified window size.
Args:
stream (List[in... |
magic_instruct_75k | 26,593 | Write a Python function to automate the installation of essential software on a new computer. The function should clone a specific GitHub repository and then execute a series of commands to set up the required software. The function should be named `install_new_computer` and should be written in Python.
The function s... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
def install_new_computer():
"""
Automates the installation of essential software on a new computer by cloning a GitHub repository and executing setup commands.
Steps:
1. Clone the repository... |
magic_instruct_75k | 26,597 | Write a Python function to generate a response based on the number of recipient email addresses provided. The function should take a sender's email address and a list of recipient email addresses as input and return a string response based on the following rules:
- If the list contains only one email address, the respo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_response(sender_email: str, recipient_emails: List[str]) -> str:
"""
Generates a response based on the number of recipient email addresses.
Args:
sender_email (str): The email a... |
magic_instruct_75k | 26,629 | Create a Python decorator named `count_calls` that counts the number of times each decorated function is called. The decorator should print the function name and the number of times it has been called so far each time the function is invoked. The decorator should be able to keep track of the call counts for multiple fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from functools import wraps
def count_calls(f):
"""
A decorator that counts the number of times each decorated function is called.
Args:
f (function): The function to be decorated.
Returns:
function: T... |
magic_instruct_75k | 26,645 | Write a Python function to rearrange a list of column names based on a given order. The function should take two lists as input: one representing the original column names and the other representing the desired order of the columns. The function should return the modified list of column names in the specified order.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rearrange_columns(columns: List[str], order: List[str]) -> List[str]:
"""
Rearranges the given list of column names based on the specified order.
Args:
columns (List[str]): The original ... |
magic_instruct_75k | 26,652 | Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given a list of integers representing the daily stock prices. If it is not possible to make any profit, return 0.
The code should start with:
```python
from typing import List
def max_profit(prices... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_profit(prices: List[int]) -> int:
"""
Calculate the maximum profit that can be obtained by buying and selling a stock at most once.
Args:
prices (List[int]): A list of integers repre... |
magic_instruct_75k | 26,682 | Write a Python function to find the maximum element to the left of each element in a given array. The function should store these maximum values in an array `lmax` such that `lmax[i]` contains the maximum element in the subarray `a[0:i]` (inclusive).
The code should start with:
```python
from typing import List
def f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_left_max(a: List[int]) -> List[int]:
"""
Finds the maximum element to the left of each element in the given array.
Args:
a (List[int]): The input array.
Returns:
List[i... |
magic_instruct_75k | 26,695 | Write a Python function to manage language settings for a mobile application. The function should update the current language setting and print a confirmation message. The function should be part of a `LanguageViewModel` class, and a `LanguageViewController` class should interact with the `LanguageViewModel` to set the... | Here is the Python code to solve the given problem in the markdown block:
```python
class LanguageViewModel:
def __init__(self):
self.current_language = "English"
def set_current_language(self, language: str) -> None:
"""
Update the current language setting and print a confirmation mess... |
magic_instruct_75k | 26,709 | Write a Python function to find the maximum absolute value of the processed elements in a 3D image represented by a NumPy array `im_cube`. The processing involves computing the absolute value of the negative of each element multiplied by 255. The function should be efficient and leverage NumPy's capabilities for array ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def max_abs_processed_value(im_cube: np.ndarray) -> int:
"""
Calculate the maximum absolute value of the processed elements in a 3D image.
The processing involves computing the absolute value of the nega... |
magic_instruct_75k | 26,763 | Write a Python function to simulate a simple network client-server interaction. The server is listening on `localhost` at port `9090`, and upon receiving a specific message, it performs an operation and sends back a response. The client program needs to send the message to the server and display the hexadecimal dump of... | Here is the Python code to solve the given problem in the markdown block:
```python
import socket
import concurrent.futures
def send_message_to_server(message: bytes) -> str:
"""
Sends a message to a server and returns the hexadecimal dump of the response.
Args:
message (bytes): The message to sen... |
magic_instruct_75k | 26,771 | Write a Python function to determine if a player can navigate from the top-left corner to the bottom-right corner of a given maze represented as a 2D grid. Each cell in the grid can be either empty (denoted by '0') or blocked (denoted by '1'). The player can move up, down, left, or right, but cannot move into blocked c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def canReachEnd(maze: List[List[int]]) -> bool:
"""
Determines if a player can navigate from the top-left corner to the bottom-right corner of a given maze.
Args:
maze (List[List[int]]): A 2... |
magic_instruct_75k | 26,788 | Write a Python function to extract the values associated with the variable name "$\omega$" from a list of annotations. Each annotation is a string that contains a variable name and its corresponding value, formatted using the `format` method. The variable name is denoted by a dollar sign followed by the variable name e... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_values(annotations: List[str]) -> List[float]:
"""
Extracts the values associated with the variable name "$\omega$" from a list of annotations.
Each annotation is a string that contains ... |
magic_instruct_75k | 26,826 | Write a Python function to count the number of even numbers in a given list of integers. The function should handle lists of varying lengths, including empty lists, and should correctly identify and count even numbers within the specified range.
The code should start with:
```python
from typing import List
def count_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_even_numbers(input_list: List[int]) -> int:
"""
Counts the number of even numbers in a given list of integers.
Args:
input_list (List[int]): A list of integers where each integer c... |
magic_instruct_75k | 26,849 | Write a Python function to parse a given code snippet and extract specific information from the comments. The function should return the license under which the code is distributed, the name of the person who submitted the test case, and the method by which the test case was found. The input code snippet will always co... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def extract_code_info(code_snippet: str) -> str:
"""
Extracts and returns the license, submitter, and method of finding the test case from the given code snippet.
Args:
code_snippet (str): The code snippe... |
magic_instruct_75k | 26,889 | Write a Python function to implement a generic stack data structure. The stack should support the standard operations such as push, pop, and top. Additionally, the stack should include methods to check if the stack is empty and to retrieve the current size of the stack. The function should be able to handle elements of... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import TypeVar, Generic, List
T = TypeVar('T')
class Stack(Generic[T]):
def __init__(self):
"""
Initialize an empty stack.
"""
self.elements: List[T] = []
def push(self, element: T)... |
magic_instruct_75k | 26,890 | Write a Python function to extract specific information from a given text block containing copyright and contact information for a software plugin. The function should parse the text and return a dictionary containing the copyright year, the name of the individual or organization, and the email address.
The input `tex... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import re
def extract_plugin_info(text: str) -> Dict[str, str]:
"""
Extracts the copyright year, name, and email from a given text block containing copyright and contact information.
Args:
t... |
magic_instruct_75k | 26,903 | Write a Python function to split a given dataset into two separate lists based on a specified threshold value. The dataset is a list of integers. The function should return a tuple containing two lists: one with all elements less than or equal to the threshold and the other with all elements greater than the threshold.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def split_dataset(dataset: List[int], threshold: int) -> Tuple[List[int], List[int]]:
"""
Splits the given dataset into two lists based on the specified threshold value.
Args:
dataset... |
magic_instruct_75k | 26,915 | Write a Python function to calculate and return a specific array based on the given integer `k` using the NumPy library. The function should take an integer `k` as input and return an array `coeff_denom` where the first element is `1` and the second element is `k - 1`.
The code should start with:
```python
import nump... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def calculate_coeff_denom(k: int) -> np.ndarray:
"""
Calculate and return an array based on the given integer `k`.
Args:
k (int): The integer used to calculate the second element of the array.
... |
magic_instruct_75k | 26,919 | Create a Python class `CSSManager` that simulates a CSS class management system for a web development project. The class should allow for the addition, removal, and retrieval of CSS classes associated with HTML elements. Additionally, the class should support the ability to set and retrieve specific style properties fo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
class CSSManager:
def __init__(self):
"""
Initialize the CSSManager with an empty dictionary to store classes and their styles.
"""
self.classes: Dict[str, Dict[str, st... |
magic_instruct_75k | 26,936 | Write a Python function to determine the final values of two variables `i` and `j` after performing a given number of specific operations. Each operation consists of subtracting 1 from `i` and adding 8 to `j`. The function should take two arguments:
- `operations`: an integer representing the number of operations to be... | Here is the Python code to solve the given problem in the markdown block:
```python
def finalValues(operations: int, initialValues: tuple) -> tuple:
"""
Calculate the final values of `i` and `j` after performing a given number of operations.
Each operation consists of subtracting 1 from `i` and adding 8 to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.