source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
67,108
Write a Python function to filter out specific transaction codes from a given list based on a set of exclusion criteria. The function should return a new list containing only the transaction codes that do not match any of the criteria. The code should start with: ```python from typing import List def filterTransactio...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filterTransactions(transactions: List[str], criteria: List[str]) -> List[str]: """ Filters out transaction codes based on a set of exclusion criteria. Args: transactions (List[str]): A l...
magic_instruct_75k
67,110
Write a Python function to calculate the dimensions of a cell in a grid layout based on its position in the section. The function should determine whether the cell should have normal dimensions or featured dimensions based on the given conditions. The function should start with: ```python def calculate_cell_dimensions...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_cell_dimensions(item_in_section: int, normal_column_height: int, featured_column_width: int, featured_column_height: int) -> tuple: """ Calculate the dimensions of a cell in a grid layout based on its position in t...
magic_instruct_75k
67,136
Write a Python function to parse a Docker image name based on a specific pattern and return a dictionary containing the version, Python version, distro, repository, and development status. The image name will follow the pattern specified in the regular expression `IMAGE_RE`. The function should start with: ```python i...
Here is the Python code to solve the given problem in the markdown block: ```python import re def parse_docker_image_name(image_name: str) -> dict: """ Parse a Docker image name and return a dictionary containing the version, Python version, distro, repository, and development status. Args: image_...
magic_instruct_75k
67,146
Write a Python function to calculate the total number of note points across all tonnetze in a given dictionary. Each tonnetz is represented by a key-value pair in the dictionary, where the key is a string representing the tonnetz identifier and the value is a list of integers representing the note points associated wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def get_total_note_points(dict_of_tonnetze: Dict[str, List[int]]) -> int: """ Calculate the total number of note points across all tonnetze in the given dictionary. Args: dict_of_tonne...
magic_instruct_75k
67,157
Write a Python function to convert a list of dates from the format "dd/mm/yyyy" to the format "yyyy-mm-dd". The function should take a list of strings as input, where each string represents a date in the "dd/mm/yyyy" format, and return a list of strings with the dates converted to the "yyyy-mm-dd" format. The code sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_dates(dates: List[str]) -> List[str]: """ Converts a list of dates from the format "dd/mm/yyyy" to the format "yyyy-mm-dd". Args: dates (List[str]): A list of strings, where each...
magic_instruct_75k
67,160
Write a Python function to filter a list of file content types, removing any files with the content type "image/svg+xml" and ignoring any files with an empty content type. The function should return a new list containing only the valid content types. The code should start with: ```python from typing import List def f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filterFiles(fileTypes: List[str]) -> List[str]: """ Filters a list of file content types, removing any files with the content type "image/svg+xml" and ignoring any files with an empty content typ...
magic_instruct_75k
67,161
Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should be named `max_subarray_sum` and should take a single parameter, `arr`, which is a list of integers. The function should efficiently compute the maximum sum using an optimal algorithm. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within the given list of integers. Args: arr (List[int]): The list of integers from which to fi...
magic_instruct_75k
67,170
Write a Python function to transform a list of integers based on the following rules: - If the integer is even, add 10 to it. - If the integer is odd, subtract 5 from it. The function should take a list of integers as input and return a new list containing the transformed integers. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def transform_list(lst: List[int]) -> List[int]: """ Transforms a list of integers based on the following rules: - If the integer is even, add 10 to it. - If the integer is odd, subtract 5 from i...
magic_instruct_75k
67,190
Write a Python function to update the processing status of a specific task. The function should take a dictionary representing the task and a string representing the new status. The dictionary contains keys such as `'Id'`, `'Nome'`, `'DataInicio'`, and `'Status'`. The possible statuses are `'EmAndamento'` (in progress)...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union def update_processing_status(processamento: Dict[str, Union[int, str]], status: str) -> Union[None, str]: """ Update the processing status of a specific task. Args: processamento (Dic...
magic_instruct_75k
67,199
Write a Python function to generate command-line arguments for a disassembly tool based on user input options. The function should take three parameters: `disass` (a boolean indicating whether disassembly is enabled), `number_instructions` (an integer specifying the number of instructions to display), and `signature` (...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_command_line_args(disass: bool, number_instructions: int, signature: bool) -> str: """ Generates command-line arguments for a disassembly tool based on user input options. Args: disass (bool): Indicates...
magic_instruct_75k
67,240
Write a Python function to simulate the deletion of a specific user from a list of users and provide appropriate feedback in case of failure. The function should handle the deletion of the user 'modem-keepaliver' from a given list of users and return a message indicating whether the deletion was successful or if it fai...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def delete_user(users: List[str]) -> Tuple[bool, str]: """ Simulates the deletion of the user 'modem-keepaliver' from a list of users and provides feedback. Args: users (List[str]): A...
magic_instruct_75k
67,243
Write a Python function to convert a given temperature in Celsius to Fahrenheit. The function should take an integer parameter `degrees` representing the temperature in Celsius and return the equivalent temperature in Fahrenheit, rounded to the nearest integer. The formula for converting Celsius to Fahrenheit is: \[Fa...
Here is the Python code to solve the given problem in the markdown block: ```python def celsius_to_fahrenheit(degrees: int) -> int: """ Converts a given temperature in Celsius to Fahrenheit and rounds it to the nearest integer. Args: degrees (int): The temperature in Celsius, within the range -100 ...
magic_instruct_75k
67,245
Write a Python function to process a video file by applying transformations based on user-provided parameters. The function should read the video file path, the x and y positions, and the scale size. The inputs for the x and y positions, as well as the scale size, should be normalized within the range [0, 1]. The funct...
Here is the Python code to solve the given problem in the markdown block: ```python import logging def process_video(video_path: str, x_pos: float, y_pos: float, scale_size: float) -> None: """ Processes a video file by applying transformations based on user-provided parameters. Args: video_path (...
magic_instruct_75k
67,316
Write a Python function to simulate a simple text-based game where a player navigates through a grid-based world, collecting treasures and avoiding obstacles. The player's position in the grid is represented by (x, y) coordinates, where (0, 0) is the top-left corner. The grid is a square with a side length of `n` units...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def play_game(grid: List[str], treasures: int) -> bool: """ Simulates a text-based game where a player navigates through a grid to collect treasures and avoid obstacles. Args: grid (List[str...
magic_instruct_75k
67,344
Create a Python class `NetworkDevice` that represents a network device with the ability to manage its ports and their descriptions. The class should have methods to add ports, add descriptions to ports, and retrieve the description of a specific port. The class should be implemented according to the following requireme...
Here is the Python code to solve the given problem in the markdown block: ```python class NetworkDevice: def __init__(self): """ Initialize the NetworkDevice with an empty dictionary to store ports and their descriptions. """ self.ports = {} def add_port(self, port_number): ...
magic_instruct_75k
67,361
Write a Python function to process data from a generator and perform an ETL (Extract, Transform, Load) pipeline. The generator yields dictionaries representing data records, and the ETL pipeline involves extracting specific fields, transforming the data, and loading it into a new structure. The function should take a g...
Here is the Python code to solve the given problem in the markdown block: ```python def etl_pipeline(data_generator): """ Processes data from a generator and performs an ETL (Extract, Transform, Load) pipeline. Args: data_generator (generator): A generator that yields dictionaries representing data...
magic_instruct_75k
67,383
Write a Python function to update a dictionary of application settings based on a list of updates. Each update is represented as a tuple containing a setting key and its new value. The function should return the modified settings dictionary. The code should start with: ```python from typing import Dict, List, Tuple, A...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple, Any def update_settings(settings: Dict[str, Any], updates: List[Tuple[str, Any]]) -> Dict[str, Any]: """ Update the settings dictionary based on the provided list of updates. Args: ...
magic_instruct_75k
67,418
Write a Python function to process a configuration file in a simple key-value format and extract specific settings based on a given prefix. The configuration file content is provided as a string, where each line contains a setting in the form of "key = value". The function should return a dictionary containing all the ...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_settings(config_file: str, prefix: str) -> dict: """ Extracts settings from a configuration file content that start with a given prefix. Args: config_file (str): A string representing the content of the ...
magic_instruct_75k
67,434
Write a Python function to update or add column mappings in a list of dictionaries. Each dictionary represents a database table column mapping with keys `model_name`, `old_name`, and `new_name`. The function should update the `old_name` to `new_name` for a specific `model_name` if it exists in the list. If the `model_n...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def update_column_mappings(column_mappings: List[Dict[str, str]], model_name: str, old_name: str, new_name: str) -> List[Dict[str, str]]: """ Updates or adds a column mapping in a list of dictionar...
magic_instruct_75k
67,456
Write a Python function to count the total number of unique binary trees that can be formed with `N` nodes. Each binary tree is represented by a `TreeNode` class, which has attributes `val`, `left`, and `right`. The function should take an integer `N` as input and return the total number of unique binary trees that can...
Here is the Python code to solve the given problem in the markdown block: ```python def count_unique_binary_trees(N: int) -> int: """ Calculate the total number of unique binary trees that can be formed with N nodes. Args: N (int): The number of nodes in the binary trees. Returns: int:...
magic_instruct_75k
67,461
Write a Python function to compute the image-level repeat factor for a given set of images and their labels based on the frequency of each label in the dataset. The repeat factor for a label is calculated using a threshold value and the frequency of the label. The image-level repeat factor for an image is the maximum o...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import math def compute_repeat_factors(category_freq: Dict[int, float], repeat_thr: float, num_images: int, image_labels: List[List[int]]) -> List[float]: """ Compute the image-level repeat factors...
magic_instruct_75k
67,468
Write a Python function to perform a binary search on a sorted array to find the index of a specific target value within a given range. The function should return the index of the target if it is present in the array, and -1 if it is not found. The function should handle edge cases such as an empty array, a target valu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(a: List[int], target: int, left: int, right: int) -> int: """ Perform a binary search on a sorted array to find the index of a specific target value within a given range. Args: ...
magic_instruct_75k
67,475
Write a Python function to replace escaped characters in a given object. The function should iterate through the sections and options of the object, and for any key-value pairs of type 'keyval', it should replace any escaped characters with their unescaped counterparts. The code should start with: ```python def replac...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_escapes(obj: dict) -> dict: """ Replace any escaped characters in key-value pairs of type 'keyval' within the given object. Args: obj (dict): The object containing sections and options. Each option can b...
magic_instruct_75k
67,485
Write a Python function to normalize the `fingerPosition` based on the `mode` of a rock-paper-scissors game. The function should map the `fingerPosition` to a specific range based on the `mode` and return the normalized value. The `mode` can be 1 (rock), 2 (paper), or 3 (scissors), and each mode has a different range f...
Here is the Python code to solve the given problem in the markdown block: ```python def normalize(fingerPosition: float, mode: int) -> float: """ Normalizes the fingerPosition based on the mode of a rock-paper-scissors game. Args: fingerPosition (float): The position of the user's finger. m...
magic_instruct_75k
67,489
Write a Python function to filter and display student information based on an age threshold. The function should take a list of student dictionaries and an age threshold as input. Each student dictionary contains the keys 'name', 'age', 'class', 'student_id', and 'profile_picture'. The function should return a new list...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_students(students: List[Dict[str, any]], age_threshold: int) -> List[Dict[str, any]]: """ Filters and displays student information based on an age threshold. Args: students ...
magic_instruct_75k
67,520
Write a Python function to check if a snake's position is within the boundaries of a game area. The snake's position is represented by a tuple `snakePos2` containing its x and y coordinates. The game area has a specified width and height. If the snake's position is outside the boundaries, the function should return spe...
Here is the Python code to solve the given problem in the markdown block: ```python def check_snake_position(snakePos2: tuple, width: int, height: int) -> tuple: """ Check if the snake's position is within the boundaries of the game area. Args: snakePos2 (tuple): A tuple containing the x and y coor...
magic_instruct_75k
67,542
Write a Python function to process user registration data from a form. The function should validate and process the username, first name, and last name according to the following rules: 1. The username must be at least 6 characters long and contain only alphanumeric characters (a-z, A-Z, 0-9). If the username is invali...
Here is the Python code to solve the given problem in the markdown block: ```python def process_registration(username: str, fname: str, lname: str) -> tuple: """ Processes user registration data by validating the username and capitalizing the first and last names. Args: username (str): The username...
magic_instruct_75k
67,544
Write a Python function to convert empty strings in a given dictionary to a specified default value. If the input dictionary is empty or does not contain any empty strings, the function should return the original dictionary. The function should handle nested dictionaries and lists within the dictionary. The code shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, List def convert_empty_strings(data: Dict[str, Any], default_value: str) -> Dict[str, Any]: """ Convert empty strings in a given dictionary to a specified default value. Args: data (Di...
magic_instruct_75k
67,570
Write a Python function to filter a list of package names based on a given prefix. The function should return a new list containing only the package names that start with the specified prefix. The function should be named `filter_packages_by_prefix` and should accept two parameters: - `package_list` (list): A list of s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_packages_by_prefix(package_list: List[str], prefix: str) -> List[str]: """ Filters a list of package names based on a given prefix. Args: package_list (list): A list of strings re...
magic_instruct_75k
67,592
Write a Python function to extract the names of functions that are connected to a specific signal using the `signals.post_syncdb.connect` method from the Django framework. The function should take a list of strings, each representing a line of code, and return a list of function names that are connected to the `post_sy...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def extract_connected_functions(code_snippets: List[str]) -> List[str]: """ Extracts the names of functions that are connected to the `post_syncdb` signal using the `signals.post_syncdb.connect` meth...
magic_instruct_75k
67,596
Write a Python function to manage a custom namespace system. The function should allow users to add, remove, and list namespaces, as well as add and remove functions within those namespaces. The function should ensure that namespaces and function names are unique within their respective scopes and that namespaces are l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict class NamespaceManager: def __init__(self): """ Initialize the namespace manager with an empty dictionary to store namespaces. """ self.namespaces: Dict[str, set] = {} ...
magic_instruct_75k
67,598
Write a Python function to determine whether a given number is a prime number or not. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take an integer as input and return a boolean value indicating whether the input number is prime or not. The...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(num: int) -> bool: """ Determines whether a given number is a prime number. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
magic_instruct_75k
67,620
Write a Python function `validate_player_data(data)` that takes a dictionary `data` as input and returns `True` if the dictionary matches the expected format, and `False` otherwise. The expected format for the input dictionary is as follows: - The dictionary must have keys "player", "killers", and "op". - The value cor...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_player_data(data: dict) -> bool: """ Validates whether the input dictionary matches the expected format. The expected format for the input dictionary is as follows: - The dictionary must have keys "player",...
magic_instruct_75k
67,627
Write a Python function to simulate the process of applying database migration operations to a list of dependencies. The dependencies are represented as a list of tuples, where each tuple contains the name of the dependency and its initial version. The operations to be applied are represented as a list of migration ope...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def apply_migrations(dependencies: List[Tuple[str, str]], operations: List[str]) -> List[Tuple[str, str]]: """ Simulate the process of applying database migration operations to a list of dependenc...
magic_instruct_75k
67,630
Write a Python function to count the number of set bits (i.e., the number of 1s) in the binary representation of a given integer `n`. The function should use an efficient algorithm to achieve this, similar to the provided Java code snippet. The code should start with: ```python def count_set_bits(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_set_bits(n: int) -> int: """ Counts the number of set bits (1s) in the binary representation of the given integer `n`. Args: n (int): The integer whose set bits are to be counted. Returns: int...
magic_instruct_75k
67,637
Write a Python function to process RTP attributes, skipping specific attributes and returning the remaining attributes as a comma-separated string. The function should skip the attributes `Attribute_MaxPTime` and `Attribute_SSRC` and concatenate the remaining attributes in the order they appear in the input list. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_rtp_attributes(attributes: List[str]) -> str: """ Processes a list of RTP attributes, skipping specific attributes and returning the remaining attributes as a comma-separated string. Arg...
magic_instruct_75k
67,640
Create a Python class called `EntityCollection` that manages a collection of entities. The class should have the following methods: - `add(entity: EntityBase) -> None`: Adds a new entity to the collection. - `remove(entity: EntityBase) -> None`: Removes the specified entity from the collection. - `get_all() -> List[Ent...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Type, TypeVar class EntityBase: """ Base class for all entities. """ pass class EntityCollection: """ A collection class to manage entities. Methods: - add(entity: EntityBase) ...
magic_instruct_75k
67,649
Write a Python function to count the number of keys in a given dictionary for each key type (integer and string) and return the counts as a dictionary. The dictionary may contain keys of different types. The function should start with: ```python from typing import Dict def count_keys(d: Dict) -> Dict[str, int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_keys(d: Dict) -> Dict[str, int]: """ Counts the number of keys in the given dictionary for each key type (integer and string) and returns the counts as a dictionary. Args: d (Dict)...
magic_instruct_75k
67,663
Write a Python function to increment a version number in the format "x.y.z" by a specified part. The function should take two parameters: - `current_version` (string): A string representing the current version in the format "x.y.z" where x, y, and z are integers. - `part` (integer): An integer representing the part of ...
Here is the Python code to solve the given problem in the markdown block: ```python def bump_version(current_version: str, part: int) -> str: """ Increments the specified part of a version number in the format "x.y.z". Args: current_version (str): A string representing the current version in the fo...
magic_instruct_75k
67,666
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The code should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid. Args: m (int): The number of row...
magic_instruct_75k
67,674
Write a Python function to calculate the entropy of a binary random variable given the probability of success `p`. The entropy is a measure of uncertainty or randomness in a random variable. For a binary random variable with probability of success `p` and failure `q`, the entropy is given by the formula: `H = -p * log2...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def calculate_entropy(p: float) -> float: """ Calculate the entropy of a binary random variable given the probability of success `p`. The entropy H is a measure of uncertainty or randomness in a random v...
magic_instruct_75k
67,675
Write a Python function to find the index of the first occurrence of the highest score in a list of student scores. If the list is empty, return -1. If there are multiple occurrences of the highest score, return the index of the first occurrence. The code should start with: ```python from typing import List def find_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_highest_score_index(scores: List[int]) -> int: """ Finds the index of the first occurrence of the highest score in a list of student scores. Args: scores (List[int]): A list of inte...
magic_instruct_75k
67,679
Write a Python function to generate a stock entry document for incoming items based on a work order. The function should take the work order ID, item code, and quantity as parameters and return a dictionary representing the stock entry document. The stock entry document should include the purpose, company, and items wi...
Here is the Python code to solve the given problem in the markdown block: ```python def make_stock_entry_incoming(work_order_id: str, item_code: str, quantity: int) -> dict: """ Generates a stock entry document for incoming items based on a work order. Args: work_order_id (str): The ID of the work ...
magic_instruct_75k
67,698
Write a Python function to sort a list of integers in non-decreasing order using the **Bubble Sort** algorithm. The function should not use any built-in sorting functions or libraries. The code should start with: ```python from typing import List def customSort(expected: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def customSort(expected: List[int]) -> List[int]: """ Sorts a list of integers in non-decreasing order using the Bubble Sort algorithm. Args: expected (List[int]): The list of integers to be...
magic_instruct_75k
67,712
Write a Python function to find the maximum sum of a subarray of a given array. The subarray must be contiguous. The function should return the maximum sum. The code should start with: ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within a given array. Args: arr (List[int]): The input array of integers. Returns: ...
magic_instruct_75k
67,735
Write a Python function to determine if a given positive integer `n` is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should utilize the provided code snippet and any additional code necessary to accurately determine whether `n` is ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(n: int) -> bool: """ Determine if a given positive integer `n` is a prime number. Args: n (int): The positive integer to check for primality. Returns: bool: True if `n` is a prime number, F...
magic_instruct_75k
67,762
Write a Python function to parse a list of GitHub repository names in the format "username/reponame" and return a list of tuples, where each tuple contains the username and repository name as separate elements. The function should handle any valid input in the specified format. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def parse_github_repos(repo_list: List[str]) -> List[Tuple[str, str]]: """ Parses a list of GitHub repository names in the format "username/reponame" and returns a list of tuples. Args: ...
magic_instruct_75k
67,785
Write a Python function to escape special characters in an error message to make it safe for displaying in HTML. The function should take an error message as input and return the HTML-escaped error message. The function should escape the following characters: - `<` should be replaced with `&lt;` - `>` should be replace...
Here is the Python code to solve the given problem in the markdown block: ```python def escape_html_message(error_message: str) -> str: """ Escapes special characters in an error message to make it safe for displaying in HTML. Args: error_message (str): The error message to be escaped. Returns...
magic_instruct_75k
67,791
Write a Python function `process_dictionary` that takes a dictionary `my_dictionary` as input and performs the following tasks: 1. Print each key-value pair in the format "key: value" on a new line. 2. Print each value in the dictionary on a new line. 3. Return the total count of key-value pairs in the dictionary. The...
Here is the Python code to solve the given problem in the markdown block: ```python def process_dictionary(my_dictionary: dict) -> int: """ Processes a given dictionary by printing each key-value pair and each value, and returns the total count of key-value pairs. Args: my_dictionary (dict): Th...
magic_instruct_75k
67,818
Write a Python function to dynamically import modules based on a given list of module names. The function should return a dictionary mapping the module names to the corresponding imported modules. If a module cannot be imported, the dictionary should map the module name to `None`. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def import_modules(module_names: List[str]) -> Dict[str, object]: """ Dynamically imports modules based on a given list of module names. Args: module_names (List[str]): A list of strin...
magic_instruct_75k
67,830
Write a Python function to sanitize a list of URLs and queries to prevent potential cross-site scripting (XSS) attacks. The function should identify and remove any unsafe URLs or queries from the given list. The unsafe URLs are represented by empty strings. The function should return a new list containing only the safe...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sanitizeURLsAndQueries(urls_and_queries: List[str]) -> List[str]: """ Sanitize a list of URLs and queries by removing any unsafe URLs represented by empty strings. Args: urls_and_queries...
magic_instruct_75k
67,849
Write a Python function to unpack a 32-bit signed magnitude integer from a byte buffer at a specified offset. The function should handle the sign bit and magnitude bits appropriately to return the unpacked 32-bit signed magnitude integer. The code should start with: ```python import struct def unpack_int32_from(buf: b...
Here is the Python code to solve the given problem in the markdown block: ```python import struct def unpack_int32_from(buf: bytes, offset: int = 0) -> int: """ Unpack a 32-bit signed magnitude integer from the byte buffer *buf* at the specified *offset*. Args: buf (bytes): The byte buffer from wh...
magic_instruct_75k
67,876
Implement a simplified version of a component mixin system for an entity-component system (ECS) in Python. The task involves creating a `Component` class and a `World` class with a method `component` that allows users to create new components and associate them with the ECS world. The method should support variadic arg...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, List, Type class Component: """ Represents a component in the ECS system. Args: *args (Any): Variadic arguments that the component can store. """ def __init__(self, *args: Any): ...
magic_instruct_75k
67,878
Write a Python function to count the number of occurrences of a specific target character within a given string. The function should efficiently handle strings of length up to 100,000 characters. The code should start with: ```python def countOccurrences(s: str, target: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def countOccurrences(s: str, target: str) -> int: """ Counts the number of occurrences of a specific target character within a given string. Args: s (str): The input string in which to count the occurrences. ...
magic_instruct_75k
67,906
Create a Python decorator named `error_handler` that handles exceptions for a given function. The decorator should catch any exceptions raised by the function and print an error message along with the exception type and message. Additionally, it should return a default value specified by the decorator if an error occur...
Here is the Python code to solve the given problem in the markdown block: ```python def error_handler(default_value): """ A decorator that handles exceptions for a given function. Args: default_value: The value to return if an exception occurs. Returns: decorator: A decorator function ...
magic_instruct_75k
67,911
Write a Python class `CustomBatchNormalizationLayer` that implements a custom batch normalization layer for a neural network. The class should include methods for the forward pass during training and prediction. The `forward` method should apply batch normalization to the input data during training, updating the runnin...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np class CustomBatchNormalizationLayer: def __init__(self, epsilon=1e-5, momentum=0.9): """ Initialize the batch normalization layer. Args: epsilon (float): A small value to avoi...
magic_instruct_75k
67,918
Write a Python function `helper(nums, i)` that takes in a list of integers `nums` and an integer `i`. The function should return a specific value based on the input list and index. The function should behave as follows: - If the index `i` is equal to the length of the list `nums` minus 1, return the last element of the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def helper(nums: List[int], i: int) -> int: """ Returns a specific value from the list `nums` based on the index `i`. Args: nums (List[int]): The list of integers. i (int): The index...
magic_instruct_75k
67,949
Implement the `CommitAndWaitDocumentRetriever` class in Python based on the provided specifications. The class should have a constructor that initializes a `_retriever` member variable of type `DocumentRetriever`. It should also have two methods: `parseSelect` and `getReadGuard`, which delegate their operations to the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any class DocumentRetriever: def parseSelect(self, selection: str) -> Any: """ Placeholder method for parsing a selection string. Args: selection (str): The selection ...
magic_instruct_75k
67,952
Write a Python function to process a list of macro definitions and return a dictionary containing the defined macros. Each macro definition is represented as a tuple containing the macro name and its value. The function should handle the case where a macro is defined multiple times, in which case the last definition sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def process_macros(define_macros: List[Tuple[str, str]]) -> Dict[str, str]: """ Processes a list of macro definitions and returns a dictionary containing the defined macros. If a macro i...
magic_instruct_75k
67,953
Write a Python function to merge overlapping intervals from a given list of intervals. Each interval is represented as a pair of integers `[start, end]`, and the intervals are sorted based on their start values. The function should return a new list of non-overlapping intervals after merging. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_intervals(intervals: List[List[int]]) -> List[List[int]]: """ Merge overlapping intervals from a given list of intervals. Args: intervals (List[List[int]]): A list of intervals, wh...
magic_instruct_75k
67,970
Write a Python function to predict the likelihood of hypertension and heart disease based on patient data. The function should take two input variables, `hypertension` and `heart_disease`, which can either be "Yes" or "No". The function should return a tuple containing the predicted likelihood of hypertension and heart...
Here is the Python code to solve the given problem in the markdown block: ```python def predict_health_condition(hypertension: str, heart_disease: str) -> (int, int): """ Predicts the likelihood of hypertension and heart disease based on patient data. Args: hypertension (str): A string indicating t...
magic_instruct_75k
67,986
Create a Python class `ApparatusRequestObject` that handles apparatus requests in a virtual reality simulation environment. The class should have a method `LoadAsset` that takes a string `assetName` as a parameter and returns an instance of `ApparatusRequestObject` with the `Type` property set to `EApparatusRequestType...
Here is the Python code to solve the given problem in the markdown block: ```python from enum import Enum class EApparatusRequestType(Enum): LoadAsset = 1 UnloadAsset = 2 Other = 3 class AssetLoadRequestArgs: def __init__(self, asset_name: str): """ Initialize the AssetLoadRequestArgs ...
magic_instruct_75k
67,989
Write a Python function `generate_master_list(master_discovery)` that takes a string `master_discovery` as input and returns the corresponding `master_list` based on the following rules: - If `master_discovery` is `'master_http_loadbalancer'`, set `master_list` to the value of `exhibitor_address` followed by `':2181'`....
Here is the Python code to solve the given problem in the markdown block: ```python def generate_master_list(master_discovery: str) -> str: """ Generate a master list based on the master discovery method. Args: master_discovery (str): The method used to discover the master nodes. Returns: ...
magic_instruct_75k
68,000
Write a Python function to remove duplicate elements from a given tuple while preserving the original order of elements. The function should take a tuple as input and return a new tuple with all duplicate elements removed. The order of elements in the output tuple should be the same as their first occurrence in the inp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def remove_duplicated_keep_order(value_in_tuple: Tuple) -> Tuple: """ Removes duplicate elements from a given tuple while preserving the original order of elements. Args: value_in_tuple (Tu...
magic_instruct_75k
68,010
Write a Python function to process a dictionary containing stock symbols and their corresponding stock quotes. The function should return a new dictionary with the stock symbols as keys and their quotes converted to uppercase as values. The input dictionary will have stock symbols as keys and stock quotes as string val...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def process_quotes(quotes_dict: Dict[str, str]) -> Dict[str, str]: """ Processes a dictionary of stock symbols and their corresponding stock quotes, converting the quotes to uppercase. Args: ...
magic_instruct_75k
68,026
Write a Python function to filter out network interface names based on a predefined list of prefixes. The function should take a list of interface names as input and return a filtered list that excludes any interfaces with names starting with specific prefixes. The function should be efficient and handle various edge c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List IGNORE_INTERFACE_PREFIXES = ('lo', 'docker', 'br') def filter_interfaces(interface_names: List[str]) -> List[str]: """ Filters out network interface names based on a predefined list of prefixes. Ar...
magic_instruct_75k
68,038
Write a Python function to generate a specific log message based on the provided registry, appname, and metatag. The log message should follow the format "registry/appname:metatag exist." and return the resulting log message as a string. The function should handle any valid string inputs for registry, appname, and meta...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_log_message(registry: str, appname: str, metatag: str) -> str: """ Generates a log message based on the provided registry, appname, and metatag. The log message follows the format "registry/appname:metatag exis...
magic_instruct_75k
68,046
Write a Python function `count_imports(code_snippet: str) -> Tuple[int, int]` that takes a string `code_snippet` as input, representing a code snippet containing import statements, and returns a tuple containing the count of modules and packages being imported. For the purpose of this problem, consider a package as a d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def count_imports(code_snippet: str) -> Tuple[int, int]: """ Counts the number of modules and packages being imported in the given code snippet. Args: code_snippet (str): A string represent...
magic_instruct_75k
68,086
Write a Python function to filter out invalid SMS messages from a list of dictionaries. Each dictionary represents an SMS message and contains the following keys: 'source_addr_ton', 'source_addr_npi', 'source_addr', 'esme_addr_ton', 'esme_addr_npi', and 'esme_addr'. The function should return a new list containing only...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_valid_sms(sms_list: List[Dict]) -> List[Dict]: """ Filters out invalid SMS messages from a list of dictionaries. Args: sms_list (List[Dict]): A list of dictionaries, each re...
magic_instruct_75k
68,094
Write a Python function to calculate the total number of rows and columns across all files given a list of tuples. Each tuple contains a file name, the number of rows, and the number of columns in that file. The function should return a tuple with the total number of rows and columns. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_total_dimensions(file_dimensions: List[Tuple[str, int, int]]) -> Tuple[int, int]: """ Calculate the total number of rows and columns across all files given a list of tuples. Arg...
magic_instruct_75k
68,101
Write a Python function to count the number of good kids in a classroom for each day based on a list of strings representing the behavior of children. Each string consists of characters 'G' and 'V', where 'G' represents a good kid and 'V' represents a naughty kid. The function should return a list of integers represent...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_good_kids(behavior: List[str]) -> List[int]: """ Counts the number of good kids for each day based on the behavior list. Args: behavior (List[str]): A list of strings where each st...
magic_instruct_75k
68,119
Write a Python function to calculate the average decoding time for a series of images. The function will take in a list of image decoding times and return the average decoding time. The image decoding times are represented in milliseconds. The code should start with: ```python from typing import List def calculate_av...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average_decoding_time(image_decoding_times: List[int]) -> float: """ Calculate the average decoding time for a series of images. Args: image_decoding_times (List[int]): A list ...
magic_instruct_75k
68,124
Write a Python function to validate a given JSON object based on a set of predefined validation rules. The function should take in two parameters: `json_obj` (a JSON object to be validated) and `validation_rules` (a dictionary containing the validation rules). The validation rules specify the expected structure and con...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_json(json_obj: dict, validation_rules: dict) -> dict: """ Validates a given JSON object based on a set of predefined validation rules. Args: json_obj (dict): The JSON object to be validated. val...
magic_instruct_75k
68,139
Write a Python function to generate command-line commands for zipping specific files using the `cross-zip` tool. The function should take a version number as input and return the commands as strings. The files to be zipped follow the naming convention `dwebx-$VERSION-<platform>-x64`, where `<platform>` can be either `l...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_zip_commands(version: str) -> tuple: """ Generates command-line commands for zipping specific files using the `cross-zip` tool. Args: version (str): The version number to be used in the file names. ...
magic_instruct_75k
68,163
Write a Python function to calculate the sum of the squares of all integers from 0 to `res_r - 1` (inclusive). The function should use a loop to iterate over the range of values and compute the sum of squares. The function should be named `sumOfSquares` and should take an integer `res_r` as input, returning the compute...
Here is the Python code to solve the given problem in the markdown block: ```python def sumOfSquares(res_r: int) -> int: """ Calculate the sum of the squares of all integers from 0 to res_r - 1 (inclusive). Args: res_r (int): The upper limit (exclusive) for the range of integers. Returns: ...
magic_instruct_75k
68,214
Write a Python function to determine if at least one of the given OpenStreetMap bus route relations, represented by their respective z, x, and y coordinates, is present in the tiles up to zoom level 12. The function should return `True` if at least one of the given coordinates is present in the tiles up to zoom level 1...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def check_tiles_present(coords: List[Tuple[int, int, int]]) -> bool: """ Determines if at least one of the given OpenStreetMap bus route relations, represented by their respective z, x, and y coor...
magic_instruct_75k
68,242
Create a Python function to manage and control various lighting modes for a smart lighting system. The function should provide methods for switching between modes, activating specific modes, and transitioning between modes smoothly. The function should be designed to be modular and extensible for adding new modes in th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Callable def animation_manager(modes: Dict[str, Callable[[], None]]) -> Callable[[str], None]: """ Manages and controls various lighting modes for a smart lighting system. Args: modes (Dict...
magic_instruct_75k
68,277
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 max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be obtained by buying and selling a stock at most once. Args: prices (List[int]): A list of integers repre...
magic_instruct_75k
68,292
Write a Python function to generate file paths for raw and processed Digital Elevation Model (DEM) data based on given naming conventions and file types. The function should take in the output directory path and the name of the DEM data, and return a dictionary containing the file paths for the raw and processed DEM da...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_file_paths(path_out: str, DoD_name: str) -> dict: """ Generates file paths for raw and processed Digital Elevation Model (DEM) data based on the given naming conventions. Args: path_out (str): The outpu...
magic_instruct_75k
68,300
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should take a list of integers as input and return the sum of all the even numbers in the list. The function should be named `sum_of_even_numbers` and should adhere to the following signature: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(nums: List[int]) -> int: """ Calculate the sum of all even numbers in a given list of integers. Args: nums (List[int]): A list of integers from which to calculate the...
magic_instruct_75k
68,306
Write a Python function to check if the sum of weights of all self-loops in a directed graph, represented as an adjacency matrix, is zero. If the sum is zero, the function should return `True`; otherwise, it should return `False`. The code should start with: ```python from typing import List def check_self_loop_sum(a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_self_loop_sum(adj: List[List[int]]) -> bool: """ Check if the sum of weights of all self-loops in a directed graph is zero. Args: adj (List[List[int]]): The adjacency matrix of the...
magic_instruct_75k
68,307
Write a Python function to generate a ROS2 launch configuration for a specified node with given parameters and output settings. The function should take the name of the node, a YAML file containing parameters, and a boolean indicating whether to use simulation time. The function should return a string representing the ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_launch_config(node_name: str, yaml_file: str, use_sim_time: bool) -> str: """ Generates a ROS2 launch configuration for a specified node with given parameters and output settings. Args: node_name (str):...
magic_instruct_75k
68,318
Write a Python function to parse command-line arguments for a simulation program that accepts both Lua script options and non-Lua test options. The function should differentiate between these two types of options and store the values accordingly. The command-line arguments are provided as a list of strings. The functi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def parse_command_line_args(args: List[str]) -> Dict[str, Union[str, int, float, bool]]: """ Parses command-line arguments for a simulation program that accepts both Lua script options and n...
magic_instruct_75k
68,329
Write a Python function to generate file names for saving and loading numpy arrays based on specific parameters. The file names should follow a predefined pattern that includes the quantum bit dimension, relative error, rank, ansatz type, and channel number. The function should handle both lower and upper bound data. ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_file_name(qdim: int, error: float, rank: int, an: str, any_chan_no: int, lower_bound: bool = True) -> str: """ Generates a file name for saving or loading numpy arrays based on the given parameters. Args: ...
magic_instruct_75k
68,336
Write a Python function to generate endpoint paths for accessing and managing cancellation complaints in a procurement management system. The function should take three parameters: `tender_id`, `cancellation_id`, and `complaint_id`, and return the collection path and the specific complaint path based on these parameter...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_complaint_paths(tender_id: str, cancellation_id: str, complaint_id: str) -> tuple: """ Generates the endpoint paths for accessing and managing cancellation complaints. Args: tender_id (str): The unique ...
magic_instruct_75k
68,346
Create a Python function to simulate the process of updating software packages on a Linux system using the `apt` package manager. The function should simulate the steps of updating the package repository and upgrading the installed packages. Additionally, the function should include error handling to simulate capturing...
Here is the Python code to solve the given problem in the markdown block: ```python import random def simulate_system_update() -> None: """ Simulates the process of updating software packages on a Linux system using the `apt` package manager. This function simulates the steps of updating the package repos...
magic_instruct_75k
68,359
Write a Python function to generate a mapping of worker server IDs to their corresponding network addresses based on a predefined configuration. The configuration consists of the bind address and port for the load balancer and the number of worker servers available. The network addresses should be generated by incremen...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_worker_addresses(bind: str, workers: int) -> dict: """ Generates a mapping of worker server IDs to their corresponding network addresses. The network addresses are generated by incrementing the port number star...
magic_instruct_75k
68,375
Write a Python function to simulate a chatbot called SkyViewBot that processes command-line arguments and executes the chatbot program. The function should correctly handle the command-line arguments and ensure the program runs without any issues. The code should start with: ```python import sys def main(args): ```
Here is the Python code to solve the given problem in the markdown block: ```python import sys def main(args): """ Simulates a chatbot called SkyViewBot that processes command-line arguments and executes the chatbot program. Args: args (list): A list of command-line arguments. Returns: ...
magic_instruct_75k
68,379
Write a Python function to simulate a simplified version of a web page testing scenario. The function should take a list of actions as input and perform them sequentially. Each action can be one of the following types: 1. Click on a hyperlink using its XPath. 2. Click on an element with a specific ID. 3. Check if the c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union, Tuple def test_webpage(actions: List[Union[Tuple[str, str], str]]) -> int: """ Simulate a web page testing scenario by performing a list of actions and counting the occurrences of a keyword in th...
magic_instruct_75k
68,392
Write a Python function to merge overlapping intervals in a list of intervals. Each interval is represented as a tuple of two integers, where the first integer is the start of the interval and the second integer is the end of the interval. The function should return a list of merged intervals. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def merge_intervals(intervals: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Merge overlapping intervals in a list of intervals. Args: intervals (List[Tuple[int, int]]): A list...
magic_instruct_75k
68,394
Write a Python function to compute the histogram of a given list of integers. The histogram should be represented as a dictionary where the keys are the unique integers from the input list and the values are the frequencies of those integers in the input list. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def get_hist(lst: List[int]) -> Dict[int, int]: """ Computes the histogram of a given list of integers. Args: lst (List[int]): The list of integers from which to compute the histogram....
magic_instruct_75k
68,404
Create a Python class `Map` that simulates a simple game map for a bomberman-style game. The map is represented as a grid of cells, each of which can be either empty or contain an obstacle. The class should provide methods to place obstacles, check if a cell is empty, and print the map. The class should also include a ...
Here is the Python code to solve the given problem in the markdown block: ```python class Map: def __init__(self, rows, cols): """ Initialize the map with the specified number of rows and columns. Args: rows (int): The number of rows in the map. cols (int): T...
magic_instruct_75k
68,405
Write a Python function `extract_network_info` that takes a DHCP server range row represented as a dictionary and extracts the relevant network information such as netmask, broadcast address, and prefix length. The function should return a dictionary containing the extracted information. The keys of the returned dictio...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_network_info(DHCPSrv_Range_row): """ Extracts the netmask, broadcast address, and prefix length from a DHCP server range row. Args: DHCPSrv_Range_row (dict): A dictionary representing the DHCP server ran...
magic_instruct_75k
68,406
Write a Python function to create a dictionary that maps each filename to its parent directory. The function should take a list of filenames and a parent directory as input and return a dictionary where each key is a filename and each value is the parent directory. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def populate_file_dict(filenames: List[str], parent_dir: str) -> Dict[str, str]: """ Populates a dictionary with filenames as keys and their parent directory as values. Args: filenames...
magic_instruct_75k
68,450
Write a Python function to automate the process of adding an SSH key to the SSH agent if the key file exists and the SSH agent is not already running. The function should check for the existence of the key file, start the SSH agent if it's not already running, and then add the key to the agent. The function should hand...
Here is the Python code to solve the given problem in the markdown block: ```python import os import subprocess def add_ssh_key_to_agent(key_file_path: str) -> None: """ Automates the process of adding an SSH key to the SSH agent if the key file exists and the SSH agent is not already running. Args: ...
magic_instruct_75k
68,487
Write a Python function to simulate the behavior of the given Bash script. The function should take in several input arguments and perform validation checks before proceeding to start a "workload container" using the provided input arguments. If the `IMAGE_NAME` is not provided, the function should use `'image.jpeg'` b...
Here is the Python code to solve the given problem in the markdown block: ```python def start_workload_container(SERVER_PORT: int, DB_SERVER_IP: str, DB_PORT: int, DB_NAME: str, CPU_COUNT: int, IMAGE_NAME: str = None) -> None: """ Simulates starting a workload container using the provided input arguments. ...
magic_instruct_75k
68,495
Write a Python function to simulate a simplified file management system. The function should take a list of file paths and a list of commands as input and perform the specified operations on the files. The function should support the following commands: - `cd <directory>`: Change the current directory to the specified ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def file_manager(file_paths: List[str], commands: List[str]) -> List[str]: """ Simulates a simplified file management system. Args: file_paths (List[str]): A list of file paths. comm...
magic_instruct_75k
68,512
Write a Python function to manage a process monitoring system. The function should take a list of process IDs (PIDs) as input and terminate each process using the `os.kill` function with the signal `signal.SIGKILL`. After terminating all the processes, the function should print "Done" to indicate the completion of the ...
Here is the Python code to solve the given problem in the markdown block: ```python import os import signal from typing import List def terminate_processes(pids: List[int]) -> None: """ Terminates a list of processes specified by their PIDs using the `os.kill` function with the `signal.SIGKILL` signal. Aft...
magic_instruct_75k
68,529
Write a Python function to retrieve the time ID based on the given data and configuration. The function should be named `get_time_id` and should take two parameters: 1. `data`: A list of integers representing time data points. 2. `config`: A dictionary containing configuration settings. The function should return the ...
Here is the Python code to solve the given problem in the markdown block: ```python def get_time_id(data, config): """ Retrieve the time ID based on the given data and configuration. Args: data (list): A list of integers representing time data points. config (dict): A dictionary containing ...
magic_instruct_75k
68,553
Write a Python function `route_request(url: str) -> str` that takes a URL as input and returns the name of the view function associated with that URL. If the URL does not match any of the defined paths, the function should return "Not Found". The defined paths and their associated view functions are as follows: - '/se...
Here is the Python code to solve the given problem in the markdown block: ```python def route_request(url: str) -> str: """ Maps an incoming URL to its corresponding view function name. Args: url (str): The URL to be mapped. Returns: str: The name of the view function associated with t...