source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_instruct_75k
54,327
Write a Python function to implement a search algorithm for finding the optimal route in a network. The network is represented as a list of strategies, each containing information about the route and the target. The search algorithm should terminate when the last strategy is reached. If the strategy list is empty, the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Union def find_optimal_route(strategies: List[Dict[str, str]]) -> Union[List[str], str]: """ Finds the optimal route in a network represented by a list of strategies. Args: strategies...
magic_instruct_75k
54,345
Write a Python function to determine if a given string represents a valid integer. The function should return `True` if the string represents a valid integer, and `False` otherwise. The string may contain leading or trailing whitespaces, and may also include a leading positive or negative sign. However, the string must...
Here is the Python code to solve the given problem in the markdown block: ```python def is_int(s: str) -> bool: """ Determine if a given string represents a valid integer. Args: s (str): The string to be checked. Returns: bool: True if the string represents a valid integer, False other...
magic_instruct_75k
54,367
Write a Python function to optimize the selection of 4 color patches from a given list of colors to minimize the cost of the design. The cost is calculated based on the absolute differences between the selected colors. The function should return the indices of the 4 colors that form the optimized combination. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import itertools def optimize_color_selection(colors: List[int]) -> List[int]: """ Optimizes the selection of 4 color patches from a given list of colors to minimize the cost. The cost is calculated...
magic_instruct_75k
54,386
Write a Python function to sort a list of dictionaries based on the integer values associated with the keys in ascending order. Each dictionary in the list contains a single key-value pair, where the key is a lowercase letter and the value is an integer. The function should return the sorted list of dictionaries. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_dicts_by_value(b: List[Dict[str, int]]) -> List[Dict[str, int]]: """ Sorts a list of dictionaries based on the integer values associated with the keys in ascending order. Args: ...
magic_instruct_75k
54,395
Write a Python function to process a list of file entries and extract specific details from each entry. Each entry is in the format `<filename>el.php<gh_stars>0`, where `<filename>` is the name of the file and `<gh_stars>` is the number of stars the file has received on GitHub. The function should return a list of dict...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def extract_file_info(file_entries: List[str]) -> List[Dict[str, str]]: """ Extracts the filename and the number of stars from each file entry in the given list. Args: file_entries (Li...
magic_instruct_75k
54,417
Create a Python class `GraphicalObject` that represents a graphical object with an anchor point. The anchor point can be one of four types: `TOP_LEFT`, `TOP_RIGHT`, `BOTTOM_LEFT`, or `BOTTOM_RIGHT`. The class should provide methods to set and get the anchor type. The class should be initialized with the anchor type set...
Here is the Python code to solve the given problem in the markdown block: ```python from enum import Enum class AnchorType(Enum): TOP_LEFT = 1 TOP_RIGHT = 2 BOTTOM_LEFT = 3 BOTTOM_RIGHT = 4 class GraphicalObject: """ A class representing a graphical object with an anchor point. Attributes...
magic_instruct_75k
54,447
Implement a Python function to simulate a simple logging system for a program that operates in two modes: one for use with the Robot Operating System (ROS) and one for standard operation. The logging system should print messages to the console based on the selected mode. Additionally, implement a `run` function that ta...
Here is the Python code to solve the given problem in the markdown block: ```python import inspect import sys def print_init_ros(): """Initialize ROS logging.""" print("Initializing ROS logging") def print_init_std(): """Initialize standard logging.""" print("Initializing standard logging") def print...
magic_instruct_75k
54,457
Write a Python function to automate the process of updating a software repository. The function should perform the following steps in sequence: 1. Pull the latest changes from the remote repository and rebase the current branch. 2. Merge the changes from a specified branch into the current branch. 3. Clean the project ...
Here is the Python code to solve the given problem in the markdown block: ```python import subprocess def update_repository(branch_name: str) -> None: """ Automates the process of updating a software repository by performing the following steps: 1. Pull the latest changes from the remote repository and reb...
magic_instruct_75k
54,482
Write a Python function to manage the power policies of virtual hosts in a data center environment. The function should take in a host object and a new power policy, and update the host's power policy if it differs from the current one. The power policy is represented by a string containing the policy name. The functi...
Here is the Python code to solve the given problem in the markdown block: ```python def update_power_policy(host, new_policy: str) -> bool: """ Updates the power policy of a virtual host if the new policy differs from the current one. Args: host: An object representing a virtual host in the data ce...
magic_instruct_75k
54,485
Write a Python function to modify a list of strings according to a set of rules. The function should take a list of strings as input and return a modified list of strings. The modifications should include creating a deep copy of the input list, inserting a specific string at the beginning of the copied list, and return...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import copy def modify_output_commands(output_commands: List[str]) -> List[str]: """ Modifies the input list of strings by creating a deep copy, inserting "drop *" at the beginning, and returning the mod...
magic_instruct_75k
54,510
Write a Python function to implement an optimized selection sort algorithm that sorts a given list of integers in ascending order. The function should improve the performance of the given selection sort algorithm without changing its sorting logic. The code should start with: ```python from typing import List def opti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def optimized_selection_sort(vector: List[int]) -> List[int]: """ Sorts a given list of integers in ascending order using the selection sort algorithm. Args: vector (List[int]): The list of ...
magic_instruct_75k
54,520
Write a Python function to perform matrix multiplication of two given matrices `A` and `B`. The function should return the resulting matrix `C` after performing the multiplication. The function should handle matrices of compatible dimensions, where the number of columns in matrix `A` is equal to the number of rows in m...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def matrix_multiplication(A: List[List[int]], B: List[List[int]]) -> List[List[int]]: """ Perform matrix multiplication of two given matrices A and B. Args: A (List[List[int]]): The first ma...
magic_instruct_75k
54,530
Write a Python function to generate random cluster positions in a 2D space based on given parameters. The function should take in the number of clusters, the number of points in each cluster, and the ranges for multipliers and offsets used to generate the cluster positions. The function should return the positions as t...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List, Tuple def generate_cluster_positions(n_clusters: int, n_points: List[int], x_mult: Tuple[int, int], y_mult: Tuple[int, int], x_off: Tuple[int, int], y_off: Tuple[int, int]) -> Tuple[List[List...
magic_instruct_75k
54,573
Write a Python function to validate the result of a GraphQL query against an expected result. The GraphQL query result and the expected result are both represented as Python dictionaries. The function should compare the result with the expected result and determine if they match. The function should handle nested dicti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def validate_graphql_result(result: Dict, expected: Dict) -> bool: """ Validates if the result of a GraphQL query matches the expected result. Args: result (Dict): The result of the Gra...
magic_instruct_75k
54,586
Write a Python function to simulate the logging system for a cross-platform game development project. The function should handle logging based on different platforms and environments. The function should take a string `message` as input and perform the following actions based on the platform and environment: - If the p...
Here is the Python code to solve the given problem in the markdown block: ```python def LogMessage(message: str, platform: int, environment: str) -> None: """ Simulates a logging system for a cross-platform game development project. Args: message (str): The message to be logged. platform (i...
magic_instruct_75k
54,594
Write a Python function to process a dictionary representing a response from a Discord API. The function should extract specific information from the response and modify it based on optional keyword arguments. The response dictionary contains a status code and an error message. The function should modify the error mess...
Here is the Python code to solve the given problem in the markdown block: ```python def process_discord_response(response: dict, **kwargs) -> dict: """ Processes a Discord API response dictionary and modifies its error message based on optional keyword arguments. Args: response (dict): A dictionary...
magic_instruct_75k
54,657
Write a Python function to decode TLV (Type-Length-Value) encoded data. The function should parse the input data and return a list of dictionaries, where each dictionary represents a TLV element with keys 'Type', 'Length', and 'Value'. The input data is a byte string where each TLV element is encoded as follows: - The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, ByteString def decode_tlv(data: ByteString) -> List[Dict[str, int or ByteString]]: """ Decodes TLV (Type-Length-Value) encoded data into a list of dictionaries. Args: data (ByteString...
magic_instruct_75k
54,699
Write a Python function `calculate_expected(n)` that takes an integer `n` as input and returns the value of `expected` based on the following rules: - If `n` is even, `expected` should be the square of `n`. - If `n` is odd, `expected` should be the cube of `n`. The code should start with: ```python def calculate_expec...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_expected(n: int) -> int: """ Calculate the value of `expected` based on the given rules. Args: n (int): The input integer. Returns: int: The value of `expected`, which is the square of `n`...
magic_instruct_75k
54,724
Write a Python function to manage a collection of plugins in a thread-safe manner. The function should support adding, removing, and retrieving plugins. The provided code snippet includes a macro for validating non-null input and acquiring a lock using an `AutoLock` object. Your task is to complete the implementation ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import threading class PluginManager: def __init__(self): self.plugins = [] self.lock = threading.Lock() def _validate_not_null(self, plugin: str) -> None: """ Validate t...
magic_instruct_75k
54,757
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
54,776
Write a Python function `custom_path_insert` that simulates a simplified version of the `sys.path.insert` method. The function should take three parameters: 1. `path_list`: A list of strings representing the current search path. 2. `index`: An integer representing the index at which the new path should be inserted. 3. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_path_insert(path_list: List[str], index: int, new_path: str) -> List[str]: """ Inserts a new path into the given path list at the specified index. Args: path_list (List[str]): A l...
magic_instruct_75k
54,782
Write a Python function to parse a list of strings representing programming language classifiers and return a dictionary containing the count of each unique programming language and its corresponding version. Each string in the list is formatted as `'Programming Language :: LanguageName :: Version'`, where the version ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def parse_language_classifiers(classifiers: List[str]) -> Dict[str, Dict[str, int]]: """ Parses a list of strings representing programming language classifiers and returns a dictionary containi...
magic_instruct_75k
54,784
Write a Python function to calculate the sum of all elements in a given array that are greater than a specified threshold. The function should be efficient and handle large input sizes within the given constraints. The code should start with: ```python from typing import List def sum_greater_than_threshold(arr: List[...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_greater_than_threshold(arr: List[int], threshold: int) -> int: """ Calculate the sum of all elements in the given array that are greater than the specified threshold. Args: arr (List...
magic_instruct_75k
54,792
Implement a stack data structure in Python with the following operations: 1. `push(val)`: Add an element `val` to the top of the stack. 2. `pop()`: Remove the element at the top of the stack and return its value. If the stack is empty, return `None`. 3. `peek()`: Return the value of the element at the top of the stack ...
Here is the Python code to solve the given problem in the markdown block: ```python class Stack: def __init__(self): """ Initialize an empty stack. """ self.stack = [] def push(self, val): """ Add an element to the top of the stack. Args: val...
magic_instruct_75k
54,859
Write a Python function to calculate the minimum number of coins needed to make change for a given amount `m` using coin denominations of 1, 3, and 4. The function should return the minimum number of coins required. The code should start with: ```python def get_change(m: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def get_change(m: int) -> int: """ Calculate the minimum number of coins needed to make change for a given amount `m` using coin denominations of 1, 3, and 4. Args: m (int): The amount for which to make change. ...
magic_instruct_75k
54,860
Write a Python function to convert a given integer to its corresponding LF_PAD value. The LF_PAD values are predefined constants in the code snippet. If the integer does not correspond to any LF_PAD value, the function should return "Not found". The LF_PAD values are defined as follows: ```python LF_PAD3 = 0xf3 LF_PAD...
Here is the Python code to solve the given problem in the markdown block: ```python def get_lf_pad_value(num: int) -> str: """ Convert a given integer to its corresponding LF_PAD value. Args: num (int): The integer to convert. Returns: str: The corresponding LF_PAD value if found, othe...
magic_instruct_75k
54,905
Write a Python function to find the index of a target value in a given list of integers. If the target value is not present in the list, the function should return -1. The function should be efficient and should handle edge cases such as an empty list or a target value that is not in the list. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_target_index(nums: List[int], target: int) -> int: """ Find the index of the target value in the given list of integers. Args: nums (List[int]): The list of integers to search throu...
magic_instruct_75k
54,932
Write a Python function to count the number of unique package names from a given list of package dependencies. Each package dependency is represented as a string in the format 'package_name' or 'package_name>=version_number'. The function should ignore any version numbers and only consider the package names for uniquen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_unique_packages(dependencies: List[str]) -> int: """ Counts the number of unique package names from a given list of package dependencies. Args: dependencies (List[str]): A list of ...
magic_instruct_75k
54,935
Write a Python function to calculate the minimum number of books required to cover a given number of sheets for red, green, and blue papers. Each book provides a certain number of sheets, and you need to calculate the minimum number of books required for each color. The function should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def calculate_books_needed(red_sheets: int, green_sheets: int, blue_sheets: int, sheets_per_book: int) -> List[int]: """ Calculate the minimum number of books needed to cover the required num...
magic_instruct_75k
54,963
Write a Python function to find the maximum sum of a contiguous subarray within a given list of integers. The function should return 0 if the list is empty or contains only non-positive integers. The function should be efficient and use an optimal algorithm to achieve this. The code should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: """ Find the maximum sum of a contiguous subarray within the given list of integers. Args: nums (List[int]): The list of integers from which to ...
magic_instruct_75k
54,972
Write a Python function `process_arguments` that takes a list of arguments as input and performs the following operations: - Asserts that the size of the arguments is equal to a predefined constant `EXPECTED_SIZE`. - Extracts a single value from the arguments. - Returns a tuple containing the extracted value. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple # Define the expected size of the input list EXPECTED_SIZE = 1 def process_arguments(args: List[int]) -> Tuple[int]: """ Processes a list of arguments and returns a tuple containing a single extr...
magic_instruct_75k
54,974
Write a Python function to generate an Alembic migration script that alters a column in a database table. The function should take the table name, column name, new data type, precision for the new data type, and the existing nullable property of the column as parameters. The function should return a string representing...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_migration_script(table_name: str, column_name: str, new_data_type: str, precision: int, existing_nullable: bool) -> str: """ Generates an Alembic migration script to alter a column in a database table. Args: ...
magic_instruct_75k
54,978
Write a Python function to check if a given metric name is present in a predefined list of metric names. The predefined list is a combination of several metric lists and a dictionary of generated metrics. The function should return `True` if the metric name is found in the list, otherwise it should return `False`. The...
Here is the Python code to solve the given problem in the markdown block: ```python def check_metric_presence(metric_name: str) -> bool: """ Check if a given metric name is present in the predefined list of metric names. Args: metric_name (str): The name of the metric to check for presence. Re...
magic_instruct_75k
55,015
Write a Python function to process a list of HTTP response data and assert whether the status code of each response matches a specified expected code. The function should return a list of boolean values indicating the success of the assertions. Each HTTP response is represented as a dictionary with keys `'status_code'`...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def assert_status_codes(responses: List[Dict[str, Any]], expected_code: int) -> List[bool]: """ Processes a list of HTTP response data and asserts whether the status code of each response matc...
magic_instruct_75k
55,038
Write a Python function to simulate the behavior of the described shell script. The function should take the path to the clang-tidy binary, the path to the `compile_commands.json` file, a boolean flag indicating whether fixes should be applied, and a list of files to run clang-tidy on. The function should simulate runn...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def run_clang_tidy(clang_tidy_path: str, compile_commands_path: str, apply_fixes: bool, files: List[str]) -> None: """ Simulate running clang-tidy on a list of files using the provided clang-tidy binary ...
magic_instruct_75k
55,040
Write a Python function to validate a command-line input for installing Python packages using pip. The function should take a list representing the command-line input and return `True` if the input matches the expected format, and `False` otherwise. The expected command-line input format for installing a package using...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def validate_pip_install_cmdline(mycmdline: List[str]) -> bool: """ Validates a command-line input for installing Python packages using pip. The expected format is: 1. The first element is the c...
magic_instruct_75k
55,071
Write a Python function to determine if a given string is a palindrome. A palindrome is a sequence of characters that reads the same forward and backward, disregarding spaces, punctuation, and capitalization. The function should be case-insensitive and should ignore non-alphanumeric characters. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine if a given string is a palindrome, disregarding spaces, punctuation, and capitalization. Args: s (str): The input string to check. Returns: bool: True if...
magic_instruct_75k
55,074
Write a Python function to extract the breaking changes for a given version number from a version history log. The version history log is a multi-line string where each line represents a version and its associated breaking changes. The breaking changes are denoted by lines starting with "###" followed by the version nu...
Here is the Python code to solve the given problem in the markdown block: ```python def extract_breaking_changes(version_history: str, target_version: str) -> list: """ Extracts the breaking changes for a given version number from a version history log. Args: version_history (str): A multi-line str...
magic_instruct_75k
55,076
Write a Python function to generate all possible sequences of length `N` using an alphabet of size `alphabetSize`. Each sequence is represented as a string of characters from 'A' to 'A' + `alphabetSize` - 1. The sequences should be generated in lexicographical order. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_sequences(N: int, alphabetSize: int) -> List[str]: """ Generate all possible sequences of length N using an alphabet of size alphabetSize. Each sequence is represented as a string of cha...
magic_instruct_75k
55,105
Write a Python function to determine the longest common prefix string among an array of strings. If there is no common prefix, the function should return an empty string `""`. The code should start with: ```python from typing import List def longest_common_prefix(strs: List[str]) -> str: ```
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 string among an array of strings. Args: strs (List[str]): A list of strings to find the longest com...
magic_instruct_75k
55,120
Write a Python function to find the closest matching color from a predefined set of colors to a given target color. The colors are represented as RGB tuples, with each component ranging from 0 to 1. The distance between two colors is calculated using the Euclidean distance formula in the RGB color space. The function ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def find_closest_color(target_color: Tuple[float, float, float], color_set: List[Tuple[float, float, float]]) -> Tuple[float, float, float]: """ Find the closest matching color from a ...
magic_instruct_75k
55,162
Write a Python function to evaluate the value of a polynomial given its coefficients and a value of `x`. The coefficients are provided in a list where each element corresponds to the coefficient of the term with the respective power of `x`. For example, the coefficient at index 0 corresponds to the constant term, the c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def evaluate_polynomial(coefficients: List[float], x: float) -> float: """ Evaluates the value of a polynomial given its coefficients and a value of x. Args: coefficients (List[float]): A li...
magic_instruct_75k
55,167
Create a Python decorator that modifies the behavior of a given function to handle access to protected members of an object. The decorator should ensure that if the decorated function attempts to access a protected member (denoted by a single underscore prefix, e.g., `_protected_member`), it returns the string "Accessi...
Here is the Python code to solve the given problem in the markdown block: ```python def protected_access_decorator(func): """ A decorator that modifies the behavior of a function to handle access to protected members of an object. If the decorated function attempts to access a protected member (denoted by a...
magic_instruct_75k
55,174
Write a Python function to determine the coordinates of rectangles to be drawn around non-empty text regions within bounding boxes. Each bounding box is represented by its coordinates and dimensions. The function should filter out bounding boxes that contain empty text and return the coordinates of rectangles for the n...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def draw_text_rectangles(n_boxes: int, text: List[str], left: List[int], top: List[int], width: List[int], height: List[int]) -> List[Tuple[int, int, int, int]]: """ Determine the coordinates of r...
magic_instruct_75k
55,191
Write a Python function to process a feed and generate an HTML string displaying the feed's title along with the titles and links of its entries. The function should take in a feed object `awesomefeed` and return a rendered HTML string containing the feed's title, entry titles, entry links, and the number of entries. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def generate_feed_page(awesomefeed: Dict[str, Any]) -> str: """ Generates an HTML string displaying the feed's title along with the titles and links of its entries. Args: awesomef...
magic_instruct_75k
55,196
Write a Python function to simulate the removal of a program called Yin-Yang from a Linux system. The function should remove the program files, configuration files, and any associated desktop shortcuts. The function should also handle errors gracefully and provide appropriate feedback to the user during the removal pro...
Here is the Python code to solve the given problem in the markdown block: ```python import os import shutil def remove_yin_yang(yin_yang_home: str) -> None: """ Simulates the removal of the Yin-Yang program from a Linux system. This function removes the program files, configuration files, and any associat...
magic_instruct_75k
55,231
Write a Python function to count the occurrences of each type of Django migration operation in a given list. Each operation is represented as a tuple where the first element is the operation type (a string) and the second element is the operation details (any type). The function should return a dictionary where the key...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Any, Dict def count_migration_operations(operations: List[Tuple[str, Any]]) -> Dict[str, int]: """ Counts the occurrences of each type of Django migration operation in a given list. Args: ...
magic_instruct_75k
55,240
Write a Python function to implement a hash table data structure that supports the following operations: 1. Insertion of a key-value pair. 2. Retrieval of the value associated with a given key. 3. Deletion of a key-value pair. The hash table should handle potential naming conflicts with the `hash` function in the `bui...
Here is the Python code to solve the given problem in the markdown block: ```python class HashTable: def __init__(self, size: int): """ Initialize the hash table with the given size. Args: size (int): The size of the hash table. """ self.size = size self....
magic_instruct_75k
55,262
Write a Python function `analyze_public_keys(dataset)` that processes a dataset containing information about public keys and returns a summary of the key types and their respective lengths. The dataset is represented as a list of dictionaries, where each dictionary contains information about a public key. The summary s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def analyze_public_keys(dataset: List[Dict]) -> Dict[str, Dict[int, int]]: """ Analyzes a dataset of public keys and returns a summary of the key types and their respective lengths. Args: ...
magic_instruct_75k
55,275
Implement a Python class `LinkedList` that represents a singly linked list. The class should have the following methods: 1. `add_node(self, item)`: Adds a new node with the given value at the beginning of the linked list. 2. `remove_node(self, item)`: Removes the first occurrence of a node with the given value from the...
Here is the Python code to solve the given problem in the markdown block: ```python class Node: def __init__(self, init_data): self.data = init_data self.next = None def get_item(self): return self.data def get_next(self): return self.next def set_next(self, new_next):...
magic_instruct_75k
55,281
Write a Python function to determine whether it is possible to convert one string (`str1`) into another string (`str2`) using at most `k` operations. The operations allowed are inserting a character, deleting a character, or replacing a character. The function should return `True` if the conversion is possible within t...
Here is the Python code to solve the given problem in the markdown block: ```python def is_k_palindrome(str1: str, str2: str, k: int) -> bool: """ Determine if it is possible to convert `str1` into `str2` using at most `k` operations. Args: str1 (str): The original string. str2 (str): The t...
magic_instruct_75k
55,282
Write a Python function `countClassOccurrences` that analyzes an HTML string to count the occurrences of specific CSS class names within the HTML elements. The function should handle both single and double quotes around the class names in the HTML. The function should take two parameters: 1. `htmlContent` (string): A ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import re def countClassOccurrences(htmlContent: str, classNames: List[str]) -> Dict[str, int]: """ Counts the occurrences of specific CSS class names in an HTML string. Args: htmlCont...
magic_instruct_75k
55,283
Write a Python function to simulate the behavior of a package manager's configuration file parser. The function should interpret rules for masking specific packages or package versions and return the corresponding file paths where the masking configurations are stored. The rules are defined using a specific syntax, and...
Here is the Python code to solve the given problem in the markdown block: ```python def get_config_file(mask_type: str, atom: str) -> str: """ Returns the file path corresponding to the given package atom based on the defined rules. Args: mask_type (str): The type of mask to retrieve, which can be ...
magic_instruct_75k
55,285
Write a Python function to generate a version string based on the Semantic Versioning (SemVer) format. The function should take three integers representing the major, minor, and patch versions, and return a string in the format "major.minor.patch". The function should ensure that the input integers are non-negative and...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_version_string(major: int, minor: int, patch: int) -> str: """ Generates a version string in the Semantic Versioning (SemVer) format. Args: major (int): The major version number. Must be a non-negative ...
magic_instruct_75k
55,296
Write a Python function to generate pre-processed datasets based on the given parameters. The function should take two input parameters: `file_name` and `prepro_type`. The `file_name` parameter specifies the name of the dataset to be pre-processed, and the `prepro_type` parameter specifies the type of pre-processing to...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_preprocessed_dataset(file_name: str, prepro_type: str) -> str: """ Generates a pre-processed dataset based on the given parameters. Args: file_name (str): The name of the dataset to be pre-processed. ...
magic_instruct_75k
55,312
Write a Python function to merge overlapping intervals from a given list of intervals. Each interval is represented as a tuple of two integers: the start and end points. The function should return a new list of non-overlapping intervals after merging the overlapping ones. 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, Tuple def merge_intervals(intervals: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Merges overlapping intervals from a given list of intervals. Args: intervals (List[Tuple[int, int]]...
magic_instruct_75k
55,322
Write a Python function to process a dictionary and return a list of its values, excluding the values associated with a specific key. The function should remove the specified key and its associated value from the dictionary before extracting the values. The function should have the following signature: ```python def pr...
Here is the Python code to solve the given problem in the markdown block: ```python def process_dictionary(input_dict: dict, key_to_exclude: str) -> list: """ Processes a dictionary by removing a specified key and its associated value, then returns a list of the remaining values in the dictionary. Args...
magic_instruct_75k
55,330
Write a Python function to verify the strength of a given password based on its length. The function should return a specific result based on the strength of the password. The code should start with: ```python from enum import Enum class PasswordVerificationResult(Enum): Failed = 0 Weak = 1 Medium = 2 ...
Here is the Python code to solve the given problem in the markdown block: ```python from enum import Enum class PasswordVerificationResult(Enum): Failed = 0 Weak = 1 Medium = 2 Strong = 3 def verify_password_strength(password: str) -> PasswordVerificationResult: """ Verify the strength of a gi...
magic_instruct_75k
55,345
Write a Python function to calculate the total score for each player after all the rounds in a game where the score of each player is the sum of their scores in the current and the previous round. The function should take a list of integers representing the scores of the game rounds and return a list of integers repres...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculateTotalScore(scores: List[int]) -> List[int]: """ Calculate the total score for each player after all the rounds in a game where the score of each player is the sum of their scores in the ...
magic_instruct_75k
55,369
Write a Python function to extract all conditional comments from a given HTML string. Conditional comments are specific to Internet Explorer and are enclosed within `<!--[if condition]> ... <![endif]-->` tags. The function should return a list of all the conditional comments found in the HTML. If no conditional comment...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_conditional_comments(html: str) -> list: """ Extracts all conditional comments from a given HTML string. Conditional comments are specific to Internet Explorer and are enclosed within `<!--[if con...
magic_instruct_75k
55,400
Write a Python function to download videos from a website. The function should take a list of video keys as input and download the high-definition (HD) version of each video. The function should use the provided `downloader` and `extractor` objects to fetch and save the videos. The `downloader` object has a `get` meth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List class Downloader: def get(self, url: str) -> str: # Fetches the webpage content from the given URL pass def save_file(self, url: str, filename: str) -> None: # Saves the file fro...
magic_instruct_75k
55,401
Write a Python function to determine if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. The function should return `True` if the input string is a palindrome and `False` ot...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome(s: str) -> bool: """ Determine if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punc...
magic_instruct_75k
55,404
Write a Python function to determine whether a given string can be transformed into another string by rearranging its characters. The function should return `True` if the transformation is possible and `False` otherwise. The function should consider all characters in the strings, including duplicates. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import Counter def can_scramble(source: str, dest: str) -> bool: """ Determine whether the characters in the source string can be rearranged to form the dest string. Args: source (str): The source ...
magic_instruct_75k
55,472
Write a Python function to increment the version number of a file in a version control system. The function should take a file path as input and return the new file path with the version number incremented by 1. The version number is appended to the file name in the format "_vX" where X is the version number. If the fi...
Here is the Python code to solve the given problem in the markdown block: ```python import re def version_up(file_path: str) -> str: """ Increments the version number of a file in a version control system. Args: file_path (str): The current file path with the version number. Returns: ...
magic_instruct_75k
55,503
Write a Python function to process a directory and its subdirectories to perform a specific action on each file. The function should take a single argument, which is the path to the directory to be processed. The function should then traverse the directory and its subdirectories, and for each file encountered, it shoul...
Here is the Python code to solve the given problem in the markdown block: ```python import os def process_directory(path: str) -> None: """ Process a directory and its subdirectories to perform custom actions on each file. Args: path (str): The path to the directory to be processed. Returns: ...
magic_instruct_75k
55,512
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
55,523
Write a Python function to convert a given month number into its corresponding three-letter abbreviation in Indonesian. The function should take an integer representing the month (1 for January, 2 for February, and so on) and return the three-letter abbreviation in Indonesian. If the input month number is invalid (not ...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_indonesian_month_abbreviation(month: int) -> str: """ Converts a given month number into its corresponding three-letter abbreviation in Indonesian. Args: month (int): The month number (1 for January, ...
magic_instruct_75k
55,526
Write a Python function to determine if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases. The function should start with: ```python def is_valid_palindrome(s: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def is_valid_palindrome(s: str) -> bool: """ Determine if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases. Args: s (str): The input string to check. Returns: ...
magic_instruct_75k
55,592
Write a Python function `add_token_expiration` that takes in a dictionary representing REST framework settings and returns a modified dictionary with an additional setting for token expiration time. The function should ensure that the input dictionary is not mutated and a new dictionary is returned with the additional ...
Here is the Python code to solve the given problem in the markdown block: ```python def add_token_expiration(settings: dict, expiration_time: int) -> dict: """ Adds a token expiration time setting to the given REST framework settings dictionary. Args: settings (dict): A dictionary representing the ...
magic_instruct_75k
55,611
Write a Python function to implement a simple stack data structure. A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. It has two main operations: `push`, which adds an element to the top of the stack, and `pop`, which removes the top element from the stack. Your task is to create...
Here is the Python code to solve the given problem in the markdown block: ```python class Stack: def __init__(self): """ Initialize an empty stack using a list. """ self.elements = [] def push(self, element): """ Adds an element to the top of the stack. ...
magic_instruct_75k
55,614
Write a Python function to filter a list of road segment dictionaries based on specific criteria. Each road segment is represented as a dictionary with keys corresponding to the attributes of the road segment. The function should filter out road segments that have an empty `identifier_roadId` or a `opendrive_roadMarkin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_road_segments(road_segments: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Filters a list of road segment dictionaries based on specific criteria. Args: road_segments (...
magic_instruct_75k
55,641
Create a Python function to parse command-line arguments for a worker program. The program should accept command-line arguments for the master IP address, master port, and worker port. The function should parse these arguments and store the values in the appropriate variables. The command-line arguments are expected t...
Here is the Python code to solve the given problem in the markdown block: ```python import argparse def parse_arguments(): """ Parse command-line arguments for the worker program. The program expects the following command-line arguments: -i/--masterip <ip>: The IP address of the master. -p/--maste...
magic_instruct_75k
55,649
Write a Python function to initialize and run a hypothetical mapper based on provided parameters. The function should take several input arguments corresponding to various configurations and settings for the mapper. After initializing and running the mapper, the function should return a string indicating the status or ...
Here is the Python code to solve the given problem in the markdown block: ```python def initialize_and_run_mapper(backbone: str, featureset: str, distance: str, onwhat: str, threshold: float, statistic: str, suffix: str, permfilter: bool, graph: str, network: str) -> str: """ Initializes and runs a hypothetical...
magic_instruct_75k
55,650
Write a Python function to complete the forward pass through a convolutional neural network (CNN) for image classification using PyTorch. The network architecture consists of three convolutional layers followed by ReLU activation functions. Your goal is to complete the implementation of the forward pass by adding the n...
Here is the Python code to solve the given problem in the markdown block: ```python import torch import torch.nn as nn import torch.nn.functional as F class SimpleCNN(nn.Module): def __init__(self): super(SimpleCNN, self).__init__() self.conv1 = nn.Conv2d(in_channels=1, out_channels=16, kernel_size...
magic_instruct_75k
55,662
Write a Python function to calculate the total price of items in a shopping cart. Each item in the cart is represented as a dictionary with keys "name", "price", and "quantity". The function should take a list of such item dictionaries and return the total price of all items in the cart. 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, Union def calculate_total_price(cart: List[Dict[str, Union[str, float, int]]]) -> float: """ Calculate the total price of items in a shopping cart. Args: cart (List[Dict[str, Union[st...
magic_instruct_75k
55,667
Write a Python function `generate_messages` that generates personalized messages for a team of employees based on their completion of tasks. The function should take two parameters: - `team`: a list of strings representing the names of team members. - `task_status`: a list of boolean values indicating whether the task ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_messages(team: List[str], task_status: List[bool]) -> List[str]: """ Generates personalized messages for a team of employees based on their task completion status. Args: team (L...
magic_instruct_75k
55,680
Write a Python function to retrieve the AWS Cognito User Pool ID based on the environment (ENV) and region (REGION) provided. The function should simulate the AWS CLI command to list user pools and extract the corresponding User Pool ID. The function should handle any errors that may occur during the process and provid...
Here is the Python code to solve the given problem in the markdown block: ```python def get_user_pool_id(env: str, region: str) -> str: """ Retrieves the AWS Cognito User Pool ID based on the provided environment and region. Args: env (str): The environment (e.g., 'dev', 'prod'). region (st...
magic_instruct_75k
55,687
Write a Python function that prints a consistent message across both Unix-based systems and Windows. The function should detect the operating system and use the appropriate command to print the message "Hello, cross-platform world!" without using any external libraries or modules. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python import os def print_cross_platform_message(): """ Prints the message "Hello, cross-platform world!" on both Unix-based systems and Windows. This function detects the operating system and uses the appropriate command to pri...
magic_instruct_75k
55,691
Write a Python function to remove commented lines from a list of strings. A commented line is defined as a line that starts with the `'#'` character followed by zero or more spaces and then some content. The function should return a new list with the commented lines removed. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_comments(lines: List[str]) -> List[str]: """ Removes commented lines from a list of strings. A commented line is defined as a line that starts with the '#' character followed by zero ...
magic_instruct_75k
55,693
Write a Python function to identify specific tokens from a given string input. The function should return a corresponding token based on the content of the string. The tokens to be identified are "DICE" and "VARIABLE". The input string should be case-insensitive, meaning that the function should treat "dice", "Dice", "...
Here is the Python code to solve the given problem in the markdown block: ```python def identify_token(s: str) -> str: """ Identifies and returns a token based on the content of the input string. The function processes the input string to identify whether it corresponds to the token "DICE" or "VARIABLE...
magic_instruct_75k
55,701
Write a Python function to count the frequency of each token in a given tuple of tokens. The function should return a dictionary where the keys are the tokens and the values are the frequency of each token in the input tuple. The frequency should be case-sensitive. 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 Tuple, Dict def count_token_frequency(tokens: Tuple[str]) -> Dict[str, int]: """ Counts the frequency of each token in a given tuple of tokens. Args: tokens (Tuple[str]): A tuple of strings repre...
magic_instruct_75k
55,742
Write a Python function to process a list of tuples, where each tuple contains a data type and a corresponding value. The data types can be "int", "str", "float", or "bool". The function should concatenate all the string values together in the order they appear in the list, and also convert any "int", "float", or "bool...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def process_data(data: List[Tuple[type, Union[str, int, float, bool]]]) -> str: """ Process a list of tuples, where each tuple contains a data type and a corresponding value. Concatenat...
magic_instruct_75k
55,754
Write a Python function to remove a specified key from a given dictionary and return the modified dictionary. If the key is not present in the dictionary, the function should return the original dictionary unchanged. The function should handle cases where the input dictionary is empty or the key is not found. The code...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_key(data_dict: dict, key: str) -> dict: """ Removes a specified key from the given dictionary and returns the modified dictionary. If the key is not present in the dictionary, the original dictionary is returned u...
magic_instruct_75k
55,760
Write a Python function to calculate the final position of a point on a 2D plane after executing a list of movement commands. Each command can be one of the following: "Top", "Bottom", "Left", or "Right". The initial position of the point is (0, 0). Each command moves the point in the corresponding direction by a unit ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def final_position(commands: List[str]) -> Tuple[int, int]: """ Calculate the final position of a point on a 2D plane after executing a list of movement commands. Args: commands (List...
magic_instruct_75k
55,777
Implement 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 rows ...
magic_instruct_75k
55,786
Write a Python function to extract named groups from a given URL pattern using regular expressions. Named groups in a regular expression are specified using the `(?P<name>...)` syntax. The function should return a list of all the named groups present in the URL pattern. The code should start with: ```python import re ...
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def extract_named_groups(url_pattern: str) -> List[str]: """ Extracts named groups from a given URL pattern using regular expressions. Args: url_pattern (str): The URL pattern cont...
magic_instruct_75k
55,790
Write a Python function to process command-line arguments and generate a settings configuration string based on the input. The function should handle multiple options and arguments and ensure that the `SETTINGS_OPTIONS` variable is correctly formatted for further processing. The function should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_settings_options(args: List[str]) -> str: """ Generates a settings configuration string based on the command-line arguments. Args: args (List[str]): A list of command-line argum...
magic_instruct_75k
55,813
Write a Python function to calculate the average population of all cities in a specific country from a given list of `City` namedtuples. Each `City` namedtuple contains the following fields: `name` (string), `country` (string), `population` (int), and `coordinates` (tuple of floats). The function should return the aver...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import namedtuple from typing import List City = namedtuple('City', 'name country population coordinates') def average_population_in_country(cities: List[City], country: str) -> float: """ Calculate the averag...
magic_instruct_75k
55,817
Write a Python function to parse a Git LFS (Large File Storage) pointer file and extract the version, SHA256 hash, and size of the large file. The function should take the pointer file content as a string and return the extracted information in a formatted string. The format of the Git LFS pointer file is as follows: ...
Here is the Python code to solve the given problem in the markdown block: ```python import re def parse_git_lfs_pointer(pointer_file: str) -> str: """ Parses a Git LFS pointer file and extracts the version, SHA256 hash, and size of the large file. Args: pointer_file (str): The content of the Git L...
magic_instruct_75k
55,820
Write a Python function to determine the winner of a tic-tac-toe game based on a given 3x3 board. The board is represented as a 2D list where each cell can be either "X", "O", or empty (" "). The function should return "X" if player X wins, "O" if player O wins, or "Tie" if the game is a tie. If the game is still ongoi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_win(board: List[List[str]]) -> str: """ Determine the winner of a tic-tac-toe game based on a given 3x3 board. Args: board (List[List[str]]): A 3x3 grid representing the tic-tac-to...
magic_instruct_75k
55,850
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 function 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
55,891
Write a Python function to determine the number of forbidden request header names in a given set of header key-value pairs based on a predefined safelist. The safelist contains allowed header names, and any header not in the safelist is considered forbidden. The function should return the count of forbidden header name...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Set def count_forbidden_headers(headers: Dict[str, str], safelist: Set[str]) -> int: """ Counts the number of forbidden request header names in a given set of header key-value pairs based on a predefine...
magic_instruct_75k
55,900
Write a Python function to process a list of tuples representing characters' attributes in a game. Each tuple contains the following elements in order: character name (string), health points (integer), attack points (integer), and defense points (integer). The function should return a dictionary where the keys are the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def process_characters(deathmask_nezumi: List[Tuple[str, int, int, int]]) -> Dict[str, int]: """ Processes a list of tuples representing characters' attributes and returns a dictionary w...
magic_instruct_75k
55,902
Implement a stack data structure using an array in Python. The stack should support the following operations: 1. `push(int val)`: Add an element to the top of the stack. 2. `pop()`: Remove the element from the top of the stack and return its value. 3. `top()`: Return the value of the top element without removing it. 4....
Here is the Python code to solve the given problem in the markdown block: ```python class StackArray: def __init__(self, capacity: int): """ Initialize the stack with the given capacity. Args: capacity (int): The maximum number of elements the stack can hold. """ ...
magic_instruct_75k
55,904
Write a Python function to find the length of a singly linked list. The function should take the head of the linked list as a parameter and return the length of the linked list. The linked list is defined as follows: ```python class ListNode: def __init__(self, value=0, next=None): self.value = 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 find_linked_list_length(head: ListNode) -> int: """ Calculate the length of a singly linked list. Args: ...
magic_instruct_75k
55,930
Write a Python program that performs specific operations on given variables and an array. The program should: 1. Increment the value of `us` by 10. 2. Calculate the square of the value of `i`. 3. Check if the value of `ui` is a multiple of 5. 4. Print the length of the string `string`. The program should output the re...
Here is the Python code to solve the given problem in the markdown block: ```python def perform_operations(us: int, i: int, ui: int, string: str) -> None: """ Performs specific operations on the given variables and prints the results. Args: us (int): An unsigned short integer. i (int): An i...
magic_instruct_75k
55,941
Write a Python function to update a list of existing URL patterns with a list of new URL patterns. The function should return the updated list of URL patterns after adding the new ones. The function should handle cases where the input lists are empty or contain duplicate patterns. 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 def update_url_patterns(existing_patterns: List[str], new_patterns: List[str]) -> List[str]: """ Updates the list of existing URL patterns with new URL patterns. Args: existing_patterns (Lis...
magic_instruct_75k
55,943
Write a Python function to load a dynamic library in a cross-platform manner. The function should handle loading the library based on the platform it is running on. For Android, the function should construct the library path based on the current app name obtained from the command line. For other platforms, it should lo...
Here is the Python code to solve the given problem in the markdown block: ```python import os import sys import platform def load_library(name: str) -> str: """ Load a dynamic library in a cross-platform manner. For Android, constructs the library path based on the current app name obtained from the comma...
magic_instruct_75k
55,959
Write a Python function to parse a JSON-like data structure representing a network management system and extract specific information. The function should take the JSON-like data structure as input and return a dictionary containing the following information: 1. The OID (object identifier) value. 2. The status of the o...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def parseNetworkData(data: Dict) -> Dict[str, str or List[str]]: """ Parses a JSON-like data structure representing a network management system and extracts specific information. Args: ...
magic_instruct_75k
55,960
Write a Python function to analyze a given software license text and count the occurrences of the words "WARRANTIES" and "CONDITIONS" in a case-insensitive manner. The function should return a dictionary with the counts of these words. The code should start with: ```python def count_warranties_conditions(license_text:...
Here is the Python code to solve the given problem in the markdown block: ```python def count_warranties_conditions(license_text: str) -> dict: """ Analyzes the given software license text to count the occurrences of the words "WARRANTIES" and "CONDITIONS" in a case-insensitive manner. Args: licens...