source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 36,673 | Write a Python function to calculate the mean, median, mode, and range of a given list of numerical or categorical data. The function should handle both types of data and return the respective statistical measures. If the input list is empty, the function should return specific default values: 0 for mean, median, and r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union, Optional
def calculate_statistics(data: List[Union[int, float, str]]) -> dict:
"""
Calculate the mean, median, mode, and range of a given list of numerical or categorical data.
Args:
... |
magic_instruct_75k | 36,680 | Write a Python function to determine if a book was returned on time based on the borrowing date, return date, and due date. The function should return a boolean value indicating whether the book was returned on or before the due date. The function should handle cases where the return date is exactly the due date as wel... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def is_book_returned_on_time(borrowing_date: datetime, return_date: datetime, due_date: datetime) -> bool:
"""
Determines if a book was returned on time based on the borrowing date, return date, an... |
magic_instruct_75k | 36,682 | Write a Python function to find the first three unique alphabetic characters in a given string, ignoring case differences. If there are fewer than three unique alphabetic characters, the function should return all unique alphabetic characters found. The function should start with:
```python
def first_three_unique_chars... | Here is the Python code to solve the given problem in the markdown block:
```python
def first_three_unique_chars(input_string: str) -> str:
"""
Finds the first three unique alphabetic characters in a given string, ignoring case differences.
Args:
input_string (str): The input string from which to e... |
magic_instruct_75k | 36,688 | Write a Python function to simulate rolling two dice `n` times and return the frequency of each possible sum from 2 to 12 as a dictionary. The function should use a specific random seed for reproducibility.
The code should start with:
```python
import numpy as np
def simulate_dice_rolls(n: int) -> dict:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def simulate_dice_rolls(n: int) -> dict:
"""
Simulate rolling two dice 'n' times and return the frequency of each possible sum from 2 to 12.
Args:
n (int): The number of times to roll the two dic... |
magic_instruct_75k | 36,704 | Write a Python function to simulate the uninstallation process of applications based on their noise level. The function should handle two types of uninstallation processes: `QuietUninstall` for applications that should be uninstalled silently, and `LoudUninstall` for applications that require a more visible and audible... | Here is the Python code to solve the given problem in the markdown block:
```python
def uninstall_application(app_info: dict) -> None:
"""
Simulates the uninstallation process of an application based on its noise level.
Args:
app_info (dict): A dictionary containing information about the applicatio... |
magic_instruct_75k | 36,708 | Write a Python function to find the index of the first occurrence of a target integer in a given list of integers. If the target integer is not found in the list, the function should return -1. The function should be efficient and should handle edge cases such as an empty list or a list that does not contain the target... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_target_index(arr: List[int], target: int) -> int:
"""
Find the index of the first occurrence of the target integer in the given list.
Args:
arr (List[int]): The list of integers to ... |
magic_instruct_75k | 36,711 | Write a Python function to retrieve the URL of a pre-trained Vision Transformer (ViT) model based on the specified model name and image resolution. The function should take two input parameters: `model_name` (a string) and `image_resolution` (a tuple of three integers representing the image dimensions in the format `(c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Dict
def get_vit_model_url(model_name: str, image_resolution: Tuple[int, int, int]) -> str:
"""
Retrieves the URL of a pre-trained Vision Transformer (ViT) model based on the specified model name and i... |
magic_instruct_75k | 36,727 | Write a Python function to parse command-line arguments for a server gateway application. The function should handle the following arguments:
1. `-p <port>` or `--port <port>`: Specifies the port number on which the server will listen for incoming requests. The port number should be a positive integer.
2. `-h` or `--he... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
def parse_arguments(args: list) -> dict:
"""
Parses command-line arguments for a server gateway application.
Args:
args (list): A list of command-line arguments.
Returns:
dict: A dictionary ... |
magic_instruct_75k | 36,744 | Write a Python function to determine if a given string contains only empty spaces. The function should return `True` if the string contains only empty spaces, and `False` otherwise. You are not allowed to use any built-in string methods or regular expressions to solve this problem.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def empty_space(s: str) -> bool:
"""
Determines if a given string contains only empty spaces.
Args:
s (str): The input string to be checked.
Returns:
bool: True if the string contains only empty spaces,... |
magic_instruct_75k | 36,780 | Write a Python script to automate the installation of Go packages and their dependencies. The script should read an input file containing package names, execute the necessary `go get` and `go install` commands to fetch and build the packages and their dependencies. The input file will contain package names in the follo... | Here is the Python code to solve the given problem in the markdown block:
```python
import subprocess
def install_go_packages(input_file: str) -> None:
"""
Automates the installation of Go packages and their dependencies by reading an input file
containing package names, executing the necessary `go get` an... |
magic_instruct_75k | 36,782 | Write a Python function to analyze gas usage statistics for different blocks in a city and return a summary of the data. The function should take a dictionary where keys are block IDs and values are gas usage amounts. The summary should include the total gas usage, average gas usage, and the block with the highest gas ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def analyze_gas_stats(gas_stats: Dict[str, int]) -> Dict[str, float]:
"""
Analyzes gas usage statistics for different blocks and returns a summary.
Args:
gas_stats (Dict[str, int]): A dictio... |
magic_instruct_75k | 36,804 | Write a Python function to process image URLs based on certain conditions. The function should take a list of dictionaries representing categories, each containing a `user_id` and a `picture` property. If the `picture` property is present and not empty, the function should return a list of image URLs formatted as `user... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def processImageURLs(categories: List[Dict[str, str]]) -> List[str]:
"""
Processes a list of categories to generate a list of image URLs based on the `user_id` and `picture` properties.
Args:
... |
magic_instruct_75k | 36,814 | Write a Python function to calculate the total thickness of all layers combined from a given list of layers and their corresponding thicknesses. Each layer is represented by a string, and its thickness is represented by an integer. The function should take two lists as input: one for the layers and one for their thickn... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_total_thickness(layers: List[str], thicknesses: List[int]) -> int:
"""
Calculate the total thickness of all layers combined.
Args:
layers (List[str]): A list of strings represe... |
magic_instruct_75k | 36,817 | Write a Python function to implement a command-line argument parser that handles the `--search`, `--file`, and `--help` options. The parser should throw an `ArgError` if:
- The `--search` option is provided without an argument immediately following it.
- Any option is provided without the required argument.
- An unknow... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
class ArgError(Exception):
pass
def parseArgs(args: List[str]) -> Dict[str, str]:
"""
Parses command-line arguments and returns a dictionary mapping options to their corresponding arguments.
... |
magic_instruct_75k | 36,860 | Write a Python function to generate a configuration file content for a distributed key-value store's cluster setup. The function should take in two parameters: `advertise_client_urls` and `initial_cluster_token`, and return a string representing the content of the configuration file. The configuration file should inclu... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_config_file(advertise_client_urls: str, initial_cluster_token: str) -> str:
"""
Generates the content of a configuration file for a distributed key-value store's cluster setup.
Args:
advertise_client_ur... |
magic_instruct_75k | 36,872 | Write a Python function to parse command-line arguments and set the source and WordPress (WP) directory paths. The function should handle various options and arguments to ensure flexibility and ease of use. The function should support the following options and arguments:
- `-s=<source_path>` or `--source=<source_path>`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def parse_args(args: list) -> Dict[str, str]:
"""
Parse command-line arguments to set the source and WordPress directory paths.
Args:
args (list): A list of strings representing command-line... |
magic_instruct_75k | 36,877 | Write a Python function to generate a formatted report string containing various details about an exception and the environment. The function should take a dictionary `ctx` as input and return a formatted report string. The `ctx` dictionary contains the following keys:
- `exception_type`: A string representing the type... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_exception_report(ctx: dict) -> str:
"""
Generates a formatted report string containing details about an exception and the environment.
Args:
ctx (dict): A dictionary containing exception and environment... |
magic_instruct_75k | 36,890 | Write a Python function to perform specific mathematical operations based on command-line arguments. The function should accept two command-line arguments: a string representing an operation and a number on which the operation will be performed. The supported operations are "square" (to calculate the square of the numb... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
def calculator(operation: str, number: int) -> int:
"""
Perform a specific mathematical operation on a given number based on the operation string.
Args:
operation (str): The operation to perform. Support... |
magic_instruct_75k | 36,930 | Write a Python function to find two distinct expenses from a given list that sum up to a specified value. The function should return the two expenses as a tuple. If no such pair exists, the function should return an empty tuple.
The code should start with:
```python
from typing import List, Tuple
def find_expenses(ex... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_expenses(expenses: List[int], required_sum: int) -> Tuple[int, int]:
"""
Find two distinct expenses from the given list that sum up to the required sum.
Args:
expenses (List[... |
magic_instruct_75k | 36,963 | Write a Python function to extract specific statistics from a given response object. The response object is a dictionary containing various statistics related to a data structure. Your task is to write a function that takes this response object as input and returns a new dictionary containing only the statistics for 'n... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_stats(response: dict) -> dict:
"""
Extracts specific statistics from a given response object.
The function takes a dictionary containing various statistics related to a data structure
and returns a new dicti... |
magic_instruct_75k | 36,965 | Write a Python function to process a list of tuples representing items in a gallery. Each tuple contains an integer representing the item's ID and a string representing the item's image path. The function should return a dictionary where the keys are the item IDs and the values are the corresponding image paths.
The c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def process_gallery(gallery_items: List[Tuple[int, str]]) -> Dict[int, str]:
"""
Processes a list of tuples representing items in a gallery and returns a dictionary.
Each tuple in the l... |
magic_instruct_75k | 37,000 | Write a Python function `get_words` that processes a given piece of text to extract and count the occurrences of each word. The function should take in a string of text and return a dictionary where the keys are the unique words in the text and the values are the counts of each word. Additionally, the function should h... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def get_words(text: str, dedupe: bool = True) -> dict:
"""
Processes a given piece of text to extract and count the occurrences of each word.
Args:
text (str): The input text string containing words separ... |
magic_instruct_75k | 37,009 | Write a Python function to remove leading indentation from a given string based on the provided indentation level, quote character, and indentation character. The function should take the following parameters:
- `text`: A string representing the text to be processed.
- `indent`: An integer representing the desired inde... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_indentation(text: str, indent: int, quote: str, indent_char: str) -> str:
"""
Remove leading indentation from each line of the input text based on the provided parameters.
Args:
text (str): The text to be... |
magic_instruct_75k | 37,042 | Create a Python class `BankAccount` that simulates a simple bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. Additionally, the class should keep track of the total number of transactions (deposits and withdrawals) made on the account. The class should also ens... | Here is the Python code to solve the given problem in the markdown block:
```python
class BankAccount:
"""
A class to simulate a simple bank account.
Attributes:
balance (float): The current balance of the account.
total_transactions (int): The total number of transactions (deposits and wit... |
magic_instruct_75k | 37,043 | Write a Python function to extract and return mining information for a specific test account from a given dictionary of accounts and a client object that provides access to mining-related data. The function should assert the presence of the mining information in the accounts dictionary and return the extracted informat... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_mining_info(accounts: dict, client) -> dict:
"""
Extracts and returns mining information for a specific test account from the given accounts dictionary and client object.
Args:
accounts (dict): A dictionary ... |
magic_instruct_75k | 37,061 | Write a Python function to swap the case of each letter in a given string. The function should return a new string where all uppercase letters are converted to lowercase and all lowercase letters are converted to uppercase. Non-letter characters should remain unchanged.
The code should start with:
```python
def swap_c... | Here is the Python code to solve the given problem in the markdown block:
```python
def swap_case(s: str) -> str:
"""
Swaps the case of each letter in the given string.
Args:
s (str): The input string containing a mix of uppercase and lowercase letters.
Returns:
str: A new string where... |
magic_instruct_75k | 37,075 | Write a Python function to update the configuration dictionary `DCS_CONFIG` based on the `SUBSYSTEM_INSTANCE_ID`. The function should modify the `DATA_CONVERSION_SUBSYSTEM_STATE_FILES_ROOT_FOLDER` key in the dictionary according to the following rules:
- If `SUBSYSTEM_INSTANCE_ID` is 1, remove any occurrences of the wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_config(DCS_CONFIG: dict, SUBSYSTEM_INSTANCE_ID: int) -> dict:
"""
Updates the configuration dictionary based on the SUBSYSTEM_INSTANCE_ID.
Args:
DCS_CONFIG (dict): The configuration dictionary containing ... |
magic_instruct_75k | 37,116 | Write a Python function to calculate the percentage of completed tasks in a given dictionary. The dictionary contains keys representing different tasks and their corresponding boolean values indicating whether the task is completed or not. The function should return the percentage of completed tasks as a float rounded ... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_completion_percentage(tasks: dict) -> float:
"""
Calculate the percentage of completed tasks in a given dictionary.
Args:
tasks (dict): A dictionary where keys are task identifiers and values are boole... |
magic_instruct_75k | 37,119 | Write a Python function to compute the fraction of Republican "nay" (no) votes out of the total votes cast. Each vote is represented as a string, where the first character indicates the party affiliation of the member ('D' for Democrat, 'R' for Republican), and the second character indicates the vote ('Y' for yes, 'N' ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def republican_nay_fraction(votes: List[str]) -> float:
"""
Compute the fraction of Republican "nay" votes out of the total votes cast.
Args:
votes (List[str]): A list of vote strings where ... |
magic_instruct_75k | 37,123 | Write a Python function to process a given list of songs and their details. Each song is represented as a list containing the song name (a string) and its release year (an integer). The function should return a dictionary where the keys are the song names and the values are the corresponding release years. The function... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def create_song_dictionary(songs: List[List[object]]) -> Dict[str, int]:
"""
Creates a dictionary from a list of songs and their release years.
Args:
songs (List[List[object]]): A list... |
magic_instruct_75k | 37,150 | Write a Python function to sort a list of colors according to a predefined order. The predefined order is: "red", "green", "blue", "yellow", "orange", "purple", "black", "white". Any other colors should follow in alphabetical order. The input list may contain duplicate colors, and the output list should maintain the sa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_colors(colors: List[str]) -> List[str]:
"""
Sorts a list of colors according to a predefined order.
The predefined order is: "red", "green", "blue", "yellow", "orange", "purple", "black", "... |
magic_instruct_75k | 37,154 | Write a Python function to parse a list of dependencies and return a dictionary containing the package names as keys and their corresponding versions as values. Each dependency in the list is represented as a string in the format "package_name==version_number" or "package_name~>version_number". The function should hand... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def parse_dependencies(dependencies: List[str]) -> Dict[str, str]:
"""
Parses a list of dependency strings and returns a dictionary with package names as keys and their versions as values.
Arg... |
magic_instruct_75k | 37,164 | Create a Bash script to automate the backup of files and databases for a web application. The script should handle the backup of files without including any upload directories, and it should also include a section for backing up the database.
The script should have the following structure:
1. A section to exclude uplo... | Here is the Python code to solve the given problem in the markdown block:
```bash
#!/bin/bash
# Define paths and filenames
BACKUP_DIR="/path/to/backup"
WEB_DIR="/path/to/web"
UPLOAD_DIR="uploads"
DB_NAME="database_name"
DB_USER="db_user"
DB_PASS="db_password"
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
DB_BACKUP_FILE="$BACKUP_D... |
magic_instruct_75k | 37,178 | Write a Python function to validate a given JSON data against a specified schema. The schema is represented as a Python dictionary, where the keys represent the expected keys in the JSON data, and the values represent the expected data types for those keys. The function should return the validated data if it conforms t... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_json_data(data: dict, schema: dict) -> dict:
"""
Validates the given JSON data against the supplied schema.
Args:
data (dict): A dictionary representing the JSON data to be validated.
schema (di... |
magic_instruct_75k | 37,220 | Implement a simplified version of a text-based Multi-User Dungeon (MUD) game's item management system in Python. Specifically, you need to:
1. Implement the `remItem` method in the `Mud` class, which removes an item from the game world. The method should return `True` if the item is successfully removed and `False` oth... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
from typing import List, Optional
class ModelType(Enum):
Corpse = 1
Weapon = 2
Armor = 3
Potion = 4
class Item:
def __init__(self, name: str, model_type: ModelType):
self.name = name
... |
magic_instruct_75k | 37,238 | Write a Python function to process a list of calendars and a request for events, and return a list of events that are present in the calendars and match the request. Each calendar is represented as a list of events, where each event is a tuple containing the event name and the event start time. The request is represent... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def list_checked(calendars: List[List[Tuple[str, int]]], request: Tuple[str, Tuple[int, int]]) -> List[Tuple[str, int]]:
"""
Process a list of calendars and a request for events, and return a list... |
magic_instruct_75k | 37,268 | Write a Python function to categorize configuration files based on their location within a directory structure. The function should take a list of file paths as input and categorize them into three sets:
1. `outages_config_files`: Set of file paths that are under the directory `infra/config/outages`.
2. `generated_conf... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set, Tuple
def categorize_config_files(file_paths: List[str]) -> Tuple[Set[str], Set[str], Set[str]]:
"""
Categorizes configuration files based on their location within the directory structure.
Arg... |
magic_instruct_75k | 37,285 | Write a Python function `extract_frustum_data` that processes and saves frustum data from a given directory. The function should handle the creation of the save directory if it does not exist and generate training data based on a specified flag. The function should take the following parameters:
- `sunrgbd_dir`: The di... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
from typing import Dict
def extract_frustum_data(sunrgbd_dir: str, save_dir: str, gen_train: bool, additional_params: Dict) -> None:
"""
Extracts frustum data from the SUN RGB-D dataset and saves it to a specified dir... |
magic_instruct_75k | 37,287 | Write a Python function to extract and manipulate tag information from a given list of tags. The function should take a list of tags as input and return a modified list of tags based on the following criteria:
1. Each tag in the input list is of the form "Tag <number>: <tag_name>", where `<number>` is a positive integ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def modify_tags(tag_list: List[str]) -> List[str]:
"""
Extracts and manipulates tag information from a given list of tags.
Each tag in the input list is of the form "Tag <number>: <tag_nam... |
magic_instruct_75k | 37,291 | Write a Python function `generate_deployment_config` that generates a configuration dictionary for a containerized application's deployment. The function should take two parameters:
- `framework` (string): The framework used by the application (can be `None`)
- `app_name` (string): The name of the application
The func... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_deployment_config(framework: str, app_name: str) -> dict:
"""
Generates a configuration dictionary for a containerized application's deployment.
Args:
framework (str): The framework used by the applicat... |
magic_instruct_75k | 37,322 | Write a Python function to distribute prizes among players in a game based on the given rules. The game consists of two teams, and each team has a list of players. The distribution of prizes must adhere to the following rules:
1. No player from team two can receive a prize if there is more than one player with the same... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def distribute_prizes(playersTeamOne: List[str], playersTeamTwo: List[str]) -> List[str]:
"""
Distributes prizes among players in a game based on the given rules.
Args:
playersTeamOne (List[... |
magic_instruct_75k | 37,337 | Write a Python function to process a dictionary containing configuration parameters for a data storage and processing system. The function should extract specific values from the dictionary and perform certain operations based on the extracted data. The function should return a new dictionary containing the extracted v... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def process_config_params(input_dict: Dict[str, any], rt_to_channel: Dict[str, int]) -> Dict[str, any]:
"""
Process the configuration parameters from the input dictionary and return a new dictionary
... |
magic_instruct_75k | 37,368 | Write a Python function to simulate the movement of a cat in a 2D space using a custom `Cat` class. The cat's movement is governed by a set of differential equations, and the simulation is visualized using the Pygame library. The provided code snippet shows a part of the `Cat` class and the main function for initializi... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
class Cat:
def __init__(self, initial_state, obstacles):
self.x = initial_state # State vector [x, y, vx, vy]
self.obstacles = obstacles # List of obstacle positions [(x1, y1), (x2, y2), ...]
... |
magic_instruct_75k | 37,384 | Write a Python function to calculate the sum of all positive integers up to a given input number `n`. The function should correctly handle the summation process and return the correct sum. The code should start with:
```python
def calculate_sum(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_sum(n: int) -> int:
"""
Calculate the sum of all positive integers up to the given input number `n`.
Args:
n (int): The upper limit of the range of integers to sum.
Returns:
int: The sum o... |
magic_instruct_75k | 37,385 | Write a Python function `process_text` that processes a series of commands to manipulate two strings, `origin` and `keyword`. The function should handle the following commands:
1. **Append a word to `origin`**: If `origin` is not empty, append a space followed by the word. If `origin` is empty, append the word directly... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def process_text(commands: List[Tuple[int, str]]) -> Tuple[str, str]:
"""
Processes a series of commands to manipulate two strings, `origin` and `keyword`.
Args:
commands (List[Tuple[... |
magic_instruct_75k | 37,412 | Write a Python function to filter components from a `MIGRATION_MODULES` dictionary based on a specified category. The `MIGRATION_MODULES` dictionary contains keys representing components and values representing corresponding migration module paths. The function should return a new dictionary containing only the compone... | Here is the Python code to solve the given problem in the markdown block:
```python
def filter_migration_modules(migration_modules: dict, category: list) -> dict:
"""
Filters the components in the `MIGRATION_MODULES` dictionary based on a specified category.
Args:
migration_modules (dict): A dictio... |
magic_instruct_75k | 37,421 | Write a Python function to generate a list of numbers within a specified range, with a given step size. The function should take three parameters: `start` (the starting value of the range), `end` (the ending value of the range), and `step` (the step size between consecutive numbers). The function should return a list c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_range(start: int, end: int, step: int) -> List[int]:
"""
Generates a list of numbers within a specified range, with a given step size.
Args:
start (int): The starting value of t... |
magic_instruct_75k | 37,441 | Write a Python function to process a list of image names and tags to generate the full image names and then append them to a list of TensorFlow jobs (tfjobs). The function should take in three parameters: a repository name, a list of image names, and a list of image tags. The full image name is obtained by concatenatin... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_images(repository: str, image_names: List[str], image_tags: List[str]) -> List[str]:
"""
Processes a list of image names and tags to generate the full image names and appends them to a list o... |
magic_instruct_75k | 37,444 | Write a Python function to automate the process of generating a temporary authentication token for a relay gateway. The function should simulate the execution of a specific command to create the token and then extract the token value from the command's output for later use. The function should also ensure that any temp... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_gateway_token(public_host: str, sdm_gateway_listen_app_port: int) -> str:
"""
Generates a temporary authentication token for a relay gateway by simulating the execution of a command.
Args:
public_host (... |
magic_instruct_75k | 37,448 | Write a Python function to automate the process of setting up a loop device and mounting a file to a specific location within a chroot environment. The function should take a file path as an argument, extract the file name and extension, and then mount the file to a predefined location within a chroot environment.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def mount_loopfile(file_path: str) -> None:
"""
Automates the process of setting up a loop device and mounting a file to a specific location within a chroot environment.
Args:
file_path (str): The path to... |
magic_instruct_75k | 37,451 | Write a Python function to solve a linear equation in the form "ax = b" for the variable x. The function should take three parameters: `a`, `b`, and `precision`. The parameter `a` represents the coefficient of x, `b` represents the constant term, and `precision` represents the number of decimal places to round the resu... | Here is the Python code to solve the given problem in the markdown block:
```python
def solve_linear_equation(a: float, b: float, precision: int) -> float:
"""
Solves the linear equation "ax = b" for the variable x and returns the result rounded to the specified precision.
Args:
a (float): The coef... |
magic_instruct_75k | 37,459 | Write a Python function to determine the text color for two labels based on the state of a button. The function should take the state of the button (`isPressedDown`), the `highlightColor`, and the `borderColor` as input and return the text color for the labels based on the provided logic.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def set_text_color(is_pressed_down: bool, highlight_color: str, border_color: str) -> tuple:
"""
Determines the text color for two labels based on the state of a button.
Args:
is_pressed_down (bool): A boolean indic... |
magic_instruct_75k | 37,461 | Write a Python function to categorize a list of household items into different groups based on their first letter. The function should return a dictionary where the keys are the first letters of the items (converted to uppercase) and the values are lists of items starting with that letter. If an item starts with a non-... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def categorize_items(items: List[str]) -> Dict[str, List[str]]:
"""
Categorizes a list of household items into groups based on their first letter.
Args:
items (List[str]): A list of st... |
magic_instruct_75k | 37,462 | Write a Python function to count the number of non-primitive and primitive constants in a given list of Alexa skill constants. The function should return a dictionary with two keys: "non_primitive_count" and "primitive_count", representing the counts of non-primitive and primitive constants, respectively.
Non-primitiv... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
# Simulate the non-primitive constants from the alexa_skills.helpers.Constants module
NON_PRIMITIVE_CONSTANTS = {
"NON_PRIMATIVES",
"is_dialog_complete",
"is_request_type",
"is_intent"
}
d... |
magic_instruct_75k | 37,481 | Write a Python function to calculate the final balance of a specific account after processing a list of transactions. Each transaction is represented as a tuple with the format `(account_id, amount)`, where `account_id` is a string and `amount` is a float. The function should handle cases where the account does not exi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def calculate_balance(transactions: List[Tuple[str, float]], account_id: str) -> float:
"""
Calculate the final balance of a specific account after processing a list of transactions.
Args:
... |
magic_instruct_75k | 37,491 | Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once. The function should take in a list of integers `prices` where `prices[i]` represents the price of a given stock on the `i-th` day. The function should return an integer representing the maximum profi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_profit(prices: List[int]) -> int:
"""
Calculate the maximum profit that can be obtained by buying and selling a stock at most once.
Args:
prices (List[int]): A list of integers where... |
magic_instruct_75k | 37,492 | Write a Python function to calculate the total number of connections (synapses) between two layers of a neural network. The function should take the number of neurons in the first layer and the number of neurons in the second layer as input and return the total number of connections. Each neuron in the first layer is c... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_synapses(first_layer_neurons: int, second_layer_neurons: int) -> int:
"""
Calculate the total number of connections (synapses) between two layers of a neural network.
Args:
first_layer_neurons (int): T... |
magic_instruct_75k | 37,495 | Write a Python function `update_game_state(state: List[int], button_presses: List[int]) -> List[int]` that updates the game state based on the given button presses. The game state is represented by a list of integers, and the button presses are also represented as a list of integers. The function should return the upda... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def update_game_state(state: List[int], button_presses: List[int]) -> List[int]:
"""
Updates the game state by retaining the first 7 elements of the original state and appending the button presses.
... |
magic_instruct_75k | 37,502 | Write a Python function to manage and validate server configurations for a web application. The function should be able to initialize, validate, update, and retrieve server configurations. The server configuration is represented as a dictionary with specific keys and values.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def server_config_manager(initial_config: Dict[str, Any]) -> Dict[str, Any]:
"""
Manages and validates server configurations for a web application.
Args:
initial_config (Dict[str, Any])... |
magic_instruct_75k | 37,510 | Write a Python function to determine if a given string containing parentheses, brackets, and curly braces is valid. The string is valid if all the parentheses, brackets, and curly braces are properly nested and closed.
The function should start with:
```python
def isValidParentheses(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def isValidParentheses(s: str) -> bool:
"""
Determines if the given string containing parentheses, brackets, and curly braces is valid.
A string is considered valid if all the parentheses, brackets, and curly braces are pro... |
magic_instruct_75k | 37,535 | Write a Python function to count the occurrences of each unique ISTAT code in a given list of ISTAT codes. The ISTAT code is a unique identifier for each municipality in Italy and follows the format "istat_codes.province_name". The function should return a dictionary where the keys are the unique ISTAT codes and the va... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_istat_codes(codes: List[str]) -> Dict[str, int]:
"""
Counts the occurrences of each unique ISTAT code in the given list.
Args:
codes (List[str]): A list of ISTAT codes where ... |
magic_instruct_75k | 37,537 | Write a Python function to identify and return the test cases imported from `test_empty_build` that have the `# NOQA` comment at the end. The function should take a list of imported test cases as input and return a list of test cases that meet the criteria. The `# NOQA` comment is always at the end of the line for the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_test_cases_with_noqa(imported_test_cases: List[str]) -> List[str]:
"""
Identify and return the test cases imported from `test_empty_build` that have the `# NOQA` comment at the end.
Args:
... |
magic_instruct_75k | 37,570 | Write a Python function to perform a specific image processing operation on three grayscale images represented as 2D arrays of floating-point values. The function should subtract the second image from the first image and then add the third image to the result. The resulting image should have its pixel intensities clipp... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
from typing import List
def image_processing(im_man: List[List[float]], im_j: List[List[float]], im_t: List[List[float]]) -> List[List[float]]:
"""
Perform a specific image processing operation on three grays... |
magic_instruct_75k | 37,572 | Write a Python function to count the number of users associated with each organization, excluding those organizations that are associated with a specific registrar. The function should take a registrar name and a list of organizations as input, where each organization is represented as a dictionary with 'name' and 'use... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_users_per_organization(registrar_name: str, organizations: List[Dict[str, any]]) -> Dict[str, int]:
"""
Count the number of users associated with each organization, excluding those associ... |
magic_instruct_75k | 37,606 | Write a Python function to count the occurrences of a specific phrase within a given text. The search should be case-insensitive, and the function should handle various edge cases, such as empty input strings and phrases. The function should return the count of occurrences of the phrase within the text.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_phrase_occurrences(text: str, phrase: str) -> int:
"""
Counts the occurrences of a specific phrase within a given text.
The search is case-insensitive, and the function handles various edge cases,
such as empt... |
magic_instruct_75k | 37,612 | Write a Python function to filter a list of attributes and return only those related to the HVAC dampers. The function should take a list of strings as input and return a filtered list containing only the attributes that are related to the HVAC dampers. The attributes related to HVAC dampers are defined by the constant... | Here is the Python code to solve the given problem in the markdown block:
```python
def filter_hvac_attributes(attributes: list) -> list:
"""
Filters a list of attributes and returns only those related to HVAC dampers.
Args:
attributes (list): A list of strings representing various attributes.
... |
magic_instruct_75k | 37,615 | Create a Python function to implement a dynamic array (also known as a list) that can grow in size as elements are added to it. The dynamic array should support the following operations:
1. `__init__(initial_capacity: int)`: Initializes the dynamic array with the specified initial capacity.
2. `get(index: int) -> Any`:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any
class DynamicArray:
def __init__(self, initial_capacity: int):
"""
Initializes the dynamic array with the specified initial capacity.
Args:
initial_capacity (int): The ini... |
magic_instruct_75k | 37,620 | Write a Python function to simulate the behavior of the shell script `file_checker.sh` that checks for the existence of a specific file and sources it if it exists. The function should handle both cases where the file exists and where it does not exist.
The code should start with:
```python
import os
def check_and_so... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def check_and_source_file(file_path: str) -> None:
"""
Simulates checking for the existence of a specific file and sourcing it if it exists.
Args:
file_path (str): The path to the file to be checked and s... |
magic_instruct_75k | 37,634 | Write a Python function to prepare two dictionaries from the given training data. The first dictionary should map IDs to labels, and the second dictionary should map IDs to numerical values. The function should take in the training data and return the two dictionaries.
The training data consists of the following compo... | Here is the Python code to solve the given problem in the markdown block:
```python
def prepare_id_dicts(ID_train, X_num_tr, X_img_tr, y_tr):
"""
Prepare two dictionaries from the given training data.
Args:
ID_train (list): A list of IDs for the training data.
X_num_tr (dict): A dictionary ... |
magic_instruct_75k | 37,639 | Write a Python function to filter out palindromic strings from a given list of strings. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. The function should return a new list containing only the string... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def find_palindromes(input_list: List[str]) -> List[str]:
"""
Filters out palindromic strings from a given list of strings.
Args:
input_list (List[str]): A list of strings to be ch... |
magic_instruct_75k | 37,652 | Write a Python function to find the highest score achieved in a game given a list of integers representing the scores. If the list is empty, the function should return 0. The function should be efficient and handle edge cases appropriately.
The code should start with:
```python
from typing import List
def highest_sco... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def highest_score(scores: List[int]) -> int:
"""
Returns the highest score achieved in the game from a list of scores.
Args:
scores (List[int]): A list of integers representing the scores of... |
magic_instruct_75k | 37,655 | Write a Python function `ArrayAdditionI` that determines whether any combination of the numbers in a given array of positive integers can be added together to produce the largest number in the array. The function should return `True` if such a combination exists, and `False` otherwise.
The function signature is:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def ArrayAdditionI(arr: List[int]) -> bool:
"""
Determines whether any combination of the numbers in the given array can sum up to the largest number in the array.
Args:
arr (List[int]): The... |
magic_instruct_75k | 37,672 | Write a Python function to filter a list of numbers based on the criteria that only numbers greater than or equal to 12 should be included in the output list. The function should maintain the original order of elements from the input list and should not use any built-in filtering functions (e.g., `filter`, list compreh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_filter_types(numbers: List[int]) -> List[int]:
"""
Filters a list of numbers to include only those that are greater than or equal to 12.
Args:
numbers (List[int]): The list of number... |
magic_instruct_75k | 37,686 | Write a Python function to determine if all daemons in a distributed system are healthy based on their heartbeat signals. Each daemon sends a heartbeat signal at regular intervals, and the health check system must verify that these heartbeats are being received within an acceptable tolerance.
The function should take ... | Here is the Python code to solve the given problem in the markdown block:
```python
def all_daemons_healthy(instance, heartbeat_tolerance_seconds):
"""
Determines if all daemons in a distributed system are healthy based on their heartbeat signals.
Args:
instance: An instance of the `DagsterInstance... |
magic_instruct_75k | 37,687 | Write a Python function `generate_full_prefixes` that takes in three parameters: `prefix`, `releases_prefix`, and `articles_prefix`. The function should return a dictionary containing the full prefixes for both the "releases" and "articles" categories. The full prefix for each category is formed by combining the common... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_full_prefixes(prefix: str, releases_prefix: str, articles_prefix: str) -> dict:
"""
Generates full prefixes for the "releases" and "articles" categories by combining
the common prefix with the respective categor... |
magic_instruct_75k | 37,710 | Write a Python function to modify a given list of integers based on specific rules. The function should take in a list of integers and return a new list with the following modifications:
1. If the integer is even, it should be divided by 2.
2. If the integer is odd, it should be multiplied by 3 and increased by 1.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def modify_list(input_list: List[int]) -> List[int]:
"""
Modifies a given list of integers based on specific rules.
Args:
input_list (List[int]): The list of integers to be modified.
Re... |
magic_instruct_75k | 37,720 | Write a Python function to analyze the CPU usage of threads in a Logstash application. The function should identify the top 3 hot threads based on their CPU usage and calculate the total sum of their CPU time. The output should include the CPU percentage and state of each top hot thread, as well as the total CPU usage ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple
def analyze_cpu_threads(cpu_data: Dict[str, Tuple[int, str]]) -> Dict[str, List[Dict[str, str]]]:
"""
Analyzes the CPU usage of threads in a Logstash application and identifies the top 3 hot... |
magic_instruct_75k | 37,739 | Write a Python function to determine the final value of a variable `num` after executing a series of assignments given as a list of strings. Each string in the list represents an assignment to `num` in the format "num = x", where `x` is an integer. The assignments are provided in sequential order, and the function shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def final_value_of_num(assignments: List[str]) -> int:
"""
Calculate the final value of the variable `num` after executing a series of assignments.
Args:
assignments (List[str]): A list of s... |
magic_instruct_75k | 37,768 | Write a Python function to generate a deployment script for Redis based on the given requirements. The script should perform the following actions:
1. Change the directory to `/usr/local/`.
2. Execute a download script specified by the `download_script` variable.
3. Remove any existing `redis` executable.
4. Create a s... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_redis_deployment_script(download_script: str, dir_name: str) -> str:
"""
Generates a deployment script for Redis based on the given requirements.
Args:
download_script (str): A string representing the c... |
magic_instruct_75k | 37,787 | Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock at most once, given a list of integers representing the daily stock prices. If it is not possible to make any profit, the function should return 0.
The 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 maxProfit(prices: List[int]) -> int:
"""
Calculate the maximum profit that can be obtained by buying and selling a stock at most once.
Args:
prices (List[int]): A list of integers repres... |
magic_instruct_75k | 37,823 | Write a Python function to process a list of classifiers and extract specific information from them. Each classifier is represented as a string in the format `'Category :: Value'`. The function should return a dictionary containing the count of unique categories and the unique values associated with each category.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def process_classifiers(classifiers: List[str]) -> Dict[str, Union[int, Dict[str, List[str]]]]:
"""
Processes a list of classifiers and returns a dictionary containing the count of unique ca... |
magic_instruct_75k | 37,832 | Write a Python function to calculate the total number of elements in a multi-dimensional array. The function should be able to handle arrays of different dimensions, including 1D, 2D, and 3D arrays. The function should take the array as input and return the total number of elements present in the array, considering all... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_total_elements(arr: Union[List[int], List[List[int]], List[List[List[int]]]]) -> int:
"""
Calculate the total number of elements in a multi-dimensional array.
Args:
arr:... |
magic_instruct_75k | 37,836 | Write a Python function to identify and return the indices of degenerate bounding boxes in a list of bounding box coordinates. A degenerate box is defined as a box with zero area, i.e., a box where the width or height is zero. The function should take a list of bounding box coordinates as input and return a list of ind... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def check_degenerate_boxes(bounding_boxes: List[Tuple[int, int, int, int]]) -> List[int]:
"""
Identify and return the indices of degenerate bounding boxes in a list of bounding box coordinates.
... |
magic_instruct_75k | 37,852 | Write a Python function to analyze and manipulate HTML code by identifying the number of closing HTML tags (`</div>`) in a given HTML snippet and determining if the tags are properly balanced. A properly balanced HTML snippet has an equal number of opening and closing tags, and the closing tags are in the correct order... | Here is the Python code to solve the given problem in the markdown block:
```python
def checkHTMLBalance(htmlSnippet: str) -> bool:
"""
Analyzes and manipulates HTML code to determine if the HTML tags are properly balanced.
Args:
htmlSnippet (str): The HTML snippet to be analyzed.
Returns:
... |
magic_instruct_75k | 37,867 | Write a Python function to manage parameters in a software system. The function should handle the creation, setting, and getting of parameter values. Each parameter has a name, type, and value. The type is represented as an unsigned 32-bit integer, and the value is a floating-point number. The function should provide m... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_param(name: str, type: int, value: float) -> dict:
"""
Create a parameter with the given name, type, and value.
Args:
name (str): The name of the parameter.
type (int): The type of the parameter, ... |
magic_instruct_75k | 37,938 | Write a Python function to calculate the total score based on the outcome of rolling a set of six-sided dice. The scoring system is as follows:
- Each 1 rolled scores 100 points.
- Each 6 rolled scores 60 points.
- Each 5 rolled scores 50 points.
- Each 4 rolled scores 40 points.
- Each 3 rolled scores 30 points.
- Eac... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_score(dice_values: List[int]) -> int:
"""
Calculate the total score based on the values of rolled six-sided dice.
The scoring system is as follows:
- Each 1 rolled scores 100 point... |
magic_instruct_75k | 37,944 | Write a Python function to generate the command for processing MRI data using FreeSurfer's `recon-all` command. The function should take the following parameters:
- `subject_name`: A string representing the name of the subject for whom the MRI data is being processed.
- `home_mount`: A string representing the home moun... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_recon_command(subject_name: str, home_mount: str, main_user: str) -> str:
"""
Generates the command for processing MRI data using FreeSurfer's `recon-all` command.
Args:
subject_name (str): The name of ... |
magic_instruct_75k | 37,960 | Write a Python function to generate DNS zone update commands for a DNS server. The function should take the DNS server address, server port, forward zone, and reverse zone as input parameters. The function should return a string containing the DNS update commands in a specific format. The record type and record data fo... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_dns_update_commands(dns_server: str, server_port: int, forward_zone: str, reverse_zone: str) -> str:
"""
Generates DNS zone update commands for a DNS server.
Args:
dns_server (str): The DNS server addre... |
magic_instruct_75k | 38,000 | Write a Python function to convert a list of integers into a string representation of the list in reverse order. The function should reverse the list and then convert each element to a string before joining them together into a single string. The function signature is:
```python
from typing import List
def reverse_lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list_to_string(input_list: List[int]) -> str:
"""
Converts a list of integers into a string representation of the list in reverse order.
Args:
input_list (List[int]): The list of... |
magic_instruct_75k | 38,041 | Create a Python function to simulate the behavior of a modal component in a web application. The modal component should be able to display various types of content, such as text, images, forms, or custom components, and provide the ability to close the modal when the user interacts with it. The function should allow fo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def modal_component(content: Any, style: Dict[str, str], close_event: str) -> None:
"""
Simulates a modal component in a web application.
Args:
content (Any): The content to be displaye... |
magic_instruct_75k | 38,066 | Write a Python function to remove duplicate elements from a list while preserving the original order of the elements. The function should not use any built-in Python functions that directly solve this problem, such as `set()` or `dict.fromkeys()`.
The code should start with:
```python
from typing import List
def remo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(params: List[str]) -> List[str]:
"""
Removes duplicate elements from a list while preserving the original order.
Args:
params (List[str]): The list of strings from whic... |
magic_instruct_75k | 38,073 | Write a Python function to find the minimum element in a rotated sorted array. The array is a rotated version of a sorted array, meaning it was originally sorted in ascending order and then rotated by some number of positions. The function should efficiently find the minimum element using a binary search approach.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_minimum_in_rotated_array(rotated: List[int]) -> int:
"""
Find the minimum element in a rotated sorted array.
Args:
rotated (List[int]): A list of integers representing a rotated sor... |
magic_instruct_75k | 38,101 | Write a Python function to manage the power state of a system based on certain conditions. The function should simulate the interaction with D-Bus interfaces to query and set the power state of the system. The function should perform the following tasks:
1. Query the current power state of the system.
2. If the current... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def manage_power_state(current_state: str, activation_status: bool) -> Dict[str, Any]:
"""
Manages the power state of a system based on certain conditions.
Args:
current_state (str): Th... |
magic_instruct_75k | 38,111 | Write a Python function to categorize a list of student scores into grade levels based on predefined criteria. The function should return a list of grade levels corresponding to each score. If a score is outside the range of 0-100, the function should categorize it as "Invalid score!".
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def categorize_scores(scores: List[int]) -> List[str]:
"""
Categorizes a list of student scores into grade levels based on predefined criteria.
Args:
scores (List[int]): A list of integers r... |
magic_instruct_75k | 38,122 | Write a Python function to generate HTML code for displaying event shirt and medal images based on the provided event details. The function should accept a dictionary containing the filenames of the event shirt and medal images and return a string containing the HTML code. The HTML code should follow a specific structu... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_image_html(event_details: dict) -> str:
"""
Generates HTML code for displaying event shirt and medal images based on the provided event details.
Args:
event_details (dict): A dictionary containing the f... |
magic_instruct_75k | 38,148 | Write a Python function to find the closest symbol to a given position in a text editor. The function should take a list of tuples, where each tuple contains a region (represented as a pair of integers) and a symbol (a string). The region represents the start and end positions of the symbol in the text editor. The goal... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_closest_symbol(symbols: List[Tuple[Tuple[int, int], str]], position: int) -> str:
"""
Finds the closest symbol to a given position in a text editor.
Args:
symbols (List[Tuple... |
magic_instruct_75k | 38,161 | Write a Python function called `process_config_and_parse` that processes a configuration dictionary `conf` and an encoding string `ENCODING`. The function should create an `Objectify` object using the `conf` dictionary, and then call the `async_parser` function with `None` as the first argument, the created `Objectify`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, Dict
def process_config_and_parse(conf: Dict[str, Any], ENCODING: str) -> Any:
"""
Processes a configuration dictionary and performs asynchronous parsing on an empty stream.
Args:
conf (Dict... |
magic_instruct_75k | 38,187 | Write a Python function to remove all files with the ".png" extension from a given list of file names. The function should return the modified list after removing all files with the ".png" extension. If the list is empty or does not contain any files with the ".png" extension, the function should return the original li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_png_files(file_list: List[str]) -> List[str]:
"""
Removes all files with the ".png" extension from the given list of file names.
Args:
file_list (List[str]): A list of file names.... |
magic_instruct_75k | 38,195 | Write a Python function to generate a tag cloud from a list of items. Each item is represented as a dictionary with a 'tags' key containing a comma-separated string of tags. The function should return a dictionary where each key is a unique tag and the corresponding value is the frequency of that tag across all items.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_tag_cloud(items: List[Dict[str, str]]) -> Dict[str, int]:
"""
Generates a tag cloud from a list of items, where each item is a dictionary containing a 'tags' key with a comma-separated... |
magic_instruct_75k | 38,218 | Write a Python function to generate a Docker build command based on the provided repository name and Docker image tag. The function should follow the format:
```
docker build -t <tag> <repository>
```
Where `<tag>` is the tag for the Docker image and `<repository>` is the name of the repository. The function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_docker_build_command(repository: str, tag: str) -> str:
"""
Generates a Docker build command based on the provided repository name and Docker image tag.
Args:
repository (str): The name of the repositor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.