source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 20,538 | Write a Python function to analyze a dictionary containing file paths and their associated properties. The properties include "flag_deps" indicating whether the file has dependencies and "should_be_removed" indicating whether the file should be removed. The function should return a list of file paths that have dependen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def find_files_to_remove(file_properties: Dict[str, Dict[str, bool]]) -> List[str]:
"""
Analyzes the file properties dictionary and returns a list of file paths that have dependencies and should be... |
magic_instruct_75k | 20,539 | Create a Python script that automates the backup and restoration of tmux configuration files. The script should handle both the backup and restoration processes, ensuring that the original configuration files are backed up before any changes are made and that the backed-up files can be restored in case of a failed inst... | Here is the Python code to solve the given problem in the markdown block:
```python
import shutil
import os
def backup_tmux_config(backup_dir: str) -> None:
"""
Backs up the tmux configuration files to the specified backup directory.
Args:
backup_dir (str): The directory where the configuration fi... |
magic_instruct_75k | 20,547 | Write a Python function called `extract_fields` that takes a dictionary `config` as input and returns a list of field names present in the dictionary. The function should ignore any commented-out fields, which are denoted by a leading `#` character. The `config` dictionary will have the following format:
```python
con... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def extract_fields(config: Dict[str, str]) -> List[str]:
"""
Extracts field names from a configuration dictionary, ignoring any fields that are commented out.
Args:
config (Dict[str, s... |
magic_instruct_75k | 20,549 | Write a Python function to compute and return a tuple containing the sum, maximum, and minimum values of a given list of integers. The function should handle an empty list by returning a tuple with default values (0, 0, 0). The code should start with:
```python
from typing import List, Tuple
def sum_max_min_tuple(inpu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def sum_max_min_tuple(input_list: List[int]) -> Tuple[int, int, int]:
"""
Compute and return a tuple containing the sum, maximum, and minimum values of a given list of integers.
Args:
... |
magic_instruct_75k | 20,580 | Write a Python function to generate a setup script for packaging and distributing a Python project. The setup script should include metadata such as the project version, description, author, author's email, and a list of dependencies. The function should return the setup script as a string.
The function should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_setup_script(version: str, description: str, author: str, author_email: str, install_requires: list) -> str:
"""
Generates a setup script for packaging and distributing a Python project.
Args:
version (... |
magic_instruct_75k | 20,588 | Write a Python function to count the number of occurrences of a specific HTML tag within a given HTML document string. The HTML tags are represented in the string as follows:
- An opening tag is denoted by `<tagname>`
- A closing tag is denoted by `</tagname>`
The function should be named `countHtmlTags` and should ta... | Here is the Python code to solve the given problem in the markdown block:
```python
def countHtmlTags(html: str, tagname: str) -> int:
"""
Counts the number of occurrences of a specific HTML tag within a given HTML document string.
Args:
html (str): The input string representing the HTML document.
... |
magic_instruct_75k | 20,591 | Write a Python function to compute a new array where each element is the product of all the elements in the input array except the one at the same index. The function should not use division and should have a time complexity of O(n).
The code should start with:
```python
from typing import List
def product_except_sel... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def product_except_self(nums: List[int]) -> List[int]:
"""
Compute a new array where each element is the product of all elements in the input array except the one at the same index.
Args:
nu... |
magic_instruct_75k | 20,601 | Write a Python function `parseQuery` that takes a string representing a simplified SQL-like query as input and extracts the table name, columns, and conditions from the query. The input query will be in the following format:
```
SELECT <columns>
FROM <table>
WHERE <conditions>
```
Where:
- `<columns>`: A comma-separate... | Here is the Python code to solve the given problem in the markdown block:
```python
def parseQuery(query: str) -> None:
"""
Parses a simplified SQL-like query and extracts the table name, columns, and conditions.
Args:
query (str): A string representing a simplified SQL-like query in the format:
... |
magic_instruct_75k | 20,609 | Write a Python function to process a list of non-negative integers and perform the following operations:
1. Calculate the sum of all the numbers in the list.
2. Calculate the difference between the maximum and minimum numbers in the list.
3. Calculate the product of all the numbers in the list.
4. Calculate the result ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_numbers(numbers: List[int]) -> str:
"""
Processes a list of non-negative integers and performs various operations on them.
Args:
numbers (List[int]): A list of non-negative integ... |
magic_instruct_75k | 20,616 | Write a Python function to generate a random alphanumeric string of a specified length. The function should take an integer `length` as input and return a random string consisting of uppercase letters, lowercase letters, and digits. The code should start with:
```python
import random
import string
def generate_random_... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_random_string(length: int) -> str:
"""
Generate a random alphanumeric string of the specified length.
Args:
length (int): The length of the random string to generate.
R... |
magic_instruct_75k | 20,635 | Write a Python function `alphabet_positions(text: str) -> str` that takes a string `text` as input and returns a string containing the positions of the letters in the English alphabet. The positions are separated by spaces and are based on the input string `text`. The positions are determined by the letter's position i... | Here is the Python code to solve the given problem in the markdown block:
```python
def alphabet_positions(text: str) -> str:
"""
Returns a string containing the positions of the letters in the English alphabet
based on the input string. The positions are separated by spaces.
Args:
text (str): ... |
magic_instruct_75k | 20,639 | Write a Python function to calculate the time difference between two given timestamps in seconds. The timestamps are provided as `datetime` objects. The function should return the time difference as an integer.
The code should start with:
```python
from datetime import datetime
def calculate_time_difference(start_tim... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def calculate_time_difference(start_time: datetime, end_time: datetime) -> int:
"""
Calculate the time difference in seconds between two given timestamps.
Args:
start_time (datetime): ... |
magic_instruct_75k | 20,642 | Write a Python function to filter out certain names from a given list based on specific criteria. The function should take a list of strings as input and return a new list containing only the strings that do not meet the filtering criteria.
The filtering criteria are as follows:
1. Exclude any name that is one of the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_names(names: List[str]) -> List[str]:
"""
Filters out names from a given list based on specific criteria.
The criteria for exclusion are:
1. Any name that is one of the following: 'In... |
magic_instruct_75k | 20,652 | Write a Python function to count the occurrences of specific escape sequences in a given code snippet. The escape sequences to be counted are `\033[38;5;208m` and `\e[39m\e[49m`. The function should read the code snippet and output the count of occurrences for each escape sequence.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def count_escape_sequences(code_snippet: str) -> dict:
"""
Counts the occurrences of specific escape sequences in a given code snippet.
Args:
code_snippet (str): The code snippet containing the escape seq... |
magic_instruct_75k | 20,653 | Write a Python function to resolve dependencies for a software development project. The function should take in four parameters: `host` (the host server), `change_id` (the unique identifier for the change), `branch` (the branch of the project), and `patchset_rev` (the revision of the patchset). The function should retu... | Here is the Python code to solve the given problem in the markdown block:
```python
def resolve_dep(host: str, change_id: str, branch: str, patchset_rev: str) -> str:
"""
Resolves dependencies for a software development project based on the provided parameters.
Args:
host (str): The host server whe... |
magic_instruct_75k | 20,677 | Write a Python function that calculates and displays the total value of a person's age, height, and weight using string formatting. The function should accept four parameters: `name`, `age`, `height`, and `weight`. It should print the total value in two different formats:
1. Using an f-string to display the total value... | Here is the Python code to solve the given problem in the markdown block:
```python
def display_total_value(name: str, age: int, height: int, weight: int) -> None:
"""
Calculates and displays the total value of a person's age, height, and weight using string formatting.
Args:
name (str): The name o... |
magic_instruct_75k | 20,684 | Write a Python function to manipulate layers and anchors in a graphics software. The function should take two layer objects, `sourceLayer` and `targetLayer`, and perform the following operations:
1. If the number of anchors in `targetLayer` is not zero, clear out all the anchors in the `targetLayer`.
2. Return the numb... | Here is the Python code to solve the given problem in the markdown block:
```python
def manipulate_layers(sourceLayer, targetLayer) -> int:
"""
Manipulates the layers and anchors in a graphics software.
Args:
sourceLayer: An object representing the source layer with a property `anchors` that return... |
magic_instruct_75k | 20,705 | Write a Python function to filter a list of workloads based on certain criteria. Each workload is represented by a dictionary containing 'href' and 'label_keys' keys. Additionally, there is a condition to check if the workload is not already labeled as 'Quarantine'. If the workload meets this condition, it should be in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def filter_workloads(workloads: List[Dict[str, Union[str, List[str]]]]) -> List[Dict[str, Union[str, List[str]]]]:
"""
Filters a list of workloads based on the condition that the workload is... |
magic_instruct_75k | 20,719 | Write a Python function to filter a list of dictionaries representing election candidates based on the office they are seeking. Each dictionary contains the candidate's ID, name, and the office they are seeking. The function should return a new list containing only the candidates who are seeking a specific office.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def filter_candidates_by_office(candidates: List[Dict[str, str]], office: str) -> List[Dict[str, str]]:
"""
Filters a list of candidate dictionaries based on the office they are seeking.
Args:... |
magic_instruct_75k | 20,722 | Write a Python function to manage a reward system for a gaming application. The function should handle the configuration of a database, including the type of database, port number, and minimum reward value. Additionally, it should be capable of dumping the database output to a specified file path. After configuring the... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import time
import subprocess
def manage_reward_system(db_type: str, port: int, min_reward: int, out_pkl: str) -> None:
"""
Manages the reward system for a gaming application by configuring the database,
terminati... |
magic_instruct_75k | 20,730 | Write a Python function `processSpeciesInfo` that reads species information from a given file and formats it according to the specified format. The file contains data about various species, with each species entry on a separate line. The format for each entry is "Species Name, Common Name, Family". The function should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def processSpeciesInfo(filename: str) -> None:
"""
Reads species information from a file and formats it for display.
Args:
filename (str): The name of the file containing species information.
Returns:
N... |
magic_instruct_75k | 20,733 | Write a Python function to calculate the total number of channels in a deep learning model. The model consists of multiple blocks, each containing a certain number of channels. The function should take in the number of blocks and a list of the number of channels in each block, and return the total number of channels in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_total_channels(num_blocks: int, channels_per_block: List[int]) -> int:
"""
Calculate the total number of channels in a deep learning model.
Args:
num_blocks (int): The number o... |
magic_instruct_75k | 20,742 | Write a Python function to process a given data structure and populate a dictionary called 'ways' with specific information about the ways present in the elements list. The data structure is represented as a dictionary with a key 'elements' containing a list of elements. Each element is represented as a dictionary with... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_elements(parsed, nodes, tzname):
"""
Process the elements and populate the 'ways' dictionary.
Args:
parsed (dict): A dictionary containing the 'elements' list.
nodes (list): A list of nodes.
tzname (... |
magic_instruct_75k | 20,745 | Write a Python function to validate search queries for a web application. The function should check if the search query meets certain criteria and return a boolean value indicating its validity. The criteria for a valid search query are as follows:
1. The query must not be empty.
2. The query must not contain any speci... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_search_query(query: str) -> bool:
"""
Validate a search query based on the following criteria:
1. The query must not be empty.
2. The query must not contain any special characters such as `!`, `@`, `#`, `$`,... |
magic_instruct_75k | 20,762 | Write a Python function to process a dictionary containing information about game objects in a strategy game. The dictionary has two keys, "spawns" and "towers", each mapping to a list of objects. Each object is represented as a dictionary with "name", "type", and "position" keys. The "position" key maps to a tuple con... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple
def process_game_objects(game_objects: Dict[str, List[Dict[str, any]]]) -> Dict[str, Dict[str, any]]:
"""
Processes a dictionary containing information about game objects and returns a new d... |
magic_instruct_75k | 20,772 | Write a Python function to calculate the average salary of employees in a given department from a list of employee records. Each employee record is represented as a dictionary with keys "name" (string), "department" (string), and "salary" (float). The function should take the list of employee records and a department n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def average_salary_by_department(employees: List[Dict[str, Union[str, float]]], department: str) -> float:
"""
Calculate the average salary of employees in a given department.
Args:
... |
magic_instruct_75k | 20,795 | Write a Python function to implement a role-based access control system for a web application. The system should check if a user has the necessary role to access a specific resource. The function should take in a list of roles assigned to a user (`user_roles`) and a required role (`required_role`), and return `True` if... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
DEFAULT_ROLES = ["ADMIN_ROLE", "MEMBER_ROLE", "GUEST_ROLE"]
def check_access(user_roles: List[str], required_role: str) -> bool:
"""
Check if a user has the necessary role to access a specific resource.... |
magic_instruct_75k | 20,823 | Write a Python function to increment the quantity of an item in a dictionary. The dictionary `items` contains item IDs as keys and their quantities as values. The function should take the `items` dictionary and an integer `i_id` representing the item ID. If the item with ID `i_id` exists in the dictionary, its quantity... | Here is the Python code to solve the given problem in the markdown block:
```python
def increment_item_quantity(items: dict, i_id: int) -> dict:
"""
Increments the quantity of an item in the `items` dictionary.
If the item with ID `i_id` exists in the dictionary, its quantity is incremented by 1.
If th... |
magic_instruct_75k | 20,831 | Write a Python function to count the number of unique labels present in the value associated with the 'label_count' key within a given dictionary of model settings. The model settings are represented as a dictionary where the keys are strings and the values can be of various types. The 'label_count' key holds a value t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def count_unique_labels(model_settings: Dict[str, List[str]]) -> int:
"""
Count the number of unique labels present in the value associated with the 'label_count' key in the model settings.
Ar... |
magic_instruct_75k | 20,853 | Write a Python function to generate the `swaylock` command based on the given parameters. The function should take the file path, indicator radius, indicator thickness, and background color as input and return the complete `swaylock` command as a string. The `swaylock` command format is as follows:
```
swaylock --indic... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_swaylock_command(file_path: str, indicator_radius: int, indicator_thickness: int, background_color: str) -> str:
"""
Generates the `swaylock` command based on the given parameters.
Args:
file_path (str)... |
magic_instruct_75k | 20,860 | Write a Python function to find the key that took the longest time to release from a sequence of key presses in a video game. The function should return the key that has the longest release time. If there are multiple keys with the same longest release time, return the lexicographically largest key.
The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def slowestKey(releaseTimes: List[int], keysPressed: str) -> str:
"""
Find the key that took the longest time to release from a sequence of key presses.
Args:
releaseTimes (List[int]): A lis... |
magic_instruct_75k | 20,874 | Write a Python function to implement a custom `Results` class that can store and manipulate a collection of integers. The `Results` class should provide methods for adding integers, calculating the sum of all integers, and finding the maximum integer in the collection.
The code should start with:
```python
class Resul... | Here is the Python code to solve the given problem in the markdown block:
```python
class Results:
def __init__(self):
"""
Initialize the Results class with an empty list to store integers.
"""
self.integers = []
def add_integer(self, number: int) -> None:
"""
Ad... |
magic_instruct_75k | 20,875 | Write a Python function to generate a noisy image with a random circle drawn on it. The function should take in the size of the image, the maximum radius for the circle, and the noise level. The function should then draw a random circle on the image and add noise to it before returning the circle's parameters and the n... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def draw_circle(image: np.ndarray, row: int, col: int, radius: int) -> None:
"""
Draws a circle on the given image at the specified position with the given radius.
Args:
image (np.ndarray): The i... |
magic_instruct_75k | 20,882 | Write a Python function to calculate the effective swap space provided by a zram device given the size of physical memory (in bytes) and the compression ratio. The function should take two parameters: `physical_memory_size` (an integer representing the size of physical memory in bytes) and `compression_ratio` (a float ... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_swap_space(physical_memory_size: int, compression_ratio: float) -> int:
"""
Calculate the effective swap space provided by a zram device given the size of physical memory and the compression ratio.
Args:
... |
magic_instruct_75k | 20,888 | Write a Python function to count the number of occurrences of a specific character within a given string. The function should take a string and a character as input and return the count of occurrences of the given character within the string. The function should be efficient and handle strings of length up to \(10^5\).... | Here is the Python code to solve the given problem in the markdown block:
```python
def countCharOccurrences(inputString: str, targetChar: str) -> int:
"""
Counts the number of occurrences of a specific character within a given string.
Args:
inputString (str): The input string to be processed.
... |
magic_instruct_75k | 20,907 | Write a Python function to clean and transform a dictionary representing a person's demographic and health information. The function should perform the following transformations:
1. Remove any key-value pairs where the value is `None`.
2. Convert the 'Year of Birth' to an integer representing the person's age in 2022.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_demographics(input_dict: dict) -> dict:
"""
Cleans and transforms a dictionary representing a person's demographic and health information.
Args:
input_dict (dict): A dictionary containing the person's de... |
magic_instruct_75k | 20,914 | Write a Python function to retrieve the parameterable elements for a template in a software modeling tool. The function should return a set of parameterable elements that can be used as the parametered elements for a template parameter of a given templateable element. The default behavior includes all the owned element... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set, List
def parameterable_elements(owned_elements: List[str]) -> Set[str]:
"""
Retrieves the parameterable elements for a template in a software modeling tool.
The function returns a set of parameterab... |
magic_instruct_75k | 20,918 | Write a Python function to filter a list of tuples based on specific criteria. Each tuple in the input list consists of an integer and a string. The function should return a new list containing only the tuples that satisfy the following conditions:
1. The integer in the tuple is greater than 2.
2. The string in the tup... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def filter_tuples(input_list: List[Tuple[int, str]]) -> List[Tuple[int, str]]:
"""
Filters a list of tuples based on specific criteria.
Args:
input_list (List[Tuple[int, str]]): A lis... |
magic_instruct_75k | 20,934 | Write a Python function `calculate_final_price` that calculates the final price of a product after applying a given tax rate. The function should optionally format the result as a currency value. The function should adhere to the following specifications:
- `num`: A float representing the initial price of the product.... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_final_price(num: float, tax: float, formato: bool) -> float or str:
"""
Calculate the final price of a product after applying a given tax rate.
Optionally format the result as a currency value.
Args:
... |
magic_instruct_75k | 20,943 | Write a Python function to combine two lists of integers in reverse order. The function should take two lists as input and return a new list that contains the elements of both input lists in reverse order. The elements of the first list (`valid`) should appear after the elements of the second list (`valid2`) in the rev... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_combine(valid: List[int], valid2: List[int]) -> List[int]:
"""
Combines two lists of integers in reverse order.
Args:
valid (List[int]): The first list of integers.
valid... |
magic_instruct_75k | 20,973 | Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should efficiently handle both positive and negative integers. The function should have the following signature:
```python
from typing import List
def max_subarray_sum(nums: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(nums: List[int]) -> int:
"""
Find the maximum sum of a contiguous subarray within the given list of integers.
Args:
nums (List[int]): The list of integers from which to ... |
magic_instruct_75k | 20,974 | Write a Python function to count the occurrences of each one-letter word in a given list of strings. Each string in the list contains a single letter surrounded by spaces. The function should return a dictionary where the keys are the letters and the values are the number of occurrences of each letter in the list.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_one_letter_words(words: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each one-letter word in a given list of strings.
Args:
words (List[str]): A list of string... |
magic_instruct_75k | 20,975 | Write a Python function to generate a list of lexicographically ordered strings based on the input string `a_string` and the integer `n`. The function should produce `n` lexicographically ordered strings derived from the input string. The code should start with:
```python
def generate_lexico_strings(a_string: str, n: i... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_lexico_strings(a_string: str, n: int) -> list:
"""
Generate a list of lexicographically ordered strings based on the input string `a_string` and the integer `n`.
Args:
a_string (str): The input string f... |
magic_instruct_75k | 20,988 | Write a Python function to calculate the maximum data usage in megabytes (MB) for a given list of daily data usage values, rounded up to the nearest whole number, and formatted as a string with "M" appended to it. The function should handle an empty list by returning "0M".
The code should start with:
```python
import ... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
from typing import List
def phone_max_use_raw(l_men: List[int]) -> str:
"""
Calculate the maximum data usage in megabytes (MB) for a given list of daily data usage values,
rounded up to the nearest whole number,... |
magic_instruct_75k | 20,993 | Write a Python function to detect the presence of certain plugins in HTML content and HTTP headers. The function should take in three parameters: `html` (a string representing the HTML content of a webpage), `headers` (a dictionary representing the HTTP headers of the webpage), and `plugin_detection_schema` (a list of ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def detect_plugins(html: str, headers: dict, plugin_detection_schema: list) -> bool:
"""
Detects the presence of plugins in HTML content and HTTP headers.
Args:
html (str): A string representing the HTML ... |
magic_instruct_75k | 20,995 | Write a Python function to determine the caging squares on a game board based on the given coordinates. The game board consists of squares identified by their x and y coordinates. The function `get_square(x, y)` returns the square at the specified coordinates. The caging squares are determined based on the input coordi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def determine_caging_squares(x: int, y: int) -> List[int]:
"""
Determine the caging squares on a game board based on the given coordinates.
Args:
x (int): The x-coordinate of the square.
... |
magic_instruct_75k | 21,019 | Write a Python function to manage a simple photo management system. The system should allow users to upload photos, set a default photo, and retrieve the default photo. The code should start with:
```python
from typing import Dict, Any
def upload_photo(photo_data: Dict[str, Any], default_photo: Dict[str, Any]) -> None... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def upload_photo(photo_data: Dict[str, Any], default_photo: Dict[str, Any]) -> None:
"""
Upload a photo to the system.
Args:
photo_data (Dict[str, Any]): A dictionary containing informa... |
magic_instruct_75k | 21,028 | Write a Python function to convert the amount of water consumed in milliliters to liters, rounded to three decimal places. The function should take an integer `milliliters` as input and return a string representing the amount of water consumed in liters, rounded to three decimal places.
The code should start with:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_liters(milliliters: int) -> str:
"""
Converts the amount of water consumed in milliliters to liters and returns it as a string rounded to three decimal places.
Args:
milliliters (int): The amount of w... |
magic_instruct_75k | 21,038 | Create a Python class `Logger` that encapsulates logging functionality and assertion mechanism. The class should support logging messages at different levels (`info`, `warning`, `error`, and `debug`) and provide a method `assertCondition` to assert that a given condition should be true. If the condition is false, an er... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
class Logger:
def __init__(self, output_destination: str = 'console', file_path: str = None):
"""
Initialize the Logger with the specified output destination.
Args:
output_destination... |
magic_instruct_75k | 21,039 | Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. If the list is empty or contains only negative numbers, the function should return 0. The function should be efficient and use an optimal approach to solve the problem.
The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(nums: List[int]) -> int:
"""
Find the maximum sum of a contiguous subarray within the given list of integers.
Args:
nums (List[int]): The list of integers from which to ... |
magic_instruct_75k | 21,061 | Write a Python function to add an adduct to the metadata of a given spectrum if the adduct is not already present. The function should interpret the compound name to determine the adduct and then update the metadata accordingly. The function should start with:
```python
from typing import Dict, Any
def add_adduct(spec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def add_adduct(spectrum_in: Dict[str, Any]) -> Dict[str, Any]:
"""Add adduct to metadata (if not present yet).
Method to interpret the given compound name to find the adduct.
Args:
spe... |
magic_instruct_75k | 21,068 | Write a Python function to remove all instances of a specified value from a given list of integers in-place and return the new length of the list. The function should not allocate extra space for another list; it must modify the input list in-place with O(1) extra memory.
The function should start with:
```python
from... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def removeElement(nums: List[int], val: int) -> int:
"""
Remove all instances of a specified value from the given list of integers in-place and return the new length of the list.
Args:
nums ... |
magic_instruct_75k | 21,083 | Write a Python function to simulate flipping tiles on a game board. The game board consists of a grid of tiles, each identified by its position. Initially, all tiles are in the "off" state. The function should take a list of tile positions to flip and return the final state of the tiles after applying the flipping oper... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def flip_tiles(tile_positions: List[Tuple[int, int]]) -> List[Tuple[int, int]]:
"""
Simulates flipping tiles on a game board and returns the final state of the tiles.
Args:
tile_posit... |
magic_instruct_75k | 21,087 | Write a Python function that simulates a basic data service for updating financial and trade information for stocks. The function should handle the following scenarios:
- If the function is called with the `updateFinanceBasic` method and a stock symbol, it should update the finance basic information for the given stock... | Here is the Python code to solve the given problem in the markdown block:
```python
def updateFinanceBasic(stock_symbol: str) -> str:
"""
Simulates updating finance basic information for a given stock symbol.
Args:
stock_symbol (str): The stock symbol for which to update finance basic information.
... |
magic_instruct_75k | 21,094 | Write a Python function to calculate the ratio of each stock price to the previous day's stock price from a given list of stock prices. The function should return a list of ratios, where each ratio is the current day's stock price divided by the previous day's stock price. The first ratio in the list should be 1, as th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_price_ratios(stock_prices: List[int]) -> List[float]:
"""
Calculate the ratio of each stock price to the previous day's stock price.
Args:
stock_prices (List[int]): A list of p... |
magic_instruct_75k | 21,139 | Write a Python function to generate a unique identifier based on the validity of an input. The function should take a boolean parameter `valid` and return a string that combines a prefix and a randomly generated 6-digit alphanumeric code. If the input `valid` is `True`, the prefix should be 'valid_', otherwise, it shou... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_identifier(valid: bool) -> str:
"""
Generates a unique identifier based on the validity of an input.
Args:
valid (bool): A boolean indicating the validity of the input.
... |
magic_instruct_75k | 21,184 | Write a Python function to find the top N repositories with the highest number of GitHub stars for executable files within the directories listed in the PATH environment variable. The function should perform the following steps:
1. Iterate through each directory in the PATH environment variable.
2. For each directory, ... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import requests
from typing import List, Dict
def get_top_github_repos(n: int) -> List[Dict[str, str]]:
"""
Find the top N repositories with the highest number of GitHub stars for executable files within the directori... |
magic_instruct_75k | 21,185 | Write a Python function that processes a list of command-line arguments and performs specific operations on them. The function should:
1. Accept a list of command-line arguments as input.
2. Iterate through the list of arguments and print each argument on a new line.
3. Print the length of the list of arguments.
4. Pri... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_command_line_args(args: List[str]) -> None:
"""
Processes a list of command-line arguments and performs specific operations on them.
Args:
args (List[str]): A list of command-lin... |
magic_instruct_75k | 21,188 | Write a Python function `check_permission(user, action, user_permissions)` that checks if a given user has permission to perform a specified action based on a provided dictionary of user permissions. The function should return `True` if the user has the specified permission and `False` otherwise.
The function should a... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_permission(user: str, action: str, user_permissions: dict) -> bool:
"""
Checks if a given user has permission to perform a specified action.
Args:
user (str): The name of the user for whom permission needs... |
magic_instruct_75k | 21,202 | Write a Python function to parse and update a version string by incorporating an optional build number. The version string is in the format "x.y.z", where x, y, and z are non-negative integers. The build number is an optional non-negative integer that can be appended to the version string. If the build number is not pr... | Here is the Python code to solve the given problem in the markdown block:
```python
def add_build_number(version: str, build_number: int = 0) -> str:
"""
Parses and updates a version string by incorporating an optional build number.
Args:
version (str): The version string in the format "x.y.z", whe... |
magic_instruct_75k | 21,210 | Write a Python function to determine whether a given integer is a palindrome without converting the integer to a string. A palindrome is a number that reads the same backward as forward. For example, 121 is a palindrome, while 123 is not. The function should handle negative numbers and numbers ending with zero appropri... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(x: int) -> bool:
"""
Determine whether a given integer is a palindrome without converting it to a string.
Args:
x (int): The integer to check for palindrome property.
Returns:
bool: Tr... |
magic_instruct_75k | 21,223 | Write a Python function to determine if a given string containing only brackets is valid. The function should return `True` if the brackets in the string are well-formed and balanced, and `False` otherwise. The string may contain the characters '(', ')', '{', '}', '[', and ']'. A bracket is considered to be well-formed... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_brackets(s: str) -> bool:
"""
Determines if a given string containing only brackets is valid.
Args:
s (str): The string containing only brackets to be validated.
Returns:
bool: True if the ... |
magic_instruct_75k | 21,230 | Write a Python function to process user data and store it in a database. The function should read a list of user data from a source, convert the user scores to integers, and then check if each user already exists in the database. If a user does not exist, the function should print a message indicating that the user wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_user_data(data: List[Dict[str, str]], users: Dict[str, int]) -> None:
"""
Process user data and check if each user exists in the database.
Args:
data (List[Dict[str, str]])... |
magic_instruct_75k | 21,256 | Write a Python function to determine whether a repository should be created based on certain criteria. The function should take the name of the repository and a dictionary containing "omit_..." keys, each associated with a boolean value. The function should construct a key using the repository name and check if the cor... | Here is the Python code to solve the given problem in the markdown block:
```python
def should_create_repository(name: str, args: dict) -> bool:
"""
Determines whether a repository should be created based on the given criteria.
Args:
name (str): The name of the repository to be checked.
arg... |
magic_instruct_75k | 21,273 | Write a Python function `calculate_average_temperature(data, var_units, color_maps, default_value)` that processes weather station data to calculate the average temperature for each month. The function should handle missing data by replacing it with a specified default value and allow for customization of units and col... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_average_temperature(data, var_units, color_maps, default_value):
"""
Calculate the average temperature for each month from weather station data.
Args:
data (dict): A dictionary containing temperature d... |
magic_instruct_75k | 21,275 | Write a Python function to maximize the total weight of items that can be loaded onto a truck without exceeding its capacity. The function should take a list of weights representing the weights of items and an integer representing the truck's weight capacity. Each item can only be loaded once, and you can only load who... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def maximize_load(weights: List[int], capacity: int) -> int:
"""
Calculate the maximum total weight of items that can be loaded onto a truck without exceeding its capacity.
Args:
weights (Li... |
magic_instruct_75k | 21,296 | Write a Python function to perform a unit test for a module in an Intrusion Detection System (IDS) software. The function should validate the correctness of the module's properties based on the provided information. The module is represented by a dictionary with the following keys:
- `name` (string): Name of the module... | Here is the Python code to solve the given problem in the markdown block:
```python
def testModuleProperties(module: dict, s_module_name: str, current_filename: str, m_engine_ib: str, s_delegate_initialized: bool) -> None:
"""
Perform a unit test for the module in the IDS software and validate its properties.
... |
magic_instruct_75k | 21,298 | Write a Python function to extract all tags enclosed within angle brackets from a given input string. The tags can contain alphanumeric characters, hyphens, and underscores. The function should return a list of these tags in the order they appear in the input string. If no tags are found, the function should return an ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_tags(input_string: str) -> List[str]:
"""
Extracts all tags enclosed within angle brackets from the given input string.
Args:
input_string (str): The input string conta... |
magic_instruct_75k | 21,325 | Write a Python function to calculate the average accuracy of a machine learning model over multiple epochs of training and testing. The function should use the provided `train` and `test` functions to train the model and evaluate its accuracy on the test dataset after each epoch. Finally, it should return the average a... | Here is the Python code to solve the given problem in the markdown block:
```python
def average_accuracy(train_loader, test_loader, model, optimizer, loss_fn, device, total_epochs):
"""
Calculate the average accuracy of a machine learning model over multiple epochs of training and testing.
Args:
tr... |
magic_instruct_75k | 21,342 | Write a Python function to generate a SLURM job submission script for a computational chemistry application using the ORCA software. The script should include the following components:
- Set the job name based on the value of the variable `root`.
- Specify the output file for the job.
- Set the number of nodes and task... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_slurm_script(root: str, output_file: str, nodes: int, tasks_per_node: int, time_limit: str, cluster: str, workdir: str, input_files: list) -> str:
"""
Generates a SLURM job submission script for a computational chem... |
magic_instruct_75k | 21,345 | Write a Python function to simulate the behavior of the `exec` command for managing Docker containers. The function should handle the execution of a specified command within a running container. Additionally, implement a `help` function to display usage information for the script.
The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
def exec_container(container_name: str, command: str) -> None:
"""
Simulate the execution of a command within a running Docker container.
Args:
container_name (str): The name of the Docker container.
command... |
magic_instruct_75k | 21,353 | Write a Python function to simulate a simple event setup registration system. The function should allow users to register event setup records and then retrieve information about the registered records. The function should use a provided macro to register the records and store them in a data structure for later retrieva... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
# Global list to store registered event setup records
registered_records = []
def register_event_setup_record(record_name: str) -> None:
"""
Register an event setup record using a provided macro.
A... |
magic_instruct_75k | 21,357 | Write a Python function to extract all occurrences of license information from a given text. The license information is enclosed within a specific format and may appear multiple times within the text. The function should return a list of all the license names found in the text.
The license information is enclosed with... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_licenses(text: str) -> List[str]:
"""
Extracts all occurrences of license information from a given text.
Args:
text (str): The input text from which to extract the lice... |
magic_instruct_75k | 21,379 | Create a Python function that implements a memoization decorator to optimize the performance of a function by caching its results. The decorator should be able to handle functions with any number of arguments, including both positional and keyword arguments. The task should include a sample function to demonstrate the ... | Here is the Python code to solve the given problem in the markdown block:
```python
import functools
def memoized(func):
"""
A memoization decorator that caches the results of the decorated function.
This decorator works for functions with any number of arguments, including
both positional and keyword... |
magic_instruct_75k | 21,410 | Write a Python function to calculate the average temperature for each month from a given list of tuples. Each tuple contains a date in the format "YYYY-MM-DD" and a corresponding temperature in degrees Fahrenheit. The function should return a dictionary where the keys are the month-year combinations (e.g., "2005-07") a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
from collections import defaultdict
def calculate_monthly_avg_temperatures(data: List[Tuple[str, int]]) -> Dict[str, float]:
"""
Calculate the average temperature for each month from a list ... |
magic_instruct_75k | 21,419 | Write a Python function `find_zip_files` that processes a list of file paths and returns a list of paths that point to ZIP files. The function should use the provided `is_zipfile_url` function to determine if a given path points to a ZIP file. The function should handle various edge cases and invalid inputs gracefully.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def is_zipfile_url(path: str) -> bool:
pattern = r"download/temp/\d+?\.zip"
match = re.search(pattern, path)
return match is not None
def find_zip_files(paths: List[str]) -> List[str]:
... |
magic_instruct_75k | 21,449 | Write a Python function to calculate the delay for each clock based on a given delay ratio and return a dictionary mapping each clock name to its corresponding delay. The delay for each clock is calculated using the formula: `delay = delay_ratio * clock_period`, where the clock period is the reciprocal of the clock fre... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def calculate_clock_delays(delay_ratio: float, clk_names: List[str]) -> Dict[str, float]:
"""
Calculate the delay for each clock based on the given delay ratio and return a dictionary mapping each ... |
magic_instruct_75k | 21,454 | Write a Python function to generate a code snippet for a "jump" statement in a programming language. The function should take an identifier as a parameter and return a string representing the code for a jump statement to the specified identifier. The identifier is formed by concatenating the string "_l" with the given ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_jump_code(identifier: str) -> str:
"""
Generates a code snippet for a "jump" statement in a programming language.
The jump statement is used to transfer control to a specific location in the code.
The targe... |
magic_instruct_75k | 21,466 | Write a Python function `extract_second_element` that takes a list of tuples as input and returns a new list containing the second element of each tuple. The function should be implemented using a lambda function and the `map` function. The function signature is:
```python
from typing import List, Tuple, Any
def extra... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Any
def extract_second_element(lst: List[Tuple[Any, Any]]) -> List[Any]:
"""
Extracts the second element from each tuple in the given list of tuples.
Args:
lst (List[Tuple[Any, Any]]... |
magic_instruct_75k | 21,473 | Write a Python function to format software license information from a given dictionary. The dictionary contains details about the license, including the GPL version, the type of license, and a license template. The function should return a formatted string summarizing the license information in the specified format.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
def format_license_info(license_details: dict) -> str:
"""
Formats the software license information from a given dictionary into a specified string format.
Args:
license_details (dict): A dictionary containing the l... |
magic_instruct_75k | 21,495 | Write a Python function to count the total number of edges in a given graph represented as a dictionary. Each node in the graph is represented by a key in the dictionary, and the value is another dictionary where the keys are edge labels and the values are tuples representing the edges. Each edge tuple contains the ID ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple, List
def count_edges(graph: Dict[int, Dict[str, List[Tuple[int, str, bool]]]]) -> int:
"""
Count the total number of edges in a given graph represented as a dictionary.
Args:
graph (... |
magic_instruct_75k | 21,547 | Write a Python function `detect_concept_drift(x, concept_drift_index)` that detects concept drift in a machine learning model. The function should take in a NumPy array `x` representing the input data for the model and an integer `concept_drift_index` representing the concept drift index calculated based on the number ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def detect_concept_drift(x, concept_drift_index):
"""
Detects concept drift in a machine learning model based on the given criteria.
Args:
x (numpy.ndarray): A NumPy array representing the input ... |
magic_instruct_75k | 21,562 | Create a Python function to implement a queue data structure using a linked list approach. The queue should follow the First In First Out (FIFO) principle, where elements are added to the back and removed from the front. The function should include the following methods:
1. `enqueue(element)`: Add an element to the ba... | 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 Queue:
def __init__(self):
self.front = None
self.rear = None
def enqueue(self, element):
"""
... |
magic_instruct_75k | 21,568 | Write a Python function to calculate the total amount of deposits from a list of financial transaction tuples. Each transaction tuple contains a Transaction ID, a Transaction Type ('D' for deposit, 'W' for withdrawal), and a Transaction Amount. The function should sum up the amounts of all transactions that are deposit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def total_deposits(transactions: List[Tuple[str, str, int]]) -> int:
"""
Calculate the total amount of deposits from a list of financial transaction tuples.
Args:
transactions (List[T... |
magic_instruct_75k | 21,570 | Write a Python function to implement a task scheduler for a mobile application that manages the execution of three specific lifecycle methods: `applicationWillResignActive`, `applicationDidEnterBackground`, and `applicationWillEnterForeground`. The scheduler should ensure that the appropriate method is called at the ri... | Here is the Python code to solve the given problem in the markdown block:
```python
class TaskScheduler:
def __init__(self):
"""
Initialize the TaskScheduler with default state and tasks.
"""
self.is_active = True
self.tasks = []
def applicationWillResignActive(self):
... |
magic_instruct_75k | 21,579 | Write a Python function to manage event subscriptions and triggers. The function should allow users to subscribe to events with callback functions and trigger those events with optional event data. The function should also handle unsubscribing from events.
The code should start with:
```python
from typing import Calla... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Callable, Any, Dict, List
def event_manager() -> Dict[str, List[Callable[[Any], None]]]:
"""
Manages event subscriptions and triggers.
Returns:
dict: A dictionary where keys are event names and v... |
magic_instruct_75k | 21,585 | Write a Python function to calculate the average streamflow from a given numpy array. The streamflow data is represented by the numpy array `Q`, where each element represents the streamflow value at a specific time interval. The function should handle empty arrays by returning `None` and should return the average strea... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def calculate_average_streamflow(Q: np.array) -> float:
"""
Calculate the average streamflow from a given numpy array.
Args:
Q (np.array): A numpy array representing the streamflow data.
Ret... |
magic_instruct_75k | 21,588 | Write a Python function to parse a string representing a date in the format "YYYY-MM-DD" and return the corresponding `datetime` object. The function should ensure that the time component of the `datetime` object is set to midnight (00:00:00).
The code should start with:
```python
from datetime import datetime
def pa... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def parse_date(date_str: str) -> datetime:
"""
Parse a string representing a date in the format "YYYY-MM-DD" and return the corresponding datetime object.
Args:
date_str (str): A strin... |
magic_instruct_75k | 21,603 | Write a Python function to determine the frequency of each letter in a given string and return the result as a dictionary where the keys are the letters and the values are their respective frequencies. The function should handle strings consisting of lowercase English letters only.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def letter_frequency(s: str) -> dict:
"""
Calculate the frequency of each letter in the given string.
Args:
s (str): The input string consisting of lowercase English letters.
Returns:
dict: A dictionary... |
magic_instruct_75k | 21,608 | Write a Python function to generate a random string of a specified length. The function should take an integer `length` as input and return a random string consisting of uppercase letters, lowercase letters, and digits. Additionally, write a set of unit tests to ensure the validity of the generated strings.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_random_string(length: int) -> str:
"""
Generate a random string of specified length consisting of uppercase letters, lowercase letters, and digits.
Args:
length (int): The l... |
magic_instruct_75k | 21,611 | Write a Python function `manage_package` that takes a dictionary as input, where the keys represent different package attributes and the values represent the corresponding values for those attributes. The function should return a formatted string representing the package management information. The output string should... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def manage_package(package_info: Dict[str, str]) -> str:
"""
Formats package management information based on the provided dictionary.
Args:
package_info (Dict[str, str]): A dictionary where ... |
magic_instruct_75k | 21,644 | Create a Python function to implement a simple key-value store. The key-value store should support three operations: setting a key-value pair, getting the value associated with a key, and removing a key-value pair. The function should handle cases where the key does not exist.
The code should start with:
```python
fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, Dict, Optional
def create_store() -> Dict[str, Any]:
"""
Create a simple key-value store with set, get, and remove operations.
Returns:
Dict[str, Any]: A dictionary containing the store oper... |
magic_instruct_75k | 21,658 | Write a Python function to compute the transpose of a given 2D matrix. The transpose of a matrix is obtained by swapping its rows with its columns. The function should handle matrices of varying dimensions, including non-square matrices.
The code should start with:
```python
from typing import List
def transpose_matr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def transpose_matrix(matrix: List[List[int]]) -> List[List[int]]:
"""
Compute the transpose of a given 2D matrix.
The transpose of a matrix is obtained by swapping its rows with its columns.
Ar... |
magic_instruct_75k | 21,663 | 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 | 21,664 | Write a Python function to map DNS error codes to their corresponding human-readable error messages. The function should take an integer `rcode` as input and return the corresponding error message based on the DNS protocol specifications. If the input `rcode` does not match any known error code, the function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
def dns_error_message(rcode: int) -> str:
"""
Returns a human-readable error message corresponding to the given DNS error code (rcode).
Args:
rcode (int): The DNS response code to be mapped to an error message.
... |
magic_instruct_75k | 21,667 | Write a Python function to generate a command that copies a specified wallpaper from a base directory to a temporary location. The function should take the base directory path and the wallpaper filename as inputs and return the command string in a specific format.
The code should start with:
```python
def generate_wal... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_wallpaper_copy_command(base_dir: str, wallpaper_filename: str) -> str:
"""
Generates a command to copy a specified wallpaper from a base directory to a temporary location.
Args:
base_dir (str): The base... |
magic_instruct_75k | 21,686 | Write a Python function to automate the execution of two shell scripts in a specific sequence. The function should execute the `publish-all-lambda-layers.sh` script located in the `${SCRIPT_DIR}` directory and then the `bump.sh` script located in the `${ROOT_DIR}` directory. The function should handle any potential err... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
import os
def execute_scripts(script_dir: str, root_dir: str) -> None:
"""
Automates the execution of two shell scripts in a specific sequence.
The function executes the `publish-all-lambda-layers.sh` scr... |
magic_instruct_75k | 21,713 | Write a Python function to generate a complete HTML output based on a provided layout and given content. The layout is a template that uses the Laravel framework's Blade syntax. The function should take a string `content` and return the complete HTML output with the content placed within the `@section('content')` direc... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_html(content: str) -> str:
"""
Generates a complete HTML output based on a provided layout and given content.
The layout uses Laravel's Blade syntax, where the content is placed within the
`@section('conten... |
magic_instruct_75k | 21,721 | Write a Python function to perform a custom deep copy of a nested list without using the built-in `copy` module. The function should be able to handle lists containing other lists and primitive data types. The function should be named `custom_deep_copy` and should take a single argument `original_list`, which is the li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def custom_deep_copy(original_list: List[Any]) -> List[Any]:
"""
Perform a custom deep copy of a nested list without using the built-in `copy` module.
Args:
original_list (List[Any]): T... |
magic_instruct_75k | 21,722 | Write a Python function to count the occurrences of opening and closing braces in a given string. The function should return a dictionary with the count of opening braces under the key "opening" and the count of closing braces under the key "closing".
The code should start with:
```python
def count_braces(source: str)... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_braces(source: str) -> dict:
"""
Counts the occurrences of opening and closing braces in the given string.
Args:
source (str): The string containing braces to be counted.
Returns:
dict: A dict... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.