source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_instruct_75k | 47,534 | Write a Python function to calculate the total number of announcements for each node from a list of node announcements. Each announcement is represented as a dictionary with the keys `'node_id'` (a unique identifier for the node) and `'announcement_count'` (the number of announcements for the node). The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def calculate_total_announcements(announcements: List[Dict[str, Union[str, int]]]) -> Dict[str, int]:
"""
Calculate the total number of announcements for each node from a list of node announ... |
magic_instruct_75k | 47,544 | Write a Python function to remove duplicate strings from a given list of strings. The function should return a new list containing only the unique strings, maintaining the order of their first appearance in the input list.
The code should start with:
```python
from typing import List
def remove_duplicates(input_list:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(input_list: List[str]) -> List[str]:
"""
Removes duplicate strings from the input list while maintaining the order of their first appearance.
Args:
input_list (List[str... |
magic_instruct_75k | 47,600 | Write a Python function to calculate the cumulative sum of a given list of integers. The cumulative sum at each index of the output list should be the sum of all the integers from the input list up to that index. The function should start with:
```python
from typing import List
def cumulative_sum(input_list: List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_sum(input_list: List[int]) -> List[int]:
"""
Calculate the cumulative sum of a given list of integers.
Args:
input_list (List[int]): The list of integers for which to calculat... |
magic_instruct_75k | 47,607 | Write a Python function to process and modify a given content string based on specific rules. The function should remove the first word if it is "-t" and the subsequent word if it is a legal table name ("filter", "nat", "raw", or "mangle"). The function should return the modified content string.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_content(content: str) -> str:
"""
Process the given content string by removing the first word if it is "-t" and the subsequent word if it is a legal table name.
Args:
content (str): The content string to... |
magic_instruct_75k | 47,625 | Write a Python function to determine the file system type based on an input value. The function should take a single argument and use a helper function to determine a post-padding word based on the input. Depending on the post-padding word, the function should return a corresponding file system type.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_post_padding_word(input_value: int) -> str:
"""
Determine the post-padding word based on the input value.
Args:
input_value (int): The input value to determine the post-padding word.
Returns:
st... |
magic_instruct_75k | 47,628 | Write a Python function to validate whether a given string is a valid variable name according to the specified rules. The function should return `True` if the input string is a valid variable name, and `False` otherwise. The rules for a valid variable name are:
1. It must start with a letter (a-z, A-Z) or an underscore... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def isValidVariableName(name: str) -> bool:
"""
Validate whether the given string is a valid variable name according to the specified rules.
Args:
name (str): The string to be validated as a variable name... |
magic_instruct_75k | 47,641 | Write a Python function `process_sensor_config(config_dict)` that processes a configuration dictionary for sensor data. The dictionary contains sensor configurations for various parameters. The function should extract and process specific information from it and return a list of tuples. Each tuple should contain the se... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Tuple, Any
def process_sensor_config(config_dict: Dict[str, Dict[str, Any]]) -> List[Tuple[str, Any, Any, Any]]:
"""
Processes a configuration dictionary for sensor data and returns a list of tupl... |
magic_instruct_75k | 47,682 | Write a Python function to convert a given string into "weird case" format. In this format, every even-indexed character in each word is converted to uppercase, while every odd-indexed character is converted to lowercase. The function should return the modified string with the words separated by spaces.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def to_weird_case(string: str) -> str:
"""
Converts a given string into "weird case" format. In this format, every even-indexed character in each word is converted to uppercase,
while every odd-indexed character is converted... |
magic_instruct_75k | 47,685 | Write a Python function to construct the complete path to a subdirectory named `jvs_ver1` within a given base directory `storage_dir`. The function should handle different types of input paths, including relative and absolute paths, and ensure that the resulting path is correctly formatted.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from os.path import join, normpath
def create_jvs_dir(storage_dir: str) -> str:
"""
Constructs the complete path to the subdirectory 'jvs_ver1' within the given base directory.
Args:
storage_dir (str): The base dir... |
magic_instruct_75k | 47,692 | Write a Python function to convert a given color in hexadecimal format to its corresponding RGB (Red, Green, Blue) values. The input will be a string representing the color in the format "#RRGGBB", where RR, GG, and BB are two-digit hexadecimal numbers representing the intensity of red, green, and blue, respectively. Y... | Here is the Python code to solve the given problem in the markdown block:
```python
def hex_to_rgb(color: str) -> str:
"""
Converts a hexadecimal color code to its corresponding RGB values.
Args:
color (str): A string representing the color in the format "#RRGGBB".
Returns:
str: A stri... |
magic_instruct_75k | 47,695 | Write a Python function to generate a command-line command for compiling a project using the `mycocos` tool based on given parameters. The function should take the following parameters:
- `platform` (string): The target platform for compilation, e.g., "linux", "windows", "mac".
- `project_name` (string): The name of th... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_compile_command(platform: str, project_name: str, build_mode: str, num_threads: int, compile_script: bool) -> str:
"""
Generates a command-line command for compiling a project using the `mycocos` tool.
Args:
... |
magic_instruct_75k | 47,710 | Write a Python function to filter and sort book sequences based on a given book ID. Each book sequence is represented by a tuple containing the book ID and the sequence number. The function should filter the sequences based on the given book ID and then sort them in ascending order based on their sequence numbers.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def filter_and_sort_sequences(book_id: int, sequences: List[Tuple[int, int]]) -> List[int]:
"""
Filters and sorts the book sequences based on the given book ID.
Args:
book_id (int): T... |
magic_instruct_75k | 47,730 | Write a Python function to process command-line arguments for a backup utility script. The script should handle options for setting the Jenkins home directory and specifying a destination backup file. The function should support the following options:
1. `-j|--jenkins-home <directory>`: Set the Jenkins home directory t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_backup_args(args: List[str]) -> Dict[str, str]:
"""
Process command-line arguments for a backup utility script.
The script supports the following options:
1. `-j|--jenkins-home... |
magic_instruct_75k | 47,738 | Write a Python function `categorize_modules(module_names: List[str]) -> Dict[str, List[str]]` that takes a list of module names as input and returns a dictionary where the keys are the source directories and the values are lists of module names belonging to each source. Each module name is represented as a string and m... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def categorize_modules(module_names: List[str]) -> Dict[str, List[str]]:
"""
Categorizes a list of module names into their respective source directories.
Args:
module_names (List[str])... |
magic_instruct_75k | 47,748 | Write a Python function to extract all numeric substrings from a given string and return the sum of these numeric values. The input string contains a mix of alphabetic characters and digits. The function should start with:
```python
def sum_numeric_substrings(ts: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_numeric_substrings(ts: str) -> int:
"""
Extracts all numeric substrings from the input string and returns the sum of these numeric values.
Args:
ts (str): The input string containing a mix of alphabetic char... |
magic_instruct_75k | 47,768 | Write a Python function `process_lines(lines: List[str]) -> Dict[int, int]` that processes a list of strings representing lines of data. Each non-empty line contains two space-separated elements: an address (in hexadecimal format) and a value (in hexadecimal or decimal format). The function should return a dictionary w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def process_lines(lines: List[str]) -> Dict[int, int]:
"""
Processes a list of strings representing lines of data. Each non-empty line contains two space-separated elements:
an address (in hexa... |
magic_instruct_75k | 47,771 | Write a Python function to rename a list of file names according to specific rules. Each file name consists of a base name and an extension, separated by a period. The renaming rules are as follows:
1. If the base name contains the substring "spam", it should be replaced with "eggs".
2. If the extension is "txt", it sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rename_files(file_names: List[str]) -> List[str]:
"""
Renames a list of file names according to specific rules.
The rules are:
1. If the base name contains the substring "spam", it should be... |
magic_instruct_75k | 47,772 | Write a Python function to simulate a TCP status tracking system that can store and update the status of TCP connections. The system should support the following functionalities:
1. Initialize the TCP status of a connection to `TCP_FIRSTSEEN`.
2. Update the TCP status of a connection to `TCP_DROP`.
3. Retrieve the curr... | Here is the Python code to solve the given problem in the markdown block:
```python
from enum import Enum
from typing import Dict, Optional
class TcpStatus(Enum):
TCP_FIRSTSEEN = 1
TCP_DROP = 2
class TCPStatusTracker:
def __init__(self):
"""
Initialize the TCP status tracker with an empty ... |
magic_instruct_75k | 47,782 | Create a Python function that implements a caching mechanism for asynchronous function calls using a decorator. The decorator should wrap asynchronous functions and cache their results to improve performance. The function should check if the result of calling the wrapped function with the given arguments and keyword ar... | Here is the Python code to solve the given problem in the markdown block:
```python
import functools
# Define the cache as a global dictionary
cache2 = {}
async def call_or_get_from_cache(cache, func, *args, **kwargs):
"""
Asynchronously calls the wrapped function or retrieves the result from the cache.
... |
magic_instruct_75k | 47,797 | Write a Python function to extract the username and repository name from a given GitHub repository URL. The URL follows the format `https://github.com/<username>/<reponame>`. The function should return a tuple containing the username and repository name.
The code should start with:
```python
from typing import Tuple
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def extract_repo_info(url: str) -> Tuple[str, str]:
"""
Extracts the username and repository name from a given GitHub repository URL.
Args:
url (str): The GitHub repository URL in the forma... |
magic_instruct_75k | 47,802 | Write a Python function to validate file paths based on specific criteria. The function should take a file path as input and return `True` if the path meets the specified criteria, and `False` otherwise.
The criteria for a valid file path are as follows:
1. The file path must not be empty.
2. The file path must not ex... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_file_path(file_path: str) -> bool:
"""
Validates a file path based on the following criteria:
1. The file path must not be empty.
2. The file path must not exceed 2048 characters in length.
3.... |
magic_instruct_75k | 47,844 | Write a Python function to verify the integrity of a package using its SHA256 hash. The function should compare the expected hash, which is stored in a specific format, with the actual hash of the package file. The expected hash is provided in the format `TERMUX_PKG_SHA256=<hash_value>`, where `<hash_value>` is the act... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def verify_sha256(expected_hash: str, actual_hash: str) -> bool:
"""
Verifies the integrity of a package by comparing the expected SHA256 hash with the actual hash.
Args:
expected_hash (str): A string rep... |
magic_instruct_75k | 47,861 | Write a Python function to extract and categorize software license information from a list of code lines. Each line of code may contain an SPDX License Identifier comment, which follows the format "SPDX-License-Identifier: <license_identifier>". The function should return a dictionary where the keys are the license ide... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def extract_license_info(code_lines: List[str]) -> Dict[str, str]:
"""
Extracts and categorizes software license information from a list of code lines.
Args:
code_lines (List[str]): A ... |
magic_instruct_75k | 47,862 | Write a Python function to extract license information from a given file content string. The function should return a dictionary containing the license type and the URL for obtaining the full license text. The license information is specified in a specific format within the file content.
The format of the license info... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def extract_license_info(file_content: str) -> dict:
"""
Extracts the license type and the URL for obtaining the full license text from a given file content string.
Args:
file_content (str): A string repr... |
magic_instruct_75k | 47,868 | Write a Python function to transpose a given 2D matrix. Transposing a matrix involves converting its rows into columns and vice versa. The function should handle matrices of different dimensions and return the transposed matrix correctly.
The code should start with:
```python
from typing import List
def transpose_mat... | 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]]:
"""
Transposes the given 2D matrix.
Args:
matrix (List[List[int]]): The original 2D matrix to be transposed.
Returns:
... |
magic_instruct_75k | 47,869 | Write a Python function `process_transaction_data(data: dict) -> dict` that processes a dictionary containing financial transaction data. The function should extract specific information from the dictionary and perform some calculations based on the extracted data.
The input dictionary `data` will always contain the f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def process_transaction_data(data: Dict[str, any]) -> Dict[str, any]:
"""
Processes a dictionary containing financial transaction data and returns a new dictionary
with extracted details and ca... |
magic_instruct_75k | 47,894 | Write a Python function `extract_package_info(metadata)` that takes a dictionary containing metadata about a Python package as input and returns a formatted string containing specific information about the package. The formatted string should include the package name, author, author email, version, and license, each on... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_package_info(metadata: dict) -> str:
"""
Extracts and formats specific information from a metadata dictionary about a Python package.
Args:
metadata (dict): A dictionary containing metadata about a Pytho... |
magic_instruct_75k | 47,907 | Write a Python function to process a series of commands to manipulate a list of integers. The commands include adding, removing, and finding elements in the list. The function should handle these commands efficiently and return the final state of the list after processing all commands.
The commands are as follows:
- "... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_commands(commands: List[str]) -> List[int]:
"""
Process a series of commands to manipulate a list of integers.
Args:
commands (List[str]): A list of commands to process. Each com... |
magic_instruct_75k | 47,910 | Write a Python function to process an indication message received from a network device and extract relevant information about a traffic management queue. The function should populate a dictionary with the extracted information. The indication message contains the following fields: `queue_id`, `queue_type`, and `queue_... | Here is the Python code to solve the given problem in the markdown block:
```python
def process_tm_queue_indication(indication) -> dict:
"""
Processes an indication message received from a network device and extracts relevant information about a traffic management queue.
Args:
indication: An object... |
magic_instruct_75k | 47,930 | Write a Python function to simulate a simplified version of a callback handling system for a parent-child relationship. The system should manage callbacks and drain sequences. Specifically, implement the following:
1. A `Child` class with a method `add_on_drain_close_cb` that registers a callback to be executed when th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Callable, List
class Child:
def __init__(self):
self.callbacks: List[Callable[[], None]] = []
def add_on_drain_close_cb(self, callback: Callable[[], None]) -> None:
"""
Register a cal... |
magic_instruct_75k | 47,934 | Write a Python script to automate the process of generating customized ISO files for different models of ultra-mobile personal computers (UMPCs). The script should take an input ISO file and the UMPC model as parameters, and then create a new ISO file with the UMPC model appended to its name. If the output ISO file alr... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import subprocess
def generate_custom_iso(input_iso: str, umpc_model: str) -> None:
"""
Automates the process of generating a customized ISO file for a specific UMPC model.
Args:
input_iso (str): The path... |
magic_instruct_75k | 47,949 | Write a Python function to calculate the total cost of a customer's order at a coffee shop. The function should take a list of drink names as input and return the total cost of the order. If a drink is not available at the coffee shop, it should be ignored in the calculation. The coffee shop offers the following drinks... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_order_cost(drinks: List[str]) -> float:
"""
Calculate the total cost of a customer's order at a coffee shop.
Args:
drinks (List[str]): A list of strings representing the names ... |
magic_instruct_75k | 47,987 | Write a Python function `filter_data` that takes a list of dictionaries representing rows from a Google Sheet and a status string as input. The function should return a list of names from the rows that match the given status, ignoring case differences.
The function should start with:
```python
from typing import List,... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def filter_data(sheet_data: List[Dict[str, Any]], status: str) -> List[str]:
"""
Filters the names from the rows in the Google Sheet data that match the given status, ignoring case differences... |
magic_instruct_75k | 48,002 | Write a Python function to find the intersection of multiple arrays, where each array contains a sequence of integers. The function should return a list of unique elements that are present in all arrays.
The code should start with:
```python
from typing import List
def find_intersection(arrays: List[List[int]]) -> Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection(arrays: List[List[int]]) -> List[int]:
"""
Finds the intersection of multiple arrays, i.e., the set of elements that are present in all arrays.
Args:
arrays (List[List[... |
magic_instruct_75k | 48,035 | Write a Python function to count the number of unique catalog file paths from a given list of catalog file paths. Each catalog file path is represented as a string in the format `../catalogs_a/catalog_3.py`, where `../catalogs_a/` is the base directory and `catalog_3.py` is the Python file representing the catalog. The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_catalogs(catalog_paths: List[str]) -> int:
"""
Counts the number of unique catalog file paths from a given list of catalog file paths.
Args:
catalog_paths (List[str]): A list of ca... |
magic_instruct_75k | 48,036 | Write a Python function to calculate the average score from a list of integers representing the scores of a game. The function should return the average score rounded to the nearest integer.
The code should start with:
```python
from typing import List
def calculate_average_score(scores: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_average_score(scores: List[int]) -> int:
"""
Calculate the average score from a list of integers representing the scores of a game.
The average score is rounded to the nearest integer.
... |
magic_instruct_75k | 48,040 | Write a Python function to print all odd numbers between a given range `[start, end]`. The function should take two integer parameters, `start` and `end`, and print each odd number in the range. Ensure that the function handles edge cases such as when `start` is greater than `end` or when the range does not contain any... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_odd_numbers(start: int, end: int) -> None:
"""
Prints all odd numbers between the given range [start, end].
Args:
start (int): The starting number of the range (inclusive).
end (int): The ending nu... |
magic_instruct_75k | 48,043 | Write a Python function to compare two NumPy arrays of type `float32` and return `1` if they are equal and `0` otherwise. The function should handle the comparison correctly, ensuring that the data types and comparison logic are appropriate. The code should start with:
```python
import numpy as np
def compare_arrays(r... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def compare_arrays(rs1: np.ndarray, rs2: np.ndarray) -> int:
"""
Compare two NumPy arrays of type float32 and return 1 if they are equal, otherwise return 0.
Args:
rs1 (np.ndarray): The first Num... |
magic_instruct_75k | 48,048 | Write a Python function to detect if a system is in a safe state or not, given the current allocation of resources to processes, the maximum demand of resources by processes, and the current available resources. The function should return `True` if the system is in a safe state (i.e., no deadlock), and `False` otherwis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def detect_deadlock(allocated: List[List[int]], max_demand: List[List[int]], available: List[int]) -> bool:
"""
Detects if the system is in a safe state (i.e., no deadlock) given the current allocation o... |
magic_instruct_75k | 48,060 | Write a Python function to calculate the amplitude of each subset of a given data set and store the amplitudes in a list. The amplitude of a data set is defined as the difference between the maximum and minimum values in the set. The function should take a list of integers `wdata` and an integer `w` representing the si... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_amplitudes(wdata: List[int], w: int) -> List[int]:
"""
Calculate the amplitude of each subset of a given data set and store the amplitudes in a list.
The amplitude of a data set is def... |
magic_instruct_75k | 48,078 | Write a Python function to extract specific files from a given directory based on command-line arguments. The function should handle multiple file arguments and output the extraction process to the standard output. The function should be named `extract_files` and should adhere to the following requirements:
- The funct... | Here is the Python code to solve the given problem in the markdown block:
```python
import sys
import os
def extract_files(file_names: list, source_directory: str) -> None:
"""
Extracts specific files from a given directory and outputs the extraction process.
Args:
file_names (list): A list of fil... |
magic_instruct_75k | 48,090 | Write a Python function to simulate the build process for a containerized application. The function should take two arguments: the name of the image and the path to the source code for that image. The function should output a message indicating that the specified image has been successfully built using the given source... | Here is the Python code to solve the given problem in the markdown block:
```python
def build(image_name: str, source_path: str) -> None:
"""
Simulates the build process for a containerized application by printing a message
indicating that the specified image has been successfully built using the given sour... |
magic_instruct_75k | 48,107 | Write a Python function to validate incoming JSON payloads from various sensors according to specific requirements. The payload is expected to be a dictionary containing mandatory keys: 'asset', 'timestamp', and 'key'. Additionally, it may contain optional keys: 'readings' (a list of numerical sensor readings) and 'sen... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_payload(payload: dict) -> bool:
"""
Validates an incoming JSON payload from various sensors according to specific requirements.
Args:
payload (dict): The payload to be validated.
Returns:
b... |
magic_instruct_75k | 48,119 | Write a Python function to calculate the complexity of a given piece of code based on the number of different types of operations present in the code. The complexity is determined by the presence of two types of operations: `COMPLEXITY_COMPARISON_UNIT` and `COMPLEXITY_CONSTANT_UNIT`. The function should count the occur... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def calculateComplexity(code_snippet: str) -> int:
"""
Calculate the complexity of a given piece of code based on the number of different types of operations present.
The complexity is determined by the presence ... |
magic_instruct_75k | 48,122 | Write a Python function to generate Django admin registration code for a list of model names. The function should take a list of model names as input and return a string containing the registration code for the administrative panel. The registration code should be in the format `admin.site.register(ModelName)` for each... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_admin_registration_code(models: List[str]) -> str:
"""
Generates Django admin registration code for a list of model names.
Args:
models (List[str]): A list of model names to be ... |
magic_instruct_75k | 48,123 | Write a Python function to implement a simple event handling system. The system should allow registering event listeners and triggering events. However, there is a specific requirement to handle the potential issue of creating multiple closures for the same event.
Your task is to implement the `EventManager` class wit... | Here is the Python code to solve the given problem in the markdown block:
```python
class EventManager:
def __init__(self):
"""
Initialize the event manager with an empty dictionary to store event listeners.
"""
self.listeners = {}
def on(self, event_name, listener):
"""... |
magic_instruct_75k | 48,131 | Write a Python function to remove a person from a list of individuals based on their ID and return a message indicating the successful removal or a message indicating that no person was found with the given ID. The function should handle cases where the ID does not exist in the list.
The function signature is:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_person(people_list: list, id: int) -> str:
"""
Removes a person from the list of individuals based on their ID and returns a message indicating the result.
Args:
people_list (list): A list of dictionaries... |
magic_instruct_75k | 48,133 | Write a Python function to validate a student's matriculation number against a predefined matriculation number. If the numbers do not match, an error message should be appended to an errors list and an alert message should be displayed. If the numbers match, the function should proceed without any errors.
The function... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_matriculation_number(student_matric: str, predefined_matricno: str) -> list:
"""
Validates the student's matriculation number against a predefined matriculation number.
If the numbers do not match, an error mess... |
magic_instruct_75k | 48,164 | Write a Python function `calculate_a(a)` that takes an integer `a` as input and returns the final value of `a` after performing the mathematical operation `a = int((a*3) + 1)`. This function should replicate the behavior of the given code snippet.
The code should start with:
```python
def calculate_a(a: int) -> int:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_a(a: int) -> int:
"""
Calculate the final value of `a` after performing the mathematical operation `a = int((a*3) + 1)`.
Args:
a (int): The initial integer value.
Returns:
int: The final v... |
magic_instruct_75k | 48,176 | Write a Python function to determine whether a given weapon is light or one-handed piercing based on the provided truth table. The function should take two parameters: `obj` representing the object and `weap` representing the weapon. The function should return 1 if the weapon is light or one-handed piercing, and 0 othe... | Here is the Python code to solve the given problem in the markdown block:
```python
def IsWeaponLightOrOneHandedPiercing(obj: int, weap: int) -> int:
"""
Determines whether a given weapon is light or one-handed piercing based on the provided truth table.
Args:
obj (int): The object value, where 0 r... |
magic_instruct_75k | 48,191 | Write a Python function to manage file embedding within a project. The function should check for the existence of embedded files and display a message accordingly. The function should also handle the case when no files are embedded.
The code should start with:
```python
from typing import List
def check_embedded_file... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_embedded_files(embedded_files: List[str]) -> None:
"""
Checks for the existence of embedded files and displays a message accordingly.
Args:
embedded_files (List[str]): A list of st... |
magic_instruct_75k | 48,193 | Implement a simple banking system simulation in Python. The system should allow users to create accounts, deposit and withdraw funds, and check their balance. The task involves completing the implementation of the `MyApp` class and the `Account` class to fulfill the following requirements:
1. **Account Class**:
- E... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
class Account:
def __init__(self, name, balance):
"""
Initialize a new account with a unique account number, name, and initial balance.
Args:
name (str): The name of the account ho... |
magic_instruct_75k | 48,195 | Write a Python function to encapsulate the camera selection and initialization logic for a QR code scanner application. The function should check for the availability of a specific camera device and fall back to the default camera if the specified device is not found or is not usable. If no usable camera is found, the ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Optional
class QCameraInfo:
@staticmethod
def availableCameras():
# Mock implementation for demonstration purposes
return [QCameraInfo("Camera1"), QCameraInfo("Camera2")]
@staticmethod
... |
magic_instruct_75k | 48,219 | Create a Python function to parse a JSON string and extract specific values based on keys. The function should handle parsing boolean values and floating-point numbers. The function should return a dictionary containing the parsed values.
The code should start with:
```python
import json
from typing import Dict
def p... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
from typing import Dict
def parse_json(json_string: str) -> Dict[str, bool | float]:
"""
Parse a JSON string and extract the boolean value associated with the key "happy"
and the floating-point value associated ... |
magic_instruct_75k | 48,226 | Write a Python function `process_tokens(tokens: List[str]) -> List[str]` that takes a list of tokens (strings of binary digits) as input and appends two specific bit sequences to the end of the list based on the following rules:
1. Add a 5-bit "don't care" sequence represented by '00000' to the end of the token list.
2... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_tokens(tokens: List[str]) -> List[str]:
"""
Process a list of tokens by appending a 5-bit "don't care" sequence and a 6-bit "op-code" sequence to the end of the list.
Args:
token... |
magic_instruct_75k | 48,252 | Write a Python function `find_memory_devices` that filters a dictionary of memory devices based on specific criteria. Each memory device is represented by a unique string key, and its specifications are stored in a nested dictionary. The function should return a list of device keys that meet the given criteria.
The fu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def find_memory_devices(devices_dict: Dict[str, Dict[str, any]], min_page_size: int, max_write_cycle: float, min_capacity: int, required_bitmask: str) -> List[str]:
"""
Filters memory devices based... |
magic_instruct_75k | 48,261 | Write a Python function to simulate the behavior of the `CORS` function used in web development. The function should take in three parameters:
- `app`: A string representing the name of the application or endpoint.
- `origins`: A list of strings representing the allowed origins for cross-origin requests.
- `supports_cr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def simulate_cors(app: str, origins: List[str], supports_credentials: bool) -> str:
"""
Simulates the CORS configuration for a given application or endpoint.
Args:
app (str): The name of the... |
magic_instruct_75k | 48,267 | Write a Python function to determine the type of network link based on a given link type identifier. The function should support three types of links: static, shared, and automatic. The link type is represented by an integer identifier where `0` corresponds to static, `1` corresponds to shared, and `2` corresponds to a... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_link_type(link_id: int) -> str:
"""
Determine the type of network link based on the given link type identifier.
Args:
link_id (int): The identifier of the link type. 0 for static, 1 for shared, and 2 for aut... |
magic_instruct_75k | 48,269 | Write a Python function to perform a right rotation on an AVL tree node. An AVL tree is a self-balancing binary search tree, where the difference in heights of the left and right subtrees for every node is at most 1. The rotation operation helps maintain the balance of the tree after insertions or deletions.
The provi... | Here is the Python code to solve the given problem in the markdown block:
```python
class AvlTreeNode:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.height = 1
def update_height(self):
self.height = 1 + max(self.get_height(self.left), se... |
magic_instruct_75k | 48,272 | Write a Python function to filter out items from a dictionary that have services with the permission "spfirewall_allow_all". The function should return a list of items associated with services that have this permission.
The input `data` is a dictionary where the keys represent items, and the values are dictionaries co... | Here is the Python code to solve the given problem in the markdown block:
```python
def filter_services_with_permission(data: dict) -> list:
"""
Filters items from a dictionary that have services with the permission "spfirewall_allow_all".
Args:
data (dict): A dictionary where keys are items and va... |
magic_instruct_75k | 48,275 | 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 string of random alphanumeric characters of the given length. The alphanumeric characters should include both uppercase and lowercase letters, as well as digits (0-9... | 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:
"""
Generates a random alphanumeric string of the specified length.
Args:
length (int): The length of the random string to generate.
... |
magic_instruct_75k | 48,313 | Write a Python function to automate the versioning of software tags. The function should take three input parameters, `major`, `minor`, and `patch`, representing the major, minor, and patch versions respectively. The function should then concatenate these numbers into a new tag format and return it as a string. For exa... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_software_tag(major: int, minor: int, patch: int) -> str:
"""
Creates a software version tag by concatenating the major, minor, and patch versions.
Args:
major (int): The major version number.
mino... |
magic_instruct_75k | 48,324 | Write a Python function to evaluate a postfix expression. A postfix expression is an arithmetic expression in which the operators follow their operands. The operators supported are addition (`+`), subtraction (`-`), multiplication (`*`), division (`/`), and exponentiation (`^`). The operands are assumed to be integers.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def evaluate_postfix(expression: List[str]) -> int:
"""
Evaluate a postfix expression and return the result.
Args:
expression (List[str]): A list representing the postfix expression where ea... |
magic_instruct_75k | 48,381 | Write a Python function to shift each character in a given string by a specified number of positions in the alphabet. The function should handle both uppercase and lowercase letters and should wrap around the alphabet if the shift goes past 'z' or 'Z'. Non-alphabet characters should remain unchanged.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def shift_string(input_string: str, shift: int) -> str:
"""
Shifts each character in the input string by the specified number of positions in the alphabet.
Args:
input_string (str): The input string to be shifted.
... |
magic_instruct_75k | 48,392 | Create a Python function to implement a logging system that supports different log levels and output destinations. The logging system should be able to handle log messages with levels such as DEBUG, INFO, WARNING, and ERROR, and output them to various destinations like the console, a file, or a network socket. Addition... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Callable, List, Optional
from datetime import datetime
def log_message(level: str, message: str, output_destinations: List[Callable[[str], None]]) -> None:
"""
Logs a message with a specified level to multipl... |
magic_instruct_75k | 48,424 | Write a Python function to update the parameters (weights) in a TVM (Tensor Virtual Machine) module. The TVM module is represented as a dictionary containing compiled functions and other metadata. The parameters are stored in a separate dictionary. The function should take the existing parameters and the updated parame... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_tvm_params(tvm_module: dict, existing_params: dict, updated_params: dict) -> dict:
"""
Updates the parameters in a TVM module with the values from the updated parameters.
Args:
tvm_module (dict): A dictio... |
magic_instruct_75k | 48,435 | Write a Python function to find the nth ugly number. An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. The function should take an integer `n` as input and return the nth ugly number.
The code should start with:
```python
def nth_ugly_number(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def nth_ugly_number(n: int) -> int:
"""
Find the nth ugly number. An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
Args:
n (int): The position of the ugly number to find.
Ret... |
magic_instruct_75k | 48,447 | Write a Python function to simulate the command-line utility for managing a PostgreSQL database. The utility should support various operations such as displaying the process list, showing locks, canceling backend queries, and terminating backends. The function should parse the command-line arguments and execute the cor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def pg_proc(command: str, pids: Optional[List[int]] = None) -> None:
"""
Simulate a command-line utility for managing a PostgreSQL database.
Args:
command (str): The command to exe... |
magic_instruct_75k | 48,460 | Write a Python script that automates the setup of Android application testing by validating two environment variables: `APP_BUNDLE` and `APP_ACTIVITY`. The script should check if both environment variables are set. If either variable is not set, the script should print an appropriate error message and exit with a non-z... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
import sys
def validate_environment_variables():
"""
Validates the presence of the `APP_BUNDLE` and `APP_ACTIVITY` environment variables.
If either variable is not set, prints an error message and exits with a non... |
magic_instruct_75k | 48,506 | Write a Python function that simulates a simplified version of a command-line utility. The function should take a list of flags as input and return the corresponding usage information for each flag. Each flag is preceded by either a single dash (`-`) or a double dash (`--`), followed by the flag name. The function shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_usage_info(flags: List[str]) -> List[str]:
"""
Returns the usage information for each flag in the input list.
Args:
flags (List[str]): A list of strings representing the command-line... |
magic_instruct_75k | 48,521 | Write a Python function to update a configuration dictionary with default values for missing keys. The function should take in three parameters: `config` (a dictionary representing the current configuration), `key` (a string representing the key to be checked and potentially added), and `default` (the default value to ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def update_config(config: Dict[str, Any], key: str, default: Any) -> Dict[str, Any]:
"""
Updates the configuration dictionary with a default value for a missing key.
Args:
config (Dict[... |
magic_instruct_75k | 48,524 | Write a Python function to calculate the sum of numerical values in a given list of mathematical expressions. Each expression may contain integers, addition, and subtraction operations. The expressions are guaranteed to be well-formed and valid.
The code should start with:
```python
from typing import List
def calcul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_expression_sum(expressions: List[str]) -> int:
"""
Calculate the sum of numerical values in the given list of mathematical expressions.
Args:
expressions: A list of strings rep... |
magic_instruct_75k | 48,531 | Write a Python function to generate a log string based on the provided training metrics for a machine learning model. The function should take in several parameters and construct a log string based on the given inputs. If verbose logging is disabled, the function should return an empty string. If verbose logging is ena... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_log_string(epoch: int, epochs: int, train_loss: float, verbose: bool, metrics: dict) -> str:
"""
Generates a log string based on the provided training metrics.
Args:
epoch (int): The current epoch of tr... |
magic_instruct_75k | 48,548 | Write a Python function to count the number of distinct prime factors for each number in a given list of integers. The function should return a list of integers where each integer represents the count of distinct prime factors for the corresponding number in the input list.
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 distinct_prime_factors_count(numbers: List[int]) -> List[int]:
"""
Counts the number of distinct prime factors for each number in the input list.
Args:
numbers (List[int]): A list of pos... |
magic_instruct_75k | 48,553 | Write a Python function to detect if a specific comment indicating manual changes is present in a file's content. The comment is defined as a line that starts with "//" followed by the message: "Manual changes to this file may cause unexpected behavior in your application." The function should return a boolean value in... | Here is the Python code to solve the given problem in the markdown block:
```python
def detect_manual_changes(file_content: str) -> bool:
"""
Detects if a specific comment indicating manual changes is present in the file's content.
Args:
file_content (str): The content of the file as a single strin... |
magic_instruct_75k | 48,573 | Write a Python function to delete all occurrences of a specific value from a given list of integers and return the modified list. The function should maintain the relative order of the remaining elements.
The code should start with:
```python
from typing import List
def delete_occurrences(lst: List[int], value: int) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def delete_occurrences(lst: List[int], value: int) -> List[int]:
"""
Deletes all occurrences of a specific value from the given list of integers and returns the modified list.
Args:
lst (Lis... |
magic_instruct_75k | 48,578 | Write a Python function to sort a list of strings alphanumerically. Alphanumeric sorting is a type of sorting that treats numbers in a way that is similar to the natural ordering of numbers. For example, "a1", "a10", "a2" would be sorted as "a1", "a2", "a10" instead of the default lexicographical sorting which would re... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def sort_alphanumerically(list_of_strings: List[str]) -> List[str]:
"""
Sorts a list of strings alphanumerically.
Alphanumeric sorting treats numbers within strings as integers rather than... |
magic_instruct_75k | 48,610 | Write a Python function to find the maximum total weight that can be loaded onto a truck without exceeding its weight capacity. The function should take a list of integers representing the weights of packages and an integer representing the weight capacity of the truck. The function should return the maximum total weig... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_weight(weights: List[int], capacity: int) -> int:
"""
Calculate the maximum total weight that can be loaded onto a truck without exceeding its capacity.
Args:
weights (List[int]): A ... |
magic_instruct_75k | 48,620 | Write a Python function to filter out positive floating-point numbers from a given list. The function should return a new list containing only the positive numbers from the input list. If the input list is empty or does not contain any positive numbers, the function should return an empty list.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_positive(numbers: List[float]) -> List[float]:
"""
Filters out positive floating-point numbers from the given list.
Args:
numbers (List[float]): The list of floating-point numbers... |
magic_instruct_75k | 48,629 | Implement two Python functions, `datasets_scrape` and `indicators_scrape`, that scrape datasets and indicators from various sources using a `workspace` object. The `workspace` object contains information about the project environment and configuration settings. The `datasets_scrape` function should extract datasets fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
class Workspace:
def __init__(self, sources: List[str], indicators: List[str]):
self.sources = sources
self.indicators = indicators
def scrape_data_from_source(source: str) -> List[Dic... |
magic_instruct_75k | 48,632 | Write a Python function to extract the names of models being created from a list of database migration operations. Each migration operation is represented as a Python class instance, and the model creation operations are represented by instances of the `migrations.CreateModel` class. The function should return a list o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_model_names(operations: List[object]) -> List[str]:
"""
Extracts the names of models being created from a list of database migration operations.
Args:
operations (List[object]): ... |
magic_instruct_75k | 48,636 | Write a Python function to calculate the Euclidean distance between two points in a 2D plane given their coordinates. The function should take four integers as input, representing the coordinates of the two points, and return the integer Euclidean distance between them.
The code should start with:
```python
def euclid... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def euclidean_distance(x0: int, y0: int, x1: int, y1: int) -> int:
"""
Calculate the integer Euclidean distance between two points in a 2D plane.
Args:
x0 (int): The x-coordinate of the first point.
... |
magic_instruct_75k | 48,638 | Write a Python function `copy_genetic_files(coreID, nameID)` that simulates the file copying behavior based on specific conditions. The function should take two parameters:
- `coreID` (string): The identifier for the genetic data file.
- `nameID` (string): The identifier for the new file names.
The function should per... | Here is the Python code to solve the given problem in the markdown block:
```python
def copy_genetic_files(coreID: str, nameID: str) -> list:
"""
Simulates the file copying behavior based on specific conditions.
Args:
coreID (str): The identifier for the genetic data file.
nameID (str): The... |
magic_instruct_75k | 48,654 | Write a Python function to count the occurrences of each unique character in a given string, ignoring spaces and treating uppercase and lowercase characters as the same. The function should return a dictionary where the keys are the unique characters (in lowercase) and the values are the counts of each character.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_unique_characters(input_string: str) -> Dict[str, int]:
"""
Counts the occurrences of each unique character in the input string, ignoring spaces and case sensitivity.
Args:
input_s... |
magic_instruct_75k | 48,662 | Create a Python class `PackageRegistry` that manages a package registry system. The system should allow users to add, remove, and search for packages, as well as display package details. Each package has a name, version, and number of GitHub stars. Implement the following methods:
1. `add_package(name: str, version: st... | Here is the Python code to solve the given problem in the markdown block:
```python
class Package:
def __init__(self, name: str, version: str, stars: int):
"""
Represents an individual package with a name, version, and number of GitHub stars.
Args:
name (str): The name of the pa... |
magic_instruct_75k | 48,672 | Write a Python function `encode_message(message, encoding)` that takes a string `message` containing only uppercase letters and a dictionary `encoding` as input, and returns the encoded message as a string of concatenated patterns. Each character in the message should be encoded using the first pattern from the corresp... | Here is the Python code to solve the given problem in the markdown block:
```python
def encode_message(message: str, encoding: dict) -> str:
"""
Encodes a message using the given encoding dictionary.
Args:
message (str): The message to be encoded, containing only uppercase letters.
encoding... |
magic_instruct_75k | 48,691 | Write a Python function that takes a user name and a default dictionary, and returns a modified dictionary based on the user's input. The function should adhere to the following rules:
- If the `user` is not already present in the `default` dictionary, add the `user` as a key with an empty list as its value.
- If the `... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def modify_user_preferences(user: str, default: Dict[str, List[str]]) -> Dict[str, List[str]]:
"""
Modifies the default dictionary based on the user's input.
Args:
user (str): The name... |
magic_instruct_75k | 48,709 | Create a Python class `CallbackManager` that implements a callback system for a game development framework called Angel2d. The framework uses a class called `String` to represent strings. The `CallbackManager` class should have the following methods:
1. `registerCallback(name: String, callback: Callable)`: This method ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Callable, Optional, Any
class String:
def __init__(self, str_value: str):
self.value = str_value
class CallbackManager:
def __init__(self):
"""
Initialize the CallbackManager with an ... |
magic_instruct_75k | 48,715 | Write a Python function to find the maximum sum of a contiguous subsequence within a given sequence of integers. The function should efficiently compute the maximum sum using an optimal approach.
The code should start with:
```python
from typing import List
def max_contiguous_sum(sequence: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_contiguous_sum(sequence: List[int]) -> int:
"""
Calculate the maximum sum of a contiguous subsequence within the given sequence.
Args:
sequence (List[int]): The sequence of integers ... |
magic_instruct_75k | 48,718 | Write a Python function to merge a list of dictionaries into a single dictionary. Each dictionary in the list represents a mapping of IDs to names for a specific category. The keys of the resulting dictionary will be the category names, and the values will be the corresponding ID to name mappings. The function should h... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def merge_dicts(dict_list: List[Dict[str, Dict[Any, Any]]]) -> Dict[str, Dict[Any, Any]]:
"""
Merge a list of dictionaries into a single dictionary. Each dictionary in the list represents a ma... |
magic_instruct_75k | 48,727 | Write a Python function to calculate the average of a list of numbers without using the built-in `sum()` or `len()` functions. Instead, use a loop and basic arithmetic operations to compute the total sum and count of elements in the list. The function should handle empty lists by returning 0 to avoid division by zero.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_average(numbers: List[int]) -> float:
"""
Calculate the average of a list of numbers without using the built-in `sum()` or `len()` functions.
Args:
numbers (List[int]): A list ... |
magic_instruct_75k | 48,744 | Write a Python function to extract column names from an HTML table header string. The HTML table header is represented by the `<thead>` tag, and the column names are enclosed within `<th>` tags. The function should return the column names as a list in the order they appear in the header.
The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_column_names(table_header: str) -> List[str]:
"""
Extracts column names from an HTML table header string.
Args:
table_header (str): A string representing an HTML table ... |
magic_instruct_75k | 48,758 | Write a Python function to perform arithmetic operations on two numbers and then use it to solve a specific problem. The function should be named `arithmetic_operations` and take three parameters: `a`, `b`, and `operation`. The `operation` parameter should be a string that specifies the arithmetic operation to be perfo... | Here is the Python code to solve the given problem in the markdown block:
```python
def arithmetic_operations(a: float, b: float, operation: str) -> float:
"""
Perform arithmetic operations on two numbers based on the specified operation.
Args:
a (float): The first number.
b (float): The se... |
magic_instruct_75k | 48,762 | Write a Python function to convert a Roman numeral string to its corresponding integer value. The function should handle the standard Roman numeral symbols and the special cases where a smaller numeral precedes a larger numeral to indicate subtraction. The code should start with:
```python
def roman_to_int(s: str) -> i... | Here is the Python code to solve the given problem in the markdown block:
```python
def roman_to_int(s: str) -> int:
"""
Converts a Roman numeral string to its corresponding integer value.
Args:
s (str): The Roman numeral string to be converted.
Returns:
int: The integer value correspo... |
magic_instruct_75k | 48,765 | Write a Python function to map a state abbreviation to its corresponding FIPS (Federal Information Processing Standards) code. The function should handle specific state abbreviations and return a default FIPS code for any other state abbreviation. The function should start with:
```python
def get_fips_code(state_abbr: ... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_fips_code(state_abbr: str) -> str:
"""
Returns the FIPS code corresponding to the given state abbreviation.
Args:
state_abbr (str): The state abbreviation (e.g., 'OH' for Ohio).
Returns:
str: Th... |
magic_instruct_75k | 48,769 | Write a Python function called `manipulate_values` that performs the following operations:
1. Concatenates a given name with a greeting message to form a text value.
2. Adds two given numbers to produce a number value.
The function should return a tuple containing the text value and the number value.
The function sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def manipulate_values(name: str, num1: int, num2: int) -> tuple:
"""
Manipulates a given name and two numbers to produce a text value and a number value.
Args:
name (str): A non-empty string representing a name.
... |
magic_instruct_75k | 48,779 | Write a Python function `get_run_generator` that generates a series of input strings based on a given set of test data. The function takes a single argument `test_data`, which is a tuple of strings. It returns a callable function that, when invoked, generates and returns the next input string based on the test data. Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Callable, Generator
def get_run_generator(test_data: Tuple[str]) -> Callable[[], str]:
"""
Generates a series of input strings based on a given set of test data.
Args:
test_data (Tuple[str... |
magic_instruct_75k | 48,836 | Write a Python function to calculate the Euclidean distance between a given 2D point and a collection of projections in a 2D space. The function should take a 2D point and a list of projections as input and return a list of distances, where each distance represents the Euclidean distance between the given point and a p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
def calculate_distances(point: Tuple[float, float], projections: List[Tuple[float, float]]) -> List[float]:
"""
Calculate the Euclidean distance between a given 2D point and a collecti... |
magic_instruct_75k | 48,840 | Write a Python function to modify a given list of integers by returning a new list containing the squares of all the even numbers from the input list, in the same order as they appear in the input list. If the input list is empty or does not contain any even numbers, the function should return an empty list.
The code ... | 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]:
"""
Returns a new list containing the squares of all the even numbers from the input list,
in the same order as they appear in the input list. If ... |
magic_instruct_75k | 48,868 | Write a Python function to determine the minimum number of invalid parentheses that need to be removed from a given string to make it a valid sequence. Invalid parentheses are defined as any closing parentheses without a corresponding opening parentheses, or any opening parentheses without a corresponding closing paren... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_invalid_parenthesis(string: str) -> int:
"""
Calculate the minimum number of invalid parentheses that need to be removed to make the string a valid sequence.
Args:
string (str): The input string containing... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.