source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
55,964
Write a Python function to update a dictionary of hyperparameters based on a list of new hyperparameter values. The hyperparameters are stored in a dictionary called `hyperparameters`, where the keys are the hyperparameter names and the values are their corresponding values. The function should take in the `hyperparame...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def update_hyperparameters(hyperparameters: Dict[str, float], new_hyperparameters: List[Tuple[str, float]]) -> Dict[str, float]: """ Updates the hyperparameters dictionary with new hyperpara...
magic_instruct_75k
55,988
Write a Python function to determine the longest common prefix among a set of strings. Given an array of strings, the function should find the longest common prefix string amongst its elements. If there is no common prefix, the function should return an empty string `""`. The code should start with: ```python from typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def longest_common_prefix(strs: List[str]) -> str: """ Determine the longest common prefix among a set of strings. Args: strs (List[str]): A list of strings to find the longest common prefix...
magic_instruct_75k
55,990
Write a Python function to count the number of unique integers in a given list. The function should take a list of integers as input and return the count of unique integers in the list. The code should start with: ```python from typing import List def count_unique_integers(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_unique_integers(arr: List[int]) -> int: """ Counts the number of unique integers in a given list. Args: arr (List[int]): The list of integers from which to count unique integers. ...
magic_instruct_75k
56,001
Write a Python function to simulate a test scenario for a software application. The function will take in three lists of integers representing the lengths of different types of data, and an optional parameter for the number of iterations. The function will then perform a series of tests based on the input data and retu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def test(firsts: List[int], others: List[int], pool: List[int], iters: int = 1000) -> int: """ Simulates a test scenario for a software application by performing a series of iterations. ...
magic_instruct_75k
56,002
Write a Python function to convert a given number of seconds into a human-readable format of days, hours, minutes, and remaining seconds. The function should take an integer representing the number of seconds as input and return a string representing the time in the format "X days, Y hours, Z minutes, W seconds". The ...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_seconds_to_readable_time(seconds: int) -> str: """ Convert a given number of seconds into a human-readable format of days, hours, minutes, and remaining seconds. Args: seconds (int): The number of second...
magic_instruct_75k
56,006
Write a Python function to calculate the Euclidean distance between two points in a 2D image represented as a list of lists. The points are given as tuples of (x, y) coordinates within the image. The function should take the image and the two points as inputs and return the Euclidean distance between the points. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def calculate_distance(image: List[List[int]], point1: Tuple[int, int], point2: Tuple[int, int]) -> float: """ Calculate the Euclidean distance between two points in a 2D image. A...
magic_instruct_75k
56,048
Write a Python function to validate a dictionary representing a connection configuration against a predefined schema. The schema defines the required and optional connection arguments along with their respective types. The function should check whether the given connection configuration dictionary conforms to the speci...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def validate_connection_config(config: Dict[str, Any], schema: Dict[str, Dict[str, type]]) -> bool: """ Validates a connection configuration dictionary against a predefined schema. Args: ...
magic_instruct_75k
56,077
Write a Python function to convert the keys of a given dictionary from snake_case to camelCase. In snake_case, words are separated by underscores, while in camelCase, the first word is all lowercase and subsequent words have their first letter capitalized and no spaces or underscores between them. For example, "chat_ty...
Here is the Python code to solve the given problem in the markdown block: ```python def snake_to_camel(input_dict: dict) -> dict: """ Converts the keys of a given dictionary from snake_case to camelCase. Args: input_dict (dict): The dictionary with snake_case keys to be converted. Returns: ...
magic_instruct_75k
56,094
Write a Python function `data_picker` that implements a decision-making algorithm based on the signal-to-noise ratio (SNR) and confidence probability from two data sources, `par1` and `par2`. The function should return the index of the chosen data source (0 for `par1`, 1 for `par2`) based on the provided conditions. If...
Here is the Python code to solve the given problem in the markdown block: ```python def data_picker(par1: dict, par2: dict, conf_thresh: float) -> int: """ Decides which data source to pick based on the signal-to-noise ratio (SNR) and confidence probability. Args: par1 (dict): A dictionary represen...
magic_instruct_75k
56,111
Write a Python function to convert a hexadecimal color code to its corresponding RGB values. The function should take a string representing the hexadecimal color code as input and return a list of three floating-point numbers representing the RGB values. The hexadecimal color code can be in the form "#RRGGBB" or "RRGGB...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hex_to_rgb(hex_code: str) -> List[float]: """ Converts a hexadecimal color code to its corresponding RGB values. Args: hex_code (str): A string representing the hexadecimal color code. I...
magic_instruct_75k
56,122
Write a Python function to simulate an asynchronous task that fetches data from a remote server and processes the received data. The function should use a mock asynchronous function `run()` that returns a `Future` object. The `Future` object will either contain the fetched data or an error message. Your task is to hand...
Here is the Python code to solve the given problem in the markdown block: ```python from concurrent.futures import Future from typing import Union def run() -> Future: """ Mock asynchronous function that simulates fetching data from a remote server. Returns a Future object that will either contain the fetc...
magic_instruct_75k
56,129
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock on different days. You are given a list of integers representing the daily stock prices of a company. You can only make one transaction (i.e., buy one and sell one share of the stock), and you must buy before you ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(stock_prices: List[int]) -> int: """ Calculate the maximum profit that can be obtained by buying and selling a stock on different days. Args: stock_prices (List[int]): A list ...
magic_instruct_75k
56,142
Write a Python function to parse command-line arguments and extract the values for the `--profile-dir` and `--ext` options. The function should return a dictionary containing the extracted values. The function should handle the following: - The `--profile-dir` option specifies the directory for profile settings. - The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def parse_command_line_args(args: List[str]) -> Dict[str, str]: """ Parses command-line arguments and extracts the values for the `--profile-dir` and `--ext` options. Args: args (List[...
magic_instruct_75k
56,157
Implement a caching mechanism for a function that checks if a given Java class is assignable from another class. The function should utilize a cache to store and retrieve previously computed results to improve performance. The cache is represented as a dictionary `__assignable_from_cache` with keys being tuples of `(jc...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple # Initialize the cache as a dictionary __assignable_from_cache: Dict[Tuple[str, str], bool] = {} def is_assignable_from(jc_classname: str, classname: str) -> bool: """ Check if a Java class `jc_c...
magic_instruct_75k
56,177
Write a Python function to simulate a simplified version of a database migration system. The function should take a list of migration operations and apply them to a database schema. Each migration operation is represented as a tuple containing the model name, the operation type, and the field name (if applicable). The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict, Optional def apply_migrations(migrations: List[Tuple[str, str, Optional[str]]], initial_schema: Dict[str, List[str]]) -> Dict[str, List[str]]: """ Simulates a simplified database migration ...
magic_instruct_75k
56,181
Implement a tag matching system for XML serializers in Python. The system should compare attributes and tags of XML elements to determine if they match. Attributes are considered matching if their lowercase representations are equal. Tags are considered matching if their lowercase representations, after stripping leadi...
Here is the Python code to solve the given problem in the markdown block: ```python def lower_dict(attributes: dict) -> dict: """ Convert all keys and values in the dictionary to lowercase. Args: attributes (dict): A dictionary of attributes. Returns: dict: A new dictionary with all ke...
magic_instruct_75k
56,198
Write a Python function to calculate the sum of all the replacement codes in a given list of replacement code values. Replacement codes are used in computer graphics to specify a particular action to be taken during rendering. The replacement codes are represented as integers. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_sum_of_replacement_codes(replacement_codes: List[int]) -> int: """ Calculate the sum of all replacement codes in a given list. Args: replacement_codes (List[int]): A list of in...
magic_instruct_75k
56,237
Write a Python function to simulate a simple game environment and return the initial state of the game after resetting the environment using a given seed value. The game environment should be initialized with the seed to ensure reproducibility. The function should start with: ```python from typing import Any def get_i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any class GameEnvironment: """ A simple game environment class that simulates a game state. """ def __init__(self): self.state = None def seed(self, seed_value: int): """ ...
magic_instruct_75k
56,240
Write a Python function to evaluate and execute a list of instructions for a specific property. Each instruction modifies the property value based on the operation specified (Add, Subtract, Multiply, Divide). The function should start with: ```python from typing import List, Tuple def execute_property_instructions(ini...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def execute_property_instructions(initial_value: float, instructions: List[Tuple[str, float]]) -> float: """ Executes a list of instructions on a property value and returns the final value. A...
magic_instruct_75k
56,294
Write a Python function to group model names by their feature dimensions from a given dictionary. The input dictionary maps model names to their respective feature dimensions. The function should return a new dictionary where the keys are the feature dimensions and the values are lists of model names that have the corr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def group_models_by_dimension(model_dimensions: Dict[str, int]) -> Dict[int, List[str]]: """ Groups model names by their feature dimensions from a given dictionary. Args: model_dimensi...
magic_instruct_75k
56,311
Write a Python function to simulate a simple decoder for a communication system. The decoder takes a list of integers as input and produces an output based on a specific algorithm. The algorithm involves iterating through each integer in the input list and modifying it according to the following rules: 1. If the intege...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def decode_transfer_values(transfer_values_input: List[int]) -> List[int]: """ Decodes a list of transfer values according to a specific algorithm. The algorithm modifies each transfer value as foll...
magic_instruct_75k
56,318
Write a Python function to calculate the total reward obtained by all actors in a reinforcement learning environment, considering a default reward for any missing rewards. The environment is represented by a class with a method for retrieving the reward of a specific actor. If the reward for a particular actor is not a...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_total_reward(environment, default_reward): """ Calculate the total reward obtained by all actors in the reinforcement learning environment. Args: environment (ReinforcementEnvironment): An instance of ...
magic_instruct_75k
56,338
Write a Python function to process a list of flag action properties and perform specific operations based on the properties provided. Each flag action property consists of a key-value pair representing a specific action and its corresponding properties. The possible actions are: 1. `enable_feature`: Indicates that a fe...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def processFlagActions(flagActions: List[Dict[str, Union[str, int]]]) -> Dict[str, Union[str, int]]: """ Processes a list of flag action properties and performs specific operations based on ...
magic_instruct_75k
56,355
Create a Python class `CookieManager` that manages three types of cookies: `LOGOUT`, `REFRESH`, and `SESSION`. The class should provide methods for adding, removing, and retrieving cookies. The class should be implemented according to the following specifications: - The class should have a constructor that initializes ...
Here is the Python code to solve the given problem in the markdown block: ```python class CookieManager: """ A class to manage three types of cookies: LOGOUT, REFRESH, and SESSION. Attributes: cookies (dict): A dictionary to store the cookies. Methods: add_cookie(type, value): Adds a c...
magic_instruct_75k
56,373
Write a Python function to retrieve the name of a system group based on its group ID. The system has a predefined set of group IDs and their corresponding group names. The function should take an integer `groupid` as input and return the corresponding group name as a string. If the provided `groupid` does not match any...
Here is the Python code to solve the given problem in the markdown block: ```python def system_groupname_from_groupid(groupid: int) -> str: """ Retrieves the name of a system group based on its group ID. Args: groupid (int): The group ID to look up. Returns: str: The corresponding grou...
magic_instruct_75k
56,384
Write a Python function `final_position(movements: List[Tuple[str, int]]) -> Tuple[int, int]` that takes in a list of movement instructions and returns the final position after executing all the movements. The movement instructions are represented as tuples, where the first element is the direction ("U" for up, "D" for...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def final_position(movements: List[Tuple[str, int]]) -> Tuple[int, int]: """ Calculate the final position after executing a series of movement instructions in a 2D grid. Args: movemen...
magic_instruct_75k
56,388
Write a Python function to calculate the average of a list of numbers, excluding the minimum and maximum values from the calculation. The function should handle lists with at least three elements and return the average of the remaining numbers. If the list contains fewer than three elements, the function should raise a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average(numbers: List[float]) -> float: """ Calculate the average of a list of numbers, excluding the minimum and maximum values. Args: numbers (List[float]): A list of numbers...
magic_instruct_75k
56,413
Write a Python function to calculate the next number in a sequence based on the last two numbers in the given list. The function should take a list of integers as input and return the sum of the second-to-last and last elements of the list. The code should start with: ```python from typing import List def calcFi(nums...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calcFi(nums: List[int]) -> int: """ Calculate the next number in a sequence based on the last two numbers in the given list. Args: nums (List[int]): A list of integers representing the s...
magic_instruct_75k
56,459
Write a Python function to extract the author's name and email from a given code snippet of a Python package setup file. The code snippet is a string that contains metadata about the package, including the author's name and email enclosed within angle brackets. The function should return a dictionary with keys 'author'...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_author_info(code: str) -> dict: """ Extracts the author's name and email from a given code snippet of a Python package setup file. Args: code (str): The code snippet containing metadata about ...
magic_instruct_75k
56,482
Write a Python function to simulate the behavior of a Django middleware that checks if the application is running on a Heroku server and redirects the request to a specified domain if certain conditions are met. The function should take three parameters: `request`, `heroku_app`, and `heroku_domain`. The `request` param...
Here is the Python code to solve the given problem in the markdown block: ```python def perform_redirect(request: dict, heroku_app: str, heroku_domain: str) -> str: """ Simulates the behavior of a Django middleware that checks if the application is running on a Heroku server and redirects the request to a speci...
magic_instruct_75k
56,527
Write a Python function to extract specific attributes from an HTML button element and return them in a dictionary format. The attributes to be extracted are `id`, `class`, `name`, `type`, and `value`. The input string will be a well-formed HTML button element containing at least one of the specified attributes. The f...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_button_attributes(html_button: str) -> dict: """ Extracts specific attributes from an HTML button element and returns them in a dictionary format. Args: html_button (str): A string representin...
magic_instruct_75k
56,545
Write a Python function to determine whether a given value `val` is within a specified percentage range of a base value `base`. The percentage range is defined as the base value plus or minus a certain percentage of the absolute value of the base. The function should return `True` if `val` is within the specified perce...
Here is the Python code to solve the given problem in the markdown block: ```python def is_within_percentage_range(val: float, base: float, percentage: float) -> bool: """ Determines whether a given value `val` is within a specified percentage range of a base value `base`. Args: val (float): The va...
magic_instruct_75k
56,548
Write a Python function to find all indices of a target element in a given list. The function should be case-sensitive and consider exact matches only. The function should return a list of indices where the target element is found. If the target element is not found in the list, the function should return an empty list...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def find_element_indices(input_list: List[Any], target_element: Any) -> List[int]: """ Find all indices of a target element in a given list. Args: input_list (List[Any]): A list of elem...
magic_instruct_75k
56,555
Write a Python function to halve the counts of items in a list of tuples. Each tuple in the list contains a unit and its corresponding count. The function should return a new list of tuples where each count is halved. If the count is an odd number, the function should round down to the nearest integer. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def halve_counts(unit_counts: List[Tuple[str, int]]) -> List[Tuple[str, int]]: """ Halves the counts of items in a list of tuples. Args: unit_counts (List[Tuple[str, int]]): A list of...
magic_instruct_75k
56,557
Write a Python function to count the occurrences of specific mathematical operators in a given string representing a mathematical expression. The function should return a dictionary with the count of each operator present in the expression. The operators to be considered are addition (`+`), subtraction (`-`), multiplic...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_operators(expression: str) -> Dict[str, int]: """ Counts the occurrences of specific mathematical operators in a given expression. Args: expression (str): A string representing a m...
magic_instruct_75k
56,588
Write a Python function `generate_format_summary(formats)` that processes a list of format objects and generates a summary report. Each format object contains attributes such as `channel_order` (an integer) and `channel_data_type` (a string). The summary report should include the channel order, channel data type, and t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_format_summary(formats: List[Dict[str, any]]) -> str: """ Generates a summary report of image formats based on their channel order and channel data type. Args: formats (Li...
magic_instruct_75k
56,594
Write a Python function to sanitize a list of closed paths. A closed path is represented as a list of points, where the first and last points are the same, forming a closed loop. The function should remove any invalid closed paths from the list and return the sanitized list. The function signature is: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sanitize_invalid_closed_paths(paths: List[List[Tuple[int, int]]]) -> List[List[Tuple[int, int]]]: """ Sanitize a list of closed paths by removing any invalid paths. A valid closed path is...
magic_instruct_75k
56,596
Write a Python function to filter a list of strings and return a new list containing only those strings that are numeric and have a length of 1. If the input list is empty or contains no such strings, the function should return an empty list. The code should start with: ```python from typing import List def filter_nu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_numeric_strings(input_list: List[str]) -> List[str]: """ Filters a list of strings and returns a new list containing only the numeric strings of length 1. Args: input_list (List[s...
magic_instruct_75k
56,600
Write a Python function `generate_whitelist` that takes two lists as input: one list of usernames and another list of permissions. The function should return a dictionary where the keys are the usernames and the values are the corresponding permissions. If the lengths of the two lists are not equal, the function should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_whitelist(users: List[str], permissions: List[str]) -> Dict[str, str]: """ Generates a whitelist dictionary from two lists: one of usernames and one of permissions. Args: ...
magic_instruct_75k
56,604
Write a Python function to extract the GitHub stars range and the package description from a given code snippet. The code snippet is in a specific format and contains placeholders that need to be replaced with actual values. The function should parse the code snippet and extract the information as per the given format....
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import Dict def extract_info_from_snippet(code_snippet: str) -> Dict[str, str]: """ Extracts the GitHub stars range and the package description from a given code snippet. Args: code_snippet (s...
magic_instruct_75k
56,611
Write a Python function to simulate the execution of the given bash script tasks. The function should: 1. Execute a command to check the BOSH version. 2. Print a message indicating the start of the CPI BOSH release creation. 3. Execute a command to create a CPI BOSH release with a specified release name. 4. Handle any ...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def create_cpi_bosh_release(cpi_release_name: str) -> None: """ Simulates the execution of a bash script to check the BOSH version and create a CPI BOSH release. Args: cpi_release_name (str): The ...
magic_instruct_75k
56,616
Write a Python function to calculate the quantity of items to be requested for a material request based on the available stock and purchase order box quantity. The function should create a material request document with the necessary attributes and return it. The function should start with: ```python def calculate_mat...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_material_request_qty(doc, i, stock): """ Calculate the quantity of items to be requested for a material request based on the available stock and purchase order box quantity. Args: doc (dict): A diction...
magic_instruct_75k
56,639
Write a Python function to extract the repository names from a list of Git clone commands. Each command is a string that follows the format "git clone https://github.com/{username}/{repository}.git". The repository name is the last segment of the URL after the last forward slash ("/") and before the ".git" extension. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def extract_repo_name(git_commands: List[str]) -> List[str]: """ Extracts the repository names from a list of Git clone commands. Args: git_commands (List[str]): A list of Git clone commands...
magic_instruct_75k
56,646
Write a Python function to check for missing keys in a dictionary based on specific conditions. The function should take in two parameters: a dictionary `pd_keys` and a string `key`. The function should return `True` if the `key` is missing from the `pd_keys` dictionary based on the following conditions: 1. If the `key...
Here is the Python code to solve the given problem in the markdown block: ```python def check_missing_key(pd_keys: dict, key: str) -> bool: """ Checks if a key is missing in the dictionary based on specific conditions. Args: pd_keys (dict): The dictionary containing keys to be checked. key ...
magic_instruct_75k
56,651
Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should efficiently compute the maximum sum using an optimal algorithm. The code should start with: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within the given list of integers. Args: nums (List[int]): A list of integers from which to fi...
magic_instruct_75k
56,659
Write a Python function to format pending targets for rendering on a new surface. The function should take a list of pending targets and a new surface as input parameters. For each target in the pending list, create a response containing the target's details and its status on the new surface. The response should be for...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def format_targets(pending: List[str], newSurface: List[str]) -> List[Dict[str, str]]: """ Formats pending targets for rendering on a new surface. Args: pending (List[str]): A list of ...
magic_instruct_75k
56,684
Write a Python function to parse and interpret a series of x86-64 assembly instructions. The function should extract the operations being performed, the registers involved, and the memory addresses being accessed. The function should return a list of tuples, where each tuple contains the operation and the operands of t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re def parse_assembly_instructions(assembly_code: str) -> List[Tuple[str, str]]: """ Parses and interprets a series of x86-64 assembly instructions. Args: assembly_code (str): ...
magic_instruct_75k
56,698
Write a Python script that automates the publication of a dataset and an algorithm asset using a command-line interface (CLI) tool. The script should capture the unique identifier (DID) generated for the dataset asset and store it in a variable for later use. The CLI tool provides the following commands and options: -...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def publish_assets(): """ Automates the publication of a dataset and an algorithm asset using a CLI tool. Captures the unique identifier (DID) generated for the dataset asset and stores it in a variable. ...
magic_instruct_75k
56,709
Write a Python function to generate an HTML navigation menu based on the provided data and current URL. The function should take the current URL and a list of menu items as input and return the HTML code for the navigation menu with the appropriate styling based on the current URL. The active link should have the class...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_navigation_menu(current_url: str, menu_items: List[Tuple[str, str]]) -> str: """ Generates an HTML navigation menu based on the provided current URL and menu items. Args: ...
magic_instruct_75k
56,711
Write a Python function to modify a list of variable names according to the following rules: 1. Convert all variable names to lowercase. 2. Remove any leading or trailing whitespace from the variable names. 3. Replace any occurrences of the string "DELTA" with "delta". The function should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def modify_variable_names(variables: List[str]) -> List[str]: """ Modify a list of variable names by converting them to lowercase, removing leading and trailing whitespace, and replacing any occurren...
magic_instruct_75k
56,713
Write a Bash script that constructs a URL by concatenating the values of two variables, `$ENDPOINT` and `$DATASET`, and then displays the constructed URL followed by a blank line and the value of a JSON string stored in the variable `$json`. The script should start with: ```bash #!/bin/bash # Define variables ENDPOIN...
Here is the Python code to solve the given problem in the markdown block: ```bash #!/bin/bash # Define variables ENDPOINT="https://api.example.com" DATASET="data123" json='{"key1": "value1", "key2": "value2"}' # Construct URL url="$ENDPOINT/$DATASET" # Display output echo "$url" echo echo "$json" ```
magic_instruct_75k
56,717
Write a Python function to reverse a singly linked list in place and return the new head of the reversed list. The function should handle edge cases such as an empty list or a list with a single node. The code should start with: ```python class ListNode: def __init__(self, value=0, next=None): self.value =...
Here is the Python code to solve the given problem in the markdown block: ```python class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def reverse_linked_list(head: ListNode) -> ListNode: """ Reverses a singly linked list in place and returns the new...
magic_instruct_75k
56,726
Write a Python function to parse and extract information from an HTTP request line. The HTTP request line has the following format: ``` METHOD URI HTTP_VERSION ``` Where: - **METHOD**: The HTTP method used in the request (e.g., GET, POST, PUT, DELETE). - **URI**: The Uniform Resource Identifier specifying the resource ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def parse_http_request(request_line: str) -> Dict[str, str]: """ Parses an HTTP request line and returns a dictionary containing the METHOD, URI, and HTTP_VERSION. Args: request_line (str): ...
magic_instruct_75k
56,769
Write a Python function to process a list of tuples containing HTML tag names and their corresponding descriptions. The function should extract the tag names and descriptions, then construct and return a dictionary where the tag names are the keys and the descriptions are the values. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_tag_dictionary(tag_data: List[Tuple[str, str]]) -> Dict[str, str]: """ Converts a list of tuples containing HTML tag names and their descriptions into a dictionary. Args: ...
magic_instruct_75k
56,790
Write a Python function to extract and return a sorted list of unique index names from a list of dictionaries. Each dictionary in the list contains a key "name" representing the index name. The function should filter out any duplicate index names and return the unique names in a sorted list. The code should start with...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def get_unique_index_names(indexes: List[Dict[str, str]]) -> List[str]: """ Extracts and returns a sorted list of unique index names from a list of dictionaries. Args: indexes (List[Di...
magic_instruct_75k
56,793
Write a Python function to validate and process semantic version numbers. Semantic versioning is a widely-used format for versioning software releases, consisting of three numeric components: major, minor, and patch, separated by periods (e.g., 1.2.3). Your function should perform the following tasks: 1. Validate that...
Here is the Python code to solve the given problem in the markdown block: ```python import re def parse_semantic_version(version: str) -> tuple: """ Validates and processes a semantic version number. Args: version (str): The semantic version number to validate and process. Returns: tu...
magic_instruct_75k
56,798
Create a Python class `MemoryManager` that simulates a simple memory management system. The class should manage memory allocations and deallocations to prevent memory leaks and ensure efficient memory usage. The class should have the following functionalities: 1. `allocate(size: int) -> int`: A method that allocates a...
Here is the Python code to solve the given problem in the markdown block: ```python class MemoryManager: def __init__(self, total_memory: int): """ Initialize the MemoryManager with a given total memory size. Args: total_memory (int): The total size of memory available. ...
magic_instruct_75k
56,805
Write a Python function to serialize a set of Unicode characters into a custom data structure. The function `serialize_unicode_set` takes in a list of Unicode characters `src` and returns a dictionary representing the serialized set. The dictionary should have two keys: `data` (a list of integers representing the seria...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def serialize_unicode_set(src: List[int]) -> Dict[str, List[int]]: """ Serialize a set of Unicode characters into a custom data structure. Args: src (List[int]): A list of Unicode char...
magic_instruct_75k
56,838
Create a Python class `CustomIterator` that implements a custom iterator to iterate over a sequence of numbers and return the square of each number. The iterator should have a method to toggle the output format between integers and strings. The class should have the following functionalities: 1. Initialize the iterator...
Here is the Python code to solve the given problem in the markdown block: ```python class CustomIterator: """ A custom iterator class that iterates over a sequence of numbers and returns the square of each number. The output format can be toggled between integers and strings. Args: numbers (lis...
magic_instruct_75k
56,859
Create a Python class `ElectricityMonitor` that simulates a simple online electricity consumption monitoring system. The class should be able to track the electricity consumption of different households and provide functionality to calculate the total electricity consumption for a specific time period. The class should...
Here is the Python code to solve the given problem in the markdown block: ```python class ElectricityMonitor: def __init__(self): """ Initializes an empty dictionary to store the electricity consumption data for different households. """ self.household_consumption = {} def add_h...
magic_instruct_75k
56,864
Write a Python function to parse a list of command-line arguments into a dictionary of options and their corresponding values. The command-line arguments are provided in the form of double-dash options followed by optional values. Each option may or may not have a value associated with it. The options and values are se...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Optional def parseCommandLineArgs(args: List[str]) -> Dict[str, Optional[str]]: """ Parses a list of command-line arguments into a dictionary of options and their corresponding values. Args: ...
magic_instruct_75k
56,933
Write a Python function to dynamically generate a GUI layout code snippet for adding buttons to a sizer using the wxPython library. The function should take a list of tuples as input, where each tuple contains the button name and its position in the sizer. The function should return a string representing the code snipp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_button_code(buttons: List[Tuple[str, Tuple[int, int]]]) -> str: """ Generates a code snippet for adding buttons to a wxPython sizer with specified positions and flags. Args: ...
magic_instruct_75k
56,946
Write a Python function to validate and set a feedback value for a stereo universal fixed delay line filter. The feedback value must be within the range of -1 to 1 to prevent divergence. If the feedback value is outside this range, the function should raise a `ValueError` with the message "Feedback must be between -1 a...
Here is the Python code to solve the given problem in the markdown block: ```python def set_feedback_ch2_ch1(feedback: float) -> None: """ Sets the feedback value for the right channel (ch2) based on the left channel's (ch1) input. The feedback value must be within the range of -1 to 1 to prevent divergence...
magic_instruct_75k
56,961
Write a Python function to extract and return a list of unique elements from a given list of integers, preserving the original order of their first occurrence. The function should not use any built-in Python functions or libraries for this task. The function signature should be: ```python from typing import List def g...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_unique_elements(input_list: List[int]) -> List[int]: """ Extracts and returns a list of unique elements from the input list, preserving the original order of their first occurrence. Args: ...
magic_instruct_75k
56,968
Create a Python decorator `log_arguments_and_return` that logs the arguments and return value of a function. The decorator should be applied to a function `add` that takes two arguments `a` and `b` and returns their sum. The decorated function should be called with arguments `3` and `5`, and the logs should be printed ...
Here is the Python code to solve the given problem in the markdown block: ```python def log_arguments_and_return(func): """ Decorator to log the arguments and return value of a function. Args: func (function): The function to be decorated. Returns: function: The decorated function. ...
magic_instruct_75k
56,973
Write a Python function to update a dictionary of model parameters with additional hyperparameters provided as keyword arguments. The function should merge the hyperparameters into the existing model parameters and return the updated dictionary. The code should start with: ```python from typing import Dict def update...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def update_model_params(model_params: Dict, **kwargs) -> Dict: """ Updates the model parameters dictionary with the provided hyperparameters. Args: model_params (Dict): A dictionary containi...
magic_instruct_75k
56,982
Implement a Python class `PlaceholderSystem` that simulates a simple placeholder system for a text processing application. The class should have the following methods: 1. A constructor `__init__` that initializes the placeholder value to an empty string. 2. A method `set_placeholder` that takes a string as input and se...
Here is the Python code to solve the given problem in the markdown block: ```python class PlaceholderSystem: """ A class to simulate a simple placeholder system for a text processing application. Attributes: placeholder (str): The current placeholder value, initialized to an empty string. Meth...
magic_instruct_75k
56,995
Write a Python function to retrieve the display name of a status code from a predefined list of status tuples. If the status code is not found in the list, the function should return "Unknown". The function should be efficient and handle a potentially large number of status tuples. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple STATUSES: List[Tuple[str, str]] = [ ('active', 'Active'), ('failed', 'Failed'), # ... more status tuples may be added ] def get_status_display(status_code: str) -> str: """ Retrieve t...
magic_instruct_75k
57,004
Write a Python function `find_nested_ids(ind, id)` that takes a dictionary `ind` and an integer `id` as input and returns a list of all the nested IDs within the 'lhn' key of the dictionary that match the given `id`. The dictionary `ind` contains keys representing IDs and the 'lhn' key, which holds a list of lists cont...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Union def find_nested_ids(ind: Dict[Union[int, str], Union[Dict, List[List[int]]]], id: int) -> List[int]: """ Find all nested IDs within the 'lhn' key of the dictionary that match the given ID. ...
magic_instruct_75k
57,027
Write a Python function to initialize the weights and biases for a neural network's second layer. The function should take the input size `input_size` and the number of neurons in the hidden layer `hidden_size` as input and return the initialized weights `W2` and biases `b2` for the second layer. The weights `W2` shoul...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import Tuple def initialize_second_layer(input_size: int, hidden_size: int) -> Tuple[np.ndarray, np.ndarray]: """ Initializes the weights and biases for the second layer of a neural network. ...
magic_instruct_75k
57,028
Write a Python function to manage directories for a distributed computing system. The function should check for the existence of a directory and create it if it does not exist. If the directory cannot be created, an error message should be displayed, and the program should terminate. The function should use the `verbos...
Here is the Python code to solve the given problem in the markdown block: ```python import os import sys # Constants for verbosity levels ERROR = 1 def manage_directory(run_directory: str, verbosity: int, machine_name: str, slave_id: str) -> None: """ Manages the creation of a directory for a distributed comp...
magic_instruct_75k
57,039
Write a Python function to extract specific messaging-related settings from a given configuration dictionary. The function should return a new dictionary containing only the specified keys and their corresponding values. The specified keys are "mjm_alerts", "telegram_chat_id", "platform", and "sms_alerts". The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_messaging_settings(config: Dict[str, any]) -> Dict[str, any]: """ Extracts specific messaging-related settings from a given configuration dictionary. Args: config (Dict[str, any]...
magic_instruct_75k
57,061
Write a Python function to extract chapter information from a list of MP3 filenames. Each MP3 file represents an audiobook with multiple chapters, and the filenames follow a specific format: "book_title_chapter_number.mp3". The function should return a dictionary where the keys are the chapter numbers and the values ar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def extract_chapters(mp3_files: List[str]) -> Dict[str, str]: """ Extracts chapter information from a list of MP3 filenames. Each MP3 filename follows the format "book_title_chapter_number.mp3...
magic_instruct_75k
57,065
Write a Python function `evaluate_condition_code(cc, ctx)` that simulates the behavior of a given assembly language code snippet. The function should take a 16-bit integer `cc` representing a condition code and an object `ctx` representing the program's context. The function should return the result of the conditional ...
Here is the Python code to solve the given problem in the markdown block: ```python def evaluate_condition_code(cc: int, ctx) -> int: """ Simulates the behavior of a given assembly language code snippet. Args: cc (int): A 16-bit integer representing the condition code. ctx (object): An obje...
magic_instruct_75k
57,067
Write a Python function to determine the rewards a player will receive based on their level in a game. The rewards are predefined in a dictionary where each key represents a level and the corresponding value is a dictionary of reward items and their quantities. If the player's level is not found in the dictionary, the ...
Here is the Python code to solve the given problem in the markdown block: ```python def get_rewards(level: int) -> dict: """ Returns the rewards for a player based on their level. Args: level (int): The level of the player. Returns: dict: A dictionary containing the rewards for the giv...
magic_instruct_75k
57,089
Write a Python function to compute the dot product of two 2D arrays, replicating the functionality of the `dot` method from the `numpy` library. The function should handle matrices of arbitrary dimensions and return a new 2D array representing the dot product of the input matrices. The input matrices are represented as...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_dot(A: List[List[int]], B: List[List[int]]) -> List[List[int]]: """ Compute the dot product of two 2D arrays. Args: A (List[List[int]]): The first 2D array. B (List[List[i...
magic_instruct_75k
57,092
Write a Python function to extract fold numbers from a list of command-line strings. Each string represents a command to execute a Python script with different configuration files specified using the `--configs` flag followed by the file path. The fold number is the integer value following the pattern `fold{number}` in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_fold_numbers(ls: List[str]) -> List[int]: """ Extracts fold numbers from a list of command-line strings. Each string represents a command to execute a Python script with differ...
magic_instruct_75k
57,107
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
57,117
Write a Python function to calculate the sum of the lengths of all distinct substrings of a given list of integers. A substring is defined as a contiguous sequence of elements within the list. The function should start with: ```python from typing import List def sum_of_distinct_substrings(a: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_distinct_substrings(a: List[int]) -> int: """ Calculate the sum of the lengths of all distinct substrings of a given list of integers. Args: a (List[int]): The list of integers fr...
magic_instruct_75k
57,128
Create a Python class `FilePacker` that simulates a file packing and unpacking system. The class should provide methods to erase files from a pack, extract a file to a destination, and extract a file to memory. The class should be designed to handle a list of files and their contents. The class should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union class FilePacker: def __init__(self, files: Dict[str, str]): """ Initialize the FilePacker with a dictionary of files and their contents. Args: files (Dict[s...
magic_instruct_75k
57,166
Write a Python function `create_composed_function` that takes three arguments: `first`, `second`, and `input_func`. The `input_func` is a function that takes a single argument and returns a value. The `create_composed_function` should return a new function that applies the `first` function to the result of the `input_f...
Here is the Python code to solve the given problem in the markdown block: ```python def create_composed_function(first, second, input_func): """ Creates a new function that applies the `first` function to the result of the `input_func`, and then applies the `second` function to the result of the first opera...
magic_instruct_75k
57,173
Write a Python function `update_histogram` that takes in a dictionary `hist` representing the current histogram of email addresses and a list `emails` containing email addresses to update the histogram. The function should update the histogram with the counts of the email addresses in the list and return the updated hi...
Here is the Python code to solve the given problem in the markdown block: ```python def update_histogram(hist: dict, emails: list) -> dict: """ Updates the histogram of email addresses with the counts of the email addresses in the list. Args: hist (dict): A dictionary representing the current histo...
magic_instruct_75k
57,177
Write a Python function to compute the shortest paths between all pairs of vertices in a directed graph using the Floyd-Warshall algorithm. The graph is represented by a list of vertices and a dictionary of pairwise distances between vertices. The function should return a dictionary representing the shortest distances ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple from math import inf Node = int # Assuming nodes are represented as integers def all_pairs_shortest_paths(vertices: List[Node], distances: Dict[Tuple[Node, Node], float]) -> Dict[Tuple[Node, Node]...
magic_instruct_75k
57,178
Write a Python function to calculate the average coverage for each unique combination of identifier, type, and subtype from a given dataset. The dataset is a list of strings where each string represents an item with its identifier, type, subtype, and coverage value. The function should return a list of strings where ea...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_average_coverage(dataset: List[str]) -> List[str]: """ Calculate the average coverage for each unique combination of identifier, type, and subtype from the given dataset. Args: ...
magic_instruct_75k
57,187
Write a Python function to automate the process of setting up a user's X Window System initialization file. The function should: 1. Read the contents of the system's default X Window System initialization file located at `/etc/X11/xinit/xinitrc`. 2. Write the contents into the user's home directory, specifically at `/h...
Here is the Python code to solve the given problem in the markdown block: ```python def setup_xinitrc(source_path: str, destination_path: str) -> None: """ Automates the process of setting up a user's X Window System initialization file. This function reads the contents of the system's default X Window Sys...
magic_instruct_75k
57,196
Write a Python function to calculate the maximum profit that can be obtained by buying and selling a stock on different days. You are only allowed to complete at most one transaction (i.e., buy one and sell one share of the stock). The function should take a list of integers `prices` representing the stock prices on di...
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 on different days. Args: prices (List[int]): A list of integers ...
magic_instruct_75k
57,205
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of a given 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
57,228
Write a Python function to convert a list of numbers (both integers and floating-point numbers) into a single string where each number is separated by a single space. The function should handle any iterable of numbers, including lists, tuples, and sets. The code should start with: ```python from typing import Iterable...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Iterable, Union def sjoin(values: Iterable[Union[float, int]]) -> str: """ Converts a list of numbers (integers and floating-point numbers) into a single string where each number is separated by a single ...
magic_instruct_75k
57,252
Write a Python function to implement the insertion sort algorithm to sort an array of integers in non-decreasing order. The insertion sort algorithm works by iteratively building a sorted portion of the array, one element at a time. At each iteration, the algorithm takes the next unsorted element and inserts it into it...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_insertion(arr: List[int]) -> List[int]: """ Sorts the input array using the insertion sort algorithm. The insertion sort algorithm works by iteratively building a sorted portion of the arra...
magic_instruct_75k
57,253
Write a Python function to calculate the sum of all prime numbers up to a given integer `n`. 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 `n` as input and return the sum of all prime numbers up to and including `n`. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_primes(n: int) -> int: """ Calculate the sum of all prime numbers up to and including a given integer `n`. Args: n (int): The upper limit for the prime numbers to be summed. Returns: int: The...
magic_instruct_75k
57,263
Write a Python function to count the occurrences of the integer `1` in a given list of integers. The list can contain elements that are either `0` or `1`. The function should efficiently count the number of `1`s and return the count. The code should start with: ```python from typing import List def count_ones(ls: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_ones(ls: List[int]) -> int: """ Counts the occurrences of the integer `1` in the given list of integers. Args: ls (List[int]): A list of integers where each element is either `0` o...
magic_instruct_75k
57,331
Write a Python function to determine whether a given string contains a balanced set of curly braces. A balanced set of braces is defined as a string where for every opening curly brace `{`, there is a corresponding closing curly brace `}` in the correct order. Additionally, the braces must be properly nested, meaning t...
Here is the Python code to solve the given problem in the markdown block: ```python def is_balanced_braces(s: str) -> bool: """ Determine whether a given string contains a balanced set of curly braces. Args: s (str): The input string to check for balanced curly braces. Returns: bool: T...
magic_instruct_75k
57,352
Write a Python function to extract and return a list of filenames for all the uploaded files in a given form dictionary. The form dictionary is structured such that each key represents a field name in the form, and each value is an object containing information about the uploaded files. If a field contains an uploaded ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Any def extract_uploaded_filenames(form: Dict[str, Any]) -> List[str]: """ Extracts and returns a list of filenames for all the uploaded files in the given form dictionary. Args: form...
magic_instruct_75k
57,359
Write a Python function to simulate a game where players must click on certain elements based on a given set of rules. The game involves a grid of clickable elements, each associated with a unique index. Additionally, there are namespaces and colors associated with each element. The game has a set of ordered terms, and...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List import random def simulate_game(all_clickable_indices: Dict[int, int], new_namespace_colours: Dict[str, str], ordered_terms: List[str]) -> List[int]: """ Simulates a game where players must click o...
magic_instruct_75k
57,363
Design a Python class `VRSystem` that efficiently handles two types of events: `SLOBSSourceEvent` and `SLOBSSceneItemEvent`. The class should provide methods to subscribe and unsubscribe to these events, and process and handle the received events. The class should be designed to handle a large number of events efficien...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable, Dict class VRSystem: def __init__(self): """ Initialize the VRSystem with empty dictionaries to store event subscriptions. """ self.subscriptions: Dict[str, List[Ca...
magic_instruct_75k
57,367
Write a Python function to filter a list of channel properties and return a list containing only the settable properties of boolean data type, along with their associated device and register information. The function should take a list of `Channel` objects as input, where each `Channel` object contains a `Device` objec...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple from enum import Enum class DataType(Enum): BOOLEAN = 1 INTEGER = 2 FLOAT = 3 STRING = 4 class Device: def __init__(self, device_id): self.id = device_id class ChannelPropert...
magic_instruct_75k
57,375
Write a Python function to process a list of arguments, where each argument is represented as a dictionary containing the keys 'text', 'start', 'end', and 'position'. The 'text' key holds a string, and the 'position' key holds a list of integers representing the start and end indices of the argument within a larger tex...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def process_arguments(arguments: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Processes a list of arguments, where each argument is represented as a dictionary. The function populates the...
magic_instruct_75k
57,392
Write a Python function to scale the dimensions of a video clip by a given factor. The function should take in the original x and y dimensions of a video clip, as well as a scaling factor, and return the new scaled x and y dimensions. The function should be named `scale_xy` and should adhere to the following signature:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def scale_xy(x: int, y: int, scale: float) -> Tuple[int, int]: """ Scales the dimensions of a video clip by a given factor. Args: x (int): The original x dimension of the video clip. ...
magic_instruct_75k
57,396
Write a Python function to map an HTTP status code to its corresponding HTTP status message. The function should handle both standard HTTP status codes and the custom "I'm a teapot" status code. If the status code is not recognized, the function should return "Unknown Status Code". The function signature is: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python def get_http_status_message(status_code: int) -> str: """ Returns the HTTP status message corresponding to the given status code. Args: status_code (int): The HTTP status code to look up. Returns: str: ...
magic_instruct_75k
57,398
Create a Python function to determine if two trading sessions are equal based on their extent and trade date. The trading session can be of two extents: "Day" or "Week". The equality comparison should consider both the extent and the trade date of the session. The function should return `True` if the two sessions are e...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def are_sessions_equal(session1: dict, session2: dict) -> bool: """ Determines if two trading sessions are equal based on their extent and trade date. Args: session1 (dict): The first ...