source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 11,452 | Implement a `Stack` class using a linked list to support the following operations: `push`, `pop`, and `peek`. Additionally, implement a static method `is_balanced_parentheses` that checks if the parentheses in a given string are balanced using the stack data structure.
The `Stack` class should have the following metho... | Here is the Python code to solve the given problem in the markdown block:
```python
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Stack:
def __init__(self):
self.top = None
def push(self, value):
"""
Adds a new element to the top o... |
magic_instruct_75k | 11,456 | Write a Python function to simulate a thread-safe lock management system. The function should return a thread-local `ThreadLockState` object that manages the lock state for different lock flags (Read and Write). The `ThreadLockState` object should be thread-local, ensuring that each thread has its own separate instance... | Here is the Python code to solve the given problem in the markdown block:
```python
from threading import local
from enum import Enum
class LockFlags(Enum):
READ = 1
WRITE = 2
class ThreadLockState:
def __init__(self):
"""
Initialize the lock state for the current thread.
"""
... |
magic_instruct_75k | 11,457 | Create a Python function to simulate the management of NFC (Near Field Communication) devices. The function should be able to perform the following operations:
1. **Read NFC Tag**: A function that takes a tag ID as input and simulates reading data from an NFC tag with the given ID. It should return the data read from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def read_nfc_tag(tag_id: str, nfc_tags: Dict[str, str]) -> Union[str, None]:
"""
Simulate reading data from an NFC tag with the given ID.
Args:
tag_id (str): The ID of the NFC t... |
magic_instruct_75k | 11,478 | Write a Python function to parse a given long description of a software package and extract specific information from it. The long description is provided as a string in Markdown format and contains metadata about the software package. Your function should extract and return the programming language and the topic of th... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def parse_long_description(long_description: str) -> dict:
"""
Parses a long description of a software package in Markdown format and extracts the programming language and topic.
Args:
long_description (s... |
magic_instruct_75k | 11,484 | Write a Python function to extract specific information from a given dictionary containing project details. The dictionary contains the project's homepage URL and author details. Your function should extract the homepage URL and the author's name and return them as a tuple.
The function should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_project_details(project_info: dict) -> tuple:
"""
Extracts the homepage URL and the author's name from a given dictionary containing project details.
Args:
project_info (dict): A dictionary containing pr... |
magic_instruct_75k | 11,487 | Write a Python function to find all keys in a JSON object that have a boolean value of `True`. The JSON object may contain nested objects and arrays, and the function should consider all levels of nesting. The function should return a list of these keys.
The code should start with:
```python
from typing import Dict, L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def find_true_keys(json_obj: Dict) -> List[str]:
"""
Find all keys in a JSON object that have a boolean value of `True`.
Args:
json_obj (dict): The JSON object to process.
Returns... |
magic_instruct_75k | 11,491 | Write a Python function to parse and extract specific information from a cursor object represented as a JSON-like structure. The cursor object contains the following fields:
- `NAME_SPACE_FIELD`: A string representing the database name and collection name in the format `<database_name>.$lt;collection_name>`
- `CURSOR_I... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def parseCursor(cursorObject: Dict) -> Dict:
"""
Parses a cursor object and extracts specific information into a dictionary.
Args:
cursorObject (Dict): A dictionary representing the cursor o... |
magic_instruct_75k | 11,525 | Write a Python function to check if any URL in a list of URL records matches a given regular expression pattern. Each URL record is represented as a dictionary with keys "url" and "description". The function should return `True` if at least one URL matches the pattern, and `False` otherwise. If the input list is empty,... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import re
def check_url_match(records: List[Dict[str, str]], pattern: str) -> bool:
"""
Check if any URL in a list of URL records matches a given regular expression pattern.
Args:
reco... |
magic_instruct_75k | 11,532 | Write a Python function to calculate the sum of each row in a given 2D array and return the results as a 1D array. The function should handle any rectangular 2D array, including those with different row lengths.
The code should start with:
```python
from typing import List
def row_sums(x: List[List[int]]) -> List[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def row_sums(x: List[List[int]]) -> List[int]:
"""
Calculate the sum of each row in a given 2D array and return the results as a 1D array.
Args:
x (List[List[int]]): A 2D array (list of list... |
magic_instruct_75k | 11,534 | Write a Python function to modify a given list of integers such that it returns a new list containing the squares of all the even numbers from the input list, in the same order as they appear. If the input list is empty or does not contain any even numbers, the function should return an empty list.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def modify_list(arr: List[int]) -> List[int]:
"""
Returns a list containing the squares of all the even numbers in the input list.
Args:
arr (List[int]): The input list of integers.
Ret... |
magic_instruct_75k | 11,562 | Write a Python function to determine whether a given set of points forms a "squarish" shape. A shape is considered "squarish" if the following conditions are met:
1. All side lengths are approximately the same, with a given threshold for acceptable deviation.
2. All angles are approximately the same.
The function shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
def distances(points: List[Tuple[int, int]]) -> List[float]:
"""
Calculate the lengths of the sides of the polygon formed by the given points.
Args:
points: A list of tupl... |
magic_instruct_75k | 11,569 | Write a Python function to perform parallel evaluation of a given task on a CPU device using multi-threading. The function should support both standard and optimized evaluation algorithms based on a boolean parameter `useOptimized`. Ensure proper synchronization and thread management for parallel execution.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import threading
# Shared lock for thread synchronization
lock = threading.Lock()
# Shared variable to track completion of all threads
completed_threads = 0
def standard_evaluation(thread_id: int) -> None:
... |
magic_instruct_75k | 11,573 | Write a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) between two strings.
Args:
str1 (str): The first string.
str2 (str): The second s... |
magic_instruct_75k | 11,599 | Write a Python function to implement a custom logging system that logs messages to different output streams, including the file name from which the log message originates. The function should construct a log message prefix based on the file name and message type. The function should also allow logging various types of ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import TextIO, Any
import os
def custom_log(output_stream: TextIO, file_path: str, message_type: str, *args: Any) -> None:
"""
Logs messages to a specified output stream with a custom prefix including the file name ... |
magic_instruct_75k | 11,602 | Write a Python function to find the indices of non-zero elements in a given list of integers. The function should return a list of indices where the corresponding elements in the input list are non-zero.
The code should start with:
```python
from typing import List
def non_zero_indices(vector: List[int]) -> List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def non_zero_indices(vector: List[int]) -> List[int]:
"""
Returns the indices of non-zero elements in the given vector.
Args:
vector (List[int]): A list of integers representing the vector.
... |
magic_instruct_75k | 11,630 | Write a Python function to convert a list of three integers representing the red, green, and blue values of a color into a hexadecimal color code. The function should return a string in the format "#rrggbb", where `rr`, `gg`, and `bb` are two-digit hexadecimal representations of the red, green, and blue values respecti... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def toHex(rgb: List[int]) -> str:
"""
Converts a list of three integers representing RGB values into a hexadecimal color code.
Args:
rgb (List[int]): A list of three integers (0 <= value <= ... |
magic_instruct_75k | 11,658 | Write a Python function to simulate a simplified version of the `rsync` command-line utility. The function should take two lists of file snapshots, representing the source and destination systems, and return a list of commands that synchronize the files from the source to the destination. The commands should include fi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_rsync_commands(old_snapshots: List[str], new_snapshots: List[str]) -> List[str]:
"""
Generates a list of commands to synchronize files from the source to the destination.
Args:
... |
magic_instruct_75k | 11,667 | Write a Python function to implement a custom filter function that takes a function and a list as input and returns a new list containing only the elements for which the function returns True. The function should be named `my_filter` and should be able to handle various types of input functions and lists.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Callable, List
def my_filter(func: Callable, lst: List) -> List:
"""
Custom filter function to filter elements from a list based on the given function.
Args:
func (Callable): A function that take... |
magic_instruct_75k | 11,684 | Write a Python function to simulate the transition of a smart bulb's HSV (Hue, Saturation, Value) settings from a current state to a target state. The function should return a list of steps needed to achieve the transition, ensuring the transition is smooth and gradual. Each step should be represented as a string descr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def transition_hsv(current_hue: int, current_saturation: int, current_brightness: int, target_hue: int, target_saturation: int, target_brightness: int) -> List[str]:
"""
Simulates the transition of a sma... |
magic_instruct_75k | 11,711 | Write a Python function to validate if a given date string in the format "YYYY-MM-DD" is a valid date. The function should return "Yes" if the date is valid and "No" otherwise. The date must satisfy the following conditions:
1. The year (YYYY) should be a 4-digit number.
2. The month (MM) should be a number between 01 ... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_date(date: str) -> str:
"""
Validate if a given date string in the format "YYYY-MM-DD" is a valid date.
Args:
date (str): The date string to validate.
Returns:
str: "Yes" if the date is val... |
magic_instruct_75k | 11,714 | Write a Python function to calculate the length of the longest consecutive substring of the same character in a given string `s`. The function should be efficient and handle edge cases such as an empty string.
The code should start with:
```python
def max_consecutive_length(s: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def max_consecutive_length(s: str) -> int:
"""
Calculate the length of the longest consecutive substring of the same character in the given string `s`.
Args:
s (str): The input string consisting of lowercase English... |
magic_instruct_75k | 11,716 | Write a Python function to count the occurrences of unique module names in a list, ignoring leading and trailing whitespaces and treating module names as case-insensitive. The function should return a dictionary where the keys are the unique module names (in lowercase and stripped of whitespaces) and the values are the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_unique_modules(module_names: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of unique module names in a list, ignoring case and leading/trailing whitespaces.
Args:
... |
magic_instruct_75k | 11,741 | Write a Python function called `find_first_zero_index` that takes a list of integer arrays as input and returns a list of integers representing the indices of the first occurrence of 0 in each array. If an array does not contain 0, the corresponding index in the returned list should be -1.
The function signature is:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_first_zero_index(arrays: List[List[int]]) -> List[int]:
"""
Finds the index of the first occurrence of 0 in each array within the input list.
If an array does not contain 0, the correspondin... |
magic_instruct_75k | 11,743 | Write a Python function to validate a list of elements based on the following conditions:
1. The list must contain at least 5 elements.
2. All elements in the list must be integers.
The function should return `True` if both conditions are met, otherwise it should return `False`.
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
def validate_list(x: List[int]) -> bool:
"""
Validates a list of elements based on the following conditions:
1. The list must contain at least 5 elements.
2. All elements in the list must be inte... |
magic_instruct_75k | 11,769 | Write a Python function to check if a given value exists in a list of integers. The function should return `True` if the value is found in the list, and `False` otherwise. The function should be efficient and correctly handle all edge cases.
The code should start with:
```python
from typing import List
def check_valu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_values(arr: List[int], value: int) -> bool:
"""
Check if a given value exists in a list of integers.
Args:
arr (List[int]): The list of integers to search.
value (int): The... |
magic_instruct_75k | 11,812 | Write a Python function `cast_row` that takes two parameters: a list of data types (`data_types`) and a list of data elements (`data`). The function should cast each element in the `data` list to the corresponding data type specified in the `data_types` list. The function should handle the following data types: 'int', ... | Here is the Python code to solve the given problem in the markdown block:
```python
def cast_row(data_types: list, data: list) -> list:
"""
Casts each element in the `data` list to the corresponding data type specified in the `data_types` list.
Args:
data_types (list of str): A list of data types i... |
magic_instruct_75k | 11,831 | Write a Python function `count_files_by_extension` that takes in a list of absolute file paths and an extension (e.g., "txt", "pdf", "jpg") and returns the count of files with the given extension in the entire directory structure. The function should be case-insensitive with respect to the file extension.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_files_by_extension(file_paths: List[str], extension: str) -> int:
"""
Counts the number of files with the given extension in a list of absolute file paths.
Args:
file_paths (List[s... |
magic_instruct_75k | 11,840 | Write a Python function to calculate the average score of a game, excluding the highest and lowest scores from a given list of integers. The function should return the average score rounded to the nearest whole number. If the list contains fewer than three scores, the function should return 0.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_average_excluding_extremes(scores: List[int]) -> int:
"""
Calculate the average score of a game, excluding the highest and lowest scores.
Args:
scores (List[int]): A list of in... |
magic_instruct_75k | 11,861 | Write a Python function to update the position of a dollars sprite in a game inventory system. The function should take the current x-coordinate of the dollars sprite and the new center x-coordinate as input parameters. The function should calculate the offset needed to adjust the position of the dollars sprite based o... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_dollars_position(current_x: float, new_center_x: float) -> float:
"""
Updates the position of the dollars sprite based on the new center x-coordinate.
Args:
current_x (float): The current x-coordinate of ... |
magic_instruct_75k | 11,868 | Write a Python function to retrieve property information based on the provided address parameters. The function should take in the name of a street, a postal zip code, and a street number, and return the details of the property associated with that address. If the address is not found, the function should return `None`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def get_property_info(street_name: str, zip_code: int, street_number: str) -> Optional[Dict]:
"""
Retrieves property information based on the provided address parameters.
Args:
str... |
magic_instruct_75k | 11,874 | Write a Python function to simulate a basic calculator that takes two numbers and an operator as input and performs the corresponding arithmetic operation. The function should handle both integer and floating-point numbers and support the following operators: addition (`+`), subtraction (`-`), multiplication (`*`), and... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculator(num1: float, num2: float, operator: str) -> float:
"""
Simulates a basic calculator that performs arithmetic operations on two numbers.
Args:
num1 (float): The first number.
num2 (float): The ... |
magic_instruct_75k | 11,887 | Write a Python function `process_input_data(input_path)` that processes input data for prediction using Google Cloud AutoML. The function should handle both BigQuery and local file input sources. If the input path starts with 'bq', it should return a dictionary with the BigQuery input configuration. If the input path d... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_input_data(input_path: str) -> dict:
"""
Processes input data for prediction using Google Cloud AutoML.
Args:
input_path (str): The path to the input data. It can be a BigQuery URI starting with 'bq' or ... |
magic_instruct_75k | 11,898 | Write a Python function to calculate the highest frequency value (`xhigh`) and the half resolution (`halfres`) based on the given parameters `resolution` and `freqStep`. The function should return these two values as a tuple.
The `resolution` represents the resolution of a Fourier transform, and `freqStep` represents ... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_values(resolution: float, freqStep: float) -> tuple:
"""
Calculate the highest frequency value (xhigh) and the half resolution (halfres) based on the given parameters.
Args:
resolution (float): The res... |
magic_instruct_75k | 11,901 | Write a Python function to traverse a tree structure from a given node to the root node and return a list of support values encountered along the path. Each node in the tree has a `support` attribute representing its support value and a `parent` attribute pointing to its parent node. The `parent` attribute is `None` fo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
class TreeNode:
def __init__(self, support: int, parent=None):
self.support = support
self.parent = parent
def get_support_path(current_node: TreeNode) -> List[int]:
"""
Traverse the... |
magic_instruct_75k | 11,916 | Write a Python function to count the number of pairs in a given string where the absolute difference between the two numbers in each pair is exactly 1. The input string consists of space-separated pairs in the format "x:y", where x and y are integers. The function should handle both positive and negative integers.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def countPairsWithDifferenceOne(pairsString: str) -> int:
"""
Counts the number of pairs in a given string where the absolute difference between the two numbers in each pair is exactly 1.
Args:
pairsString (str): A ... |
magic_instruct_75k | 11,937 | Write a Python function to process a list of file paths and execute each file if it exists. If a file does not exist, the function should move on to the next file in the list. The function should handle both absolute and relative file paths.
The code should start with:
```python
from typing import List
import os
impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import os
import subprocess
def execute_existing_files(file_paths: List[str]) -> None:
"""
Executes each file in the given list of file paths if it exists.
Args:
file_paths (List[str]): A li... |
magic_instruct_75k | 11,960 | Write a Python function to construct a URL for accessing metadata of files in an Azure Blob Storage. The function should take in the account name, container name, file name, SAS token, and a dictionary representing the file's metadata. The URL should be constructed based on the given inputs and the provided format.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_metadata_url(account: str, container: str, file: dict, sas_token: str) -> str:
"""
Constructs a URL for accessing metadata of files in an Azure Blob Storage.
Args:
account (str): The name of the Azure ... |
magic_instruct_75k | 11,988 | Write a Python function to parse and extract specific information from a JSON object. The JSON object represents metadata for an API and contains various fields such as "code", "type", and "description". Your task is to write a function that takes this JSON object as input and extracts the "code" and "type" fields from... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_api_metadata(json_data: dict) -> tuple:
"""
Extracts the 'code' and 'type' fields from the 'apiMetaData' section of a JSON object.
Args:
json_data (dict): A dictionary representing the JSON object contai... |
magic_instruct_75k | 12,000 | Write a Bash script that defines the `green` and `reset` variables to store the ANSI escape codes for green color and color reset, respectively. Complete the `printMessage` function to print the message "Ok!" in green color and return 0. The script should be executable and should print "Ok!" in green color when run.
T... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
# Define the ANSI escape code for green color
green='\033[32m'
# Define the ANSI escape code to reset the color
reset='\033[0m'
# Function to print "Ok!" in green color and return 0
printMessage() {
echo -e "${green}Ok!... |
magic_instruct_75k | 12,031 | Create a Python function `simulate_setup` that simulates a simplified version of the `setuptools.setup` function. The function should take in the following parameters:
- `name` (string): The name of the package.
- `version` (string): The version of the package.
- `description` (string): A short description of the packa... | Here is the Python code to solve the given problem in the markdown block:
```python
def simulate_setup(name: str, version: str, description: str, author: str, author_email: str, packages: list, install_requires: list) -> dict:
"""
Simulates a simplified version of the `setuptools.setup` function.
Args:
... |
magic_instruct_75k | 12,043 | Write a Python function to process a list of sales data and calculate the total sales for each month. The sales data is provided as a list of tuples, where each tuple contains the date of the sale (in the format 'YYYY-MM-DD') and the corresponding sale amount. The function should aggregate the sales by month and return... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
from collections import OrderedDict
def calculate_monthly_sales(sales_data: List[Union[str, float]]) -> OrderedDict:
"""
Calculate the total sales for each month from a list of sales data.
Ar... |
magic_instruct_75k | 12,044 | Write a Python function `sumEvenNumbers` that takes a list of integers as input and returns the sum of all the even numbers in the list. You must adhere to the character restrictions mentioned above while implementing the function. The characters you can use are: `(`, `)`, `{`, `}`, `[`, `]`, `<`, `>`, `+`, `-`, `*`, `... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sumEvenNumbers(arr: List[int]) -> int:
"""
Calculate the sum of all even numbers in the given list.
Args:
arr (List[int]): A list of integers.
Returns:
int: The sum of all e... |
magic_instruct_75k | 12,045 | Write a Python function to identify the top k most active contributors to a given repository based on the commit history. The commit history is represented as a list of strings, where each string is the name of the contributor who made a commit. The function should return a list of the names of the top k most active co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def top_contributors(commit_history: List[str], k: int) -> List[str]:
"""
Identify the top k most active contributors to a repository based on the commit history.
Args:
commit_history (List[... |
magic_instruct_75k | 12,061 | Write a Python function to optimize the configuration of a Dask client for reading and processing large CSV files. The function should determine the optimal number of workers, threads per worker, and memory limit based on the system's memory capacity and the size of the input CSV file. The function should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def optimize_dask_client(system_memory_gb: int, csv_file_size_gb: int) -> tuple:
"""
Optimize the Dask client configuration for reading and processing large CSV files.
Args:
system_memory_gb (int): The ... |
magic_instruct_75k | 12,073 | Write a Python function `generate_content_summary(content_item)` that takes a content item as input and returns a formatted summary of the item's details. The summary should include the following information:
- ID of the content item
- Routine associated with the content
- Active status of the content
- Type of content... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_content_summary(content_item: dict) -> str:
"""
Generate a formatted summary of a content item based on the provided dictionary.
Args:
content_item (dict): A dictionary containing the details of the con... |
magic_instruct_75k | 12,113 | Write a Python function to process a given file path and verify the number of arguments passed. The function should store the provided path in a read-only variable for further processing. The function should raise an error if the number of arguments is not exactly one.
The code should start with:
```python
from typing... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_file_path(args: List[str]) -> str:
"""
Processes a given file path and verifies the number of arguments passed.
Args:
args (List[str]): A list of arguments passed to the function... |
magic_instruct_75k | 12,116 | Write a Python function to count the occurrences of each type of migration operation in a list of operations. Each operation is represented as a tuple where the first element is the operation type and the second element is the model name. The operation types can be one of the following: "AddField", "RemoveField", "Rena... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def count_migration_operations(operations: List[Tuple[str, str]]) -> Dict[str, int]:
"""
Counts the occurrences of each type of migration operation in a list of operations.
Args:
... |
magic_instruct_75k | 12,131 | Write a Python function to generate an HTML notification message for users when an administrator makes a modification. The notification should include the administrator's name and a prompt for the user to review the modification. The function should return the HTML code as a string.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_notification(admin_name: str) -> str:
"""
Generates an HTML notification message for users when an administrator makes a modification.
Args:
admin_name (str): The name of the administrator who made the ... |
magic_instruct_75k | 12,133 | Write a Python function to process a list of record IDs according to the following criteria:
1. Remove any duplicate record IDs from the input list.
2. Sort the record IDs in ascending order.
3. Append the string "_mod" to each record ID in the modified list.
The function should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_record_ids(record_id_list: List[str]) -> List[str]:
"""
Processes a list of record IDs by removing duplicates, sorting them in ascending order,
and appending the string "_mod" to each rec... |
magic_instruct_75k | 12,151 | Write a Python function to process a list of directives and execute the corresponding actions based on the directive content. Each directive is a string in the format "action:target", where "action" represents the action to be performed and "target" represents the component or entity on which the action should be appli... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def DirectivesUpdated(directives: List[str]) -> List[str]:
"""
Processes a list of directives and executes the corresponding actions.
Args:
directives (List[str]): A list of directives in th... |
magic_instruct_75k | 12,158 | Write a Python function to convert date and time strings into their respective datetime and date objects. The function should handle two input strings: one representing a date and time in the format `'%m/%d/%y %H:%M:%S'`, and the other representing a date in the format `'%m-%d-%Y'`. The function should return a tuple c... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def convert_date_time(datetime_str: str, date_str: str) -> tuple:
"""
Converts date and time strings into their respective datetime and date objects.
Args:
datetime_str (str): A string... |
magic_instruct_75k | 12,186 | Write a Python function to shuffle a list of image data and their corresponding labels in the same order. The function should take the image data and labels as input and return the shuffled image data and labels. The shuffling process must maintain the correspondence between the data and their labels.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def shuffle_data_labels(image_data: List[List[int]], labels: List[int]) -> Tuple[List[List[int]], List[int]]:
"""
Shuffles the image data and their corresponding labels in the same o... |
magic_instruct_75k | 12,194 | Write a Python function to validate the format of an email address according to the specified rules. The function should take a string as input and return a boolean value indicating whether the input string is a valid email address or not. The rules for a valid email address are:
- It should contain exactly one "@" sym... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_email(email: str) -> bool:
"""
Validates the format of an email address according to the specified rules.
Args:
email (str): The email address to validate.
Returns:
bool: True if... |
magic_instruct_75k | 12,197 | Write a Python function to extract function names from a list of regular expressions and corresponding function names. The function should take a list of tuples as input, where each tuple contains a regular expression and a function name. The function should return a dictionary where the keys are the regular expression... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def extract_function_names(regex_function_pairs: List[Tuple[str, str]]) -> Dict[str, str]:
"""
Extracts function names from a list of regular expressions and corresponding function names.
... |
magic_instruct_75k | 12,203 | Write a Python function to calculate and return basic statistics for a given 2D array. The function should return a dictionary containing the sum, mean, maximum value, and minimum value of all elements in the array. The code should start with:
```python
from typing import List, Dict
def array_statistics(mu5: List[List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def array_statistics(mu5: List[List[float]]) -> Dict[str, float]:
"""
Calculate and return basic statistics for a given 2D array.
Args:
mu5 (List[List[float]]): A 2D array containing n... |
magic_instruct_75k | 12,207 | Write a Python function to convert a simplified version of Markdown text into HTML. The function should support the following Markdown syntax:
1. **Headers**: Lines starting with one or more `#` characters followed by a space should be converted to HTML headers. For example, `# Hello` should be converted to `<h1>Hello<... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def markdownToHTML(markdown: str) -> str:
"""
Converts a simplified Markdown string into an HTML string.
The function supports the following Markdown syntax:
1. Headers: Lines starting with one or more `#` ch... |
magic_instruct_75k | 12,248 | Write a Python function to generate a command string for the `perf` tool that monitors a list of specified events related to the i915 graphics driver on a Linux system. The function should take a list of event names and return a complete command string that can be executed in the terminal. Each event should be specifie... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_perf_command(events: list) -> str:
"""
Generates a command string for the `perf` tool to monitor specified events related to the i915 graphics driver.
Args:
events (list): A list of event names to be mo... |
magic_instruct_75k | 12,273 | Write a Python function to automate the deployment of a dashboard application using npm. The function should handle the deployment process, including installing dependencies, building the application, and starting the server. The function should determine the type of dashboard application (React, Vue, or Angular) and e... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
def deploy_dashboard(app_type: str) -> None:
"""
Automates the deployment of a dashboard application using npm.
Args:
app_type (str): The type of dashboard application (React, Vue, or Angular).
... |
magic_instruct_75k | 12,282 | Write a Python function to calculate the length of the longest consecutive subsequence in a given list of integers. The function should be efficient and handle edge cases such as empty lists and lists with duplicate elements.
The code should start with:
```python
from typing import List
def length_of_longest_consecut... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def length_of_longest_consecutive_subsequence(t1: List[int]) -> int:
"""
Calculate the length of the longest consecutive subsequence in a given list of integers.
Args:
t1 (List[int]): The li... |
magic_instruct_75k | 12,286 | Write a Python function to calculate the volume of water that can be trapped between a series of vertical pillars. Each pillar has a specific height, and the distance between each pillar is uniform. The pillars are represented by an array of non-negative integers, where each integer represents the height of the pillar ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def trapped_water_volume(pillar_heights: List[int]) -> int:
"""
Calculate the volume of water that can be trapped between a series of vertical pillars.
Args:
pillar_heights (List[int]): An a... |
magic_instruct_75k | 12,300 | Write a Python function to filter a list of tuples based on the integer value in each tuple. The function should return a new list containing only the strings from the tuples where the integer is 10 or greater. The function should start with:
```python
from typing import List, Tuple
def filter_items(items: List[Tuple[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def filter_items(items: List[Tuple[str, int]]) -> List[str]:
"""
Filters a list of tuples and returns a new list containing only the strings from tuples where the integer is 10 or greater.
Ar... |
magic_instruct_75k | 12,308 | Write a Python function to identify the indices of missing latitude values in a given list of latitude values. The latitude values are represented as integers, where a missing value is denoted by the integer `255`. The function should return a list of indices where these missing values occur.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_missing_latitudes(latitudes: List[int]) -> List[int]:
"""
Identify the indices of missing latitude values in a given list of latitude values.
Args:
latitudes (List[int]): A list of ... |
magic_instruct_75k | 12,315 | Write a Python function to calculate the number of combinations possible for a given set of items and optionally print the combinations. The function should take a list `nk` containing three positive integers. The first integer `n` represents the total number of items, the second integer `k` represents the number of it... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from itertools import combinations
def calculate_combinations(nk: List[int], verbose: int = 0) -> int:
"""
Calculate the number of combinations possible for a given set of items and optionally print the ... |
magic_instruct_75k | 12,329 | Write a Python function to generate a command to transfer a file from a local directory to a remote server using the Secure Copy Protocol (SCP). The function should take in the username, port, local file path, remote server address, and remote file path as input parameters and return the SCP command as a string.
The S... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_scp_command(username: str, port: int, local_file_path: str, remote_server: str, remote_file_path: str) -> str:
"""
Generates a command to transfer a file from a local directory to a remote server using the Secure Co... |
magic_instruct_75k | 12,352 | Write a Python function to determine whether a given list of integers represents a valid binary max heap. A binary max heap is a complete binary tree where every parent node is greater than or equal to its child nodes. The function should return `True` if the list forms a valid max heap, and `False` otherwise.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_valid_max_heap(hp: List[int]) -> bool:
"""
Determines whether the given list of integers represents a valid binary max heap.
Args:
hp (List[int]): The list of integers to be checked.
... |
magic_instruct_75k | 12,363 | Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given an array of stock prices where each element represents the stock price on a particular day. If no profit can be made, return 0.
The code should start with:
```python
from typing import List
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_profit(data: List[int]) -> int:
"""
Calculate the maximum profit that can be obtained by buying and selling a stock at most once.
Args:
data (List[int]): A list of integers where eac... |
magic_instruct_75k | 12,368 | Write a Python function to generate unique combinations of network configurations for a system. The function should take in a list of IP addresses, hostnames, and ports, and generate a unique configuration string for each combination of these elements. Each configuration string should follow the format: "passport:IP:ho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_configurations(ips: List[str], hostnames: List[str], ports: List[int]) -> List[str]:
"""
Generate unique combinations of network configurations based on the provided lists of IPs, hostnames,... |
magic_instruct_75k | 12,378 | Write a Python function to extract the author's name and email from a given string in the format `author="<NAME>", author_email="<EMAIL>"`. The function should take a single string as input and return a dictionary containing the extracted name and email.
The code should start with:
```python
def extract_author_info(in... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_author_info(info_str: str) -> dict:
"""
Extracts the author's name and email from a given string in the format `author="<NAME>", author_email="<EMAIL>"`.
Args:
info_str (str): The input string containing... |
magic_instruct_75k | 12,395 | Write a Python function to identify contexts where the release times are the same for all iterations. The function should take a 2D array of unsigned long integers representing the recorded release times and a constant representing the absence of a release time. The function should return a list of contexts where the r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def findSameReleaseTimes(m_ulPunkReleaseSameTime: List[List[int]], NOTAVAIL: int) -> List[int]:
"""
Identify contexts where the release times are the same for all iterations.
Args:
m_ulPunkR... |
magic_instruct_75k | 12,418 | Write a Python function to alter the location of a set of points in a 2D plane by applying specified horizontal and vertical offsets. The function should take a list of tuples representing the coordinates of the points, an integer representing the horizontal offset, and an integer representing the vertical offset. The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def alter_location(points: List[Tuple[int, int]], x_offset: int, y_offset: int) -> List[Tuple[int, int]]:
"""
Alters the location of a set of points in a 2D plane by applying specified horizontal ... |
magic_instruct_75k | 12,424 | Write a Python function to detect the operating system and install a specific tool using a shell command. The function should:
1. Detect the operating system using the `platform` module.
2. If the operating system is macOS ("Darwin"), install the tool "clever-tools" using Homebrew.
3. Return a message indicating whethe... | Here is the Python code to solve the given problem in the markdown block:
```python
import platform
import subprocess
def install_tool_on_macos() -> str:
"""
Detects the operating system and installs the "clever-tools" package on macOS using Homebrew.
Returns:
str: A message indicating whether the... |
magic_instruct_75k | 12,428 | Write a Python function to count the occurrences of each unique 3D geometric shape in a given list of shape names. The function should return a dictionary where the keys are the unique shape names and the values are the counts of each shape in the input list.
The code should start with:
```python
from typing import Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def countShapes(shapes: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique 3D geometric shape in the given list.
Args:
shapes (List[str]): A list of strings repres... |
magic_instruct_75k | 12,429 | Write a Python function to generate a dictionary that maps level numbers to their corresponding tips from a given list of tips. Each tip is a string and is associated with a specific level number. The function should take the list of tips as input and return the dictionary mapping the level number to the tip. The level... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_tip_dictionary(tips: List[str]) -> Dict[int, str]:
"""
Generates a dictionary that maps level numbers to their corresponding tips from a given list of tips.
Args:
tips (Li... |
magic_instruct_75k | 12,444 | Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down.
The code should start with:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
"""
Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid.
Args:
m (int): The number of row... |
magic_instruct_75k | 12,453 | Write a bash script to automate the installation and uninstallation of mobile applications on iOS simulators. The script should handle the installation and uninstallation of applications based on certain conditions and parameters. The script should perform the following tasks:
1. Print a dot (`.`) to the console.
2. Pr... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
# Define variables
xcrun_instruments_cmd="xcrun instruments -w 'iPhone 12 Pro Max (14.5)'"
APP_BUNDLE_ID="com.example.app"
APP_FILE="path/to/app.app"
# Print a dot to the console
echo "."
# Print the value of the variable x... |
magic_instruct_75k | 12,461 | Write a Python function to extract the last name from a given full name string in the format "first middle last". The function should handle cases where the middle name might be missing. The code should start with:
```python
def extract_last_name(full_name: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def extract_last_name(full_name: str) -> str:
"""
Extracts and returns the last name from a given full name string in the format "first middle last".
Args:
full_name (str): The full name string from which to extra... |
magic_instruct_75k | 12,466 | Write a Python function to calculate the sum of all even numbers in a given list of integers. If the input list is empty or does not contain any even numbers, the function should return 0. The function should be efficient and handle various edge cases.
The code should start with:
```python
from typing import List
def... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_even_numbers(nums: List[int]) -> int:
"""
Calculate the sum of all even numbers in the given list.
Args:
nums (List[int]): A list of integers.
Returns:
int: The sum o... |
magic_instruct_75k | 12,516 | Implement a Python class `PropertyManager` that manages property names and their corresponding values in a Cascading Style Sheets Object Model (CSSOM) library. The class should support the following functionalities:
1. **Retrieval of Property ID**: A method `get_property_id` that takes a property name as input and retu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
class PropertyManager:
DEFAULT_PROPERTY_ID = -1
def __init__(self):
self.property_name_to_id = {}
def get_property_id(self, name: str) -> int:
"""
Retrieve the proper... |
magic_instruct_75k | 12,526 | Write a Python function to process object URIs and extract DOIs from a given URL and extras. The function should return a list of object URIs, including the URL and DOI if it exists. The function should handle the following cases:
- If the DOI exists in the `extras`, it should be included in the object URI.
- If the DO... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_object_uris(url: str, extras: str) -> list:
"""
Extracts DOI from the extras string and returns a list of object URIs including the URL and DOI if it exists.
Args:
url (str): The base URL.
extras... |
magic_instruct_75k | 12,527 | Write a Python function to calculate the corrected flow rates of enzymes, calcium oxide (CaO) in water, and phosphoric acid (H3PO4) in water based on the given specifications and the last recorded net mass of lipid cane. The function should take four parameters: a list of enzyme masses, a list of CaO in water masses, a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def correct_flows(enzyme_mass: List[float], CaO_Water_mass: List[float], H3PO4_Water_mass: List[float], last_lipidcane_massnet: float) -> Tuple[float, float, float]:
"""
Calculate the corrected fl... |
magic_instruct_75k | 12,530 | Write a Python function to determine whether a given URL is valid for the Live Russia TV streaming service. The function should validate the URL based on a specific pattern:
- The URL must start with "https://live.russia.tv/index/index/channel_id/".
- Following "channel_id/", there must be a positive integer ranging fr... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_live_russia_tv_url(url: str) -> bool:
"""
Determines whether a given URL is valid for the Live Russia TV streaming service.
The URL must start with "https://live.russia.tv/index/index/channel_id/" fo... |
magic_instruct_75k | 12,547 | Write a Python function to generate a README file content in Markdown format for a Python package. The function should take the author's name, email, a list of packages, and a list of required dependencies as inputs and return a string containing the formatted README content.
The function signature should be:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_readme(author: str, author_email: str, packages: list, install_requires: list) -> str:
"""
Generates the content for a README file in Markdown format for a Python package.
Args:
author (str): The name o... |
magic_instruct_75k | 12,589 | Create a Python class `BankAccount` that simulates a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should enforce a minimum balance requirement, and if the balance falls below this threshold, a warning message should... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
def __init__(self, account_number: str, initial_balance: float, min_balance: float):
"""
Initializes a new BankAccount instance.
Args:
account_number (str): The account number.... |
magic_instruct_75k | 12,595 | Write a Python function to generate `tune2fs` commands that update the maximum mount count for a list of filesystem devices. Each command should be formatted correctly and include the `sudo` prefix for administrative privileges. The function should take a list of device names and a new maximum mount count as input, and... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_tune2fs_commands(devices: List[str], new_count: int) -> List[str]:
"""
Generates a list of `tune2fs` commands to update the maximum mount count for a list of filesystem devices.
Args:
... |
magic_instruct_75k | 12,613 | Write a Python function to generate a role configuration JSON object based on the given user's username. The function should take a string representing the user's username and return a JSON string with the following structure:
```json
{
"roleId": "user.<user>",
"description": "Personlig rolle for <user>",
"paths"... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
def generateRoleConfig(user: str) -> str:
"""
Generates a role configuration JSON object based on the given user's username.
Args:
user (str): The username for which the role configuration is to be gene... |
magic_instruct_75k | 12,628 | Write a Python function `translate_account_group_ids(role)` that takes a role object as input and returns a list of translated account group IDs. The role object is a dictionary with the following structure:
```python
role = {
'name': 'Role Name',
'accountGroupIds': [id1, id2, ...]
}
```
Where 'name' is the nam... | Here is the Python code to solve the given problem in the markdown block:
```python
def translate_account_group_ids(role: dict) -> list:
"""
Translates account group IDs based on the given role object.
Args:
role (dict): A dictionary containing the role information, including 'name' and 'accountGro... |
magic_instruct_75k | 12,629 | Write a Python function to generate SQL commands for creating non-unique indexes on database tables. The function should take the table name, column name, and index name as input parameters and return the SQL command as a string. The SQL command should follow the format:
```
CREATE INDEX index_name ON table_name (colum... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_index_sql(table_name: str, column_name: str, index_name: str) -> str:
"""
Generates an SQL command for creating a non-unique index on a specified column of a given table.
Args:
table_name (str): The nam... |
magic_instruct_75k | 12,637 | Write a Python function to find the minimum distance between a point `X` and a set of points `X_0` in a multi-dimensional space, and return the class corresponding to the closest point. The function should correctly handle the assignment of the class based on the minimum distance found.
The code should start with:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def find_closest_point(X: np.ndarray, X_0: np.ndarray) -> int:
"""
Find the minimum distance between a point `X` and a set of points `X_0` in a multi-dimensional space,
and return the index of the closest... |
magic_instruct_75k | 12,641 | Write a Python function to generate an SSH command that sets up port forwarding for a list of ports. The function should take a list of integers representing the ports and return a string representing the SSH command. The SSH command should forward each port to the localhost on the same port. The SSH command should be ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_ssh_command(ports: List[int]) -> str:
"""
Generates an SSH command that sets up port forwarding for a list of ports.
Args:
ports (List[int]): A list of integers representing the... |
magic_instruct_75k | 12,642 | Write a Python function to calculate the average number of launched AWCS (Airborne Warning and Control System) per state from a given data dictionary. The data dictionary contains information about a scheme and its associated data, structured as follows:
```python
{
'scheme_code': 'C002',
'total_launched_awcs'... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import defaultdict
from datetime import date
def calculate_average_awcs_per_state(data: dict) -> dict:
"""
Calculate the average number of launched AWCS per state from the given data dictionary.
Args:
... |
magic_instruct_75k | 12,664 | Write a Python function to find the maximum absolute difference between the sum of elements in two given arrays, `red` and `blue`. The function should be able to handle arrays of different lengths and elements that can be both positive and negative. The function should start with:
```python
from typing import List
def... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def red_and_blue(red: List[int], blue: List[int]) -> int:
"""
Calculate the maximum absolute difference between the sum of elements in two arrays, red and blue.
Args:
red (List[int]): The fi... |
magic_instruct_75k | 12,671 | Write a Python function to convert a given list of menu items into a nested dictionary structure representing the menu hierarchy. The input list contains strings where each string represents a menu item. If a string contains the character ">", it indicates that the item is a sub-item of the preceding item. The function... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def convert_to_menu_hierarchy(menu_items: List[str]) -> Dict:
"""
Converts a list of menu items into a nested dictionary structure representing the menu hierarchy.
Args:
menu_items (Li... |
magic_instruct_75k | 12,674 | Write a Python function to simulate the behavior of the "svn commit" command. The function should take a list of strings representing the stack of directories that have been modified in a version control system. The function should simulate the "svn commit" command by popping the top directory from the stack and return... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def svn_commit(stack: List[str]) -> str:
"""
Simulates the behavior of the "svn commit" command by popping the top directory from the stack.
Args:
stack (List[str]): A list of strings repres... |
magic_instruct_75k | 12,715 | Write a Python function to decode an indirect solution using a given scaling factor. The function should take two arguments: `solution`, which is a list of values representing the solution to be decoded, and `sf`, which is a scaling factor. The function should return the decoded solution.
The decoding logic should inv... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def decode_solution(solution: List[float], sf: float) -> List[float]:
"""
Decodes an indirect solution using a given scaling factor.
Args:
solution (List[float]): A list of values representi... |
magic_instruct_75k | 12,720 | Write a Python function to process a list of test case strings and return a dictionary where the keys are the unique test names and the values are the number of occurrences of each test. Each test case string is in the format "test_<test_name>".
The function should start with:
```python
from typing import List, Dict
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_test_cases(test_cases: List[str]) -> Dict[str, int]:
"""
Processes a list of test case strings and returns a dictionary where the keys are the unique test names
and the values are t... |
magic_instruct_75k | 12,723 | Write a Python function to simulate a simplified GPIO (General Purpose Input/Output) class that supports different types of GPIO operations, including digital input/output, PWM (Pulse Width Modulation), and servo control. The function should implement the `write` method, which sets the value of a GPIO pin based on its ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Callable, Optional
# Define constants for digital states
HIGH = 1
LOW = 0
def write(pins: Dict[int, int], on_write: Optional[Callable[[int, int], None]], pin: int, data: int, gpio_type: str) -> None:
"""
... |
magic_instruct_75k | 12,727 | Write a Python function to calculate the final vertical position after executing a series of movements given in two lists: one for the movements ('up' or 'down') and another for the corresponding distances. The initial vertical position is 0. If the movement is 'up', the vertical position increases by the given distanc... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def final_vertical_position(movements: List[str], distances: List[int]) -> int:
"""
Calculate the final vertical position after executing a series of movements.
Args:
movements (List[str]): ... |
magic_instruct_75k | 12,729 | Write a Python function to convert a given integer into its Roman numeral representation. The function should adhere to the standard rules of Roman numeral representation, where smaller symbols can be placed before larger symbols to denote subtraction. The input integer `num` will be between 1 and 3999 inclusive.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
def int_to_roman(num: int) -> str:
"""
Converts a given integer into its Roman numeral representation.
Args:
num (int): The integer to be converted, between 1 and 3999 inclusive.
Returns:
str: The Roman... |
magic_instruct_75k | 12,754 | Write a Python function to determine if a list of integers representing demand for products at different points in time forms a stacked line. A stacked line is defined as a sequence of demand values where each value is greater than or equal to the previous value. If the demand is stacked, the function should return `Tr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def isLineStacked(index: List[int]) -> bool:
"""
Determines if the given list of integers forms a stacked line.
A stacked line is defined as a sequence of demand values where each value is greater t... |
magic_instruct_75k | 12,755 | Write a Python function to extract specific details from a dictionary containing information about AWS compliance events. The function should handle cases where the input dictionary may not contain all the expected keys or may have nested structures with missing values. The function should return a new dictionary with ... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_compliance_details(event_dict: dict) -> dict:
"""
Extracts specific details from a dictionary containing AWS compliance event information.
Args:
event_dict (dict): A dictionary containing AWS compliance ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.