source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
4,596
Write a Python function to implement the Quick Sort algorithm that not only sorts the given array of integers but also efficiently handles duplicate integers. The function should be able to handle larger arrays efficiently. The code should start with: ```python from typing import List def quicksort_with_duplicates(arr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def quicksort_with_duplicates(arr: List[int]) -> List[int]: """ Sorts the given array of integers using the Quick Sort algorithm, efficiently handling duplicate integers. Args: arr (List[int...
evol_instruct_66k
4,606
Write a Python function to determine if the digits of a second numerical string (`num_str2`) appear in the same sequential order within a first numerical string (`num_str1`). The function should return `True` if the sequence of digits in `num_str2` is maintained in `num_str1`, and `False` otherwise. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python def check_sequence_order(num_str1: str, num_str2: str) -> bool: """ Determines if the digits of num_str2 appear in the same sequential order within num_str1. Args: num_str1 (str): The first numerical string. ...
evol_instruct_66k
4,615
Write a Python function to find the maximal value in a given list of integers. The function should be efficient and handle any size of input list. The code should start with: ```python from typing import List def find_max_value(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def find_max_value(numbers: List[int]) -> int: """ Find the maximal value in a given list of integers. Args: numbers (List[int]): The list of integers from which to find the maximal value....
evol_instruct_66k
4,645
Write a Python function to convert an octal number (represented as a string) to its hexadecimal representation (also represented as a string). The function should handle any valid octal input and return the corresponding hexadecimal string in uppercase. The code should start with: ```python def octal_to_hex(octal: str...
Here is the Python code to solve the given problem in the markdown block: ```python def octal_to_hex(octal: str) -> str: """ Convert an octal number (represented as a string) to its hexadecimal representation (also represented as a string). Args: octal (str): The octal number to be converted. ...
evol_instruct_66k
4,657
Write a Python function that takes two sets as input and returns a tuple containing four sets: the union of the two sets, the intersection of the two sets, the difference between the first set and the second set, and the difference between the second set and the first set. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Set, Tuple def set_operations(s1: Set[int], s2: Set[int]) -> Tuple[Set[int], Set[int], Set[int], Set[int]]: """ Perform set operations on two given sets and return the results. Args: s1 (Set[int]...
evol_instruct_66k
4,658
Write a Python function to calculate the sum of the squares of the first n natural numbers, where n is a positive integer. The function should print the current number, its square, and the running total of squares at each step of the iteration process. The code should start with: ```python def sum_of_squares(n: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_squares(n: int) -> None: """ Calculate and print the sum of the squares of the first n natural numbers. Prints the current number, its square, and the running total of squares at each step. Args: n (i...
evol_instruct_66k
4,663
Write a Python function to find and return the three smallest elements from a given list of integers. The function should be efficient and should handle cases where the list has fewer than three elements. The code should start with: ```python from typing import List def get_three_smallest_elements(array: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import heapq def get_three_smallest_elements(array: List[int]) -> List[int]: """ Returns the three smallest elements from the given list of integers. Args: array (List[int]): The list of i...
evol_instruct_66k
4,680
Write a Python function to find the common elements between two given lists of integers. The function should return a list of these common elements in ascending order. The code should start with: ```python from typing import List def find_common_elements(arr1: List[int], arr2: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(arr1: List[int], arr2: List[int]) -> List[int]: """ Find the common elements between two lists of integers and return them in ascending order. Args: arr1 (List[int])...
evol_instruct_66k
4,695
Write a Python function to generate an output array where each element is the cumulative sum of the preceding elements from the initial array. The function should start with: ```python from typing import List def cumulative_sum(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def cumulative_sum(arr: List[int]) -> List[int]: """ Generate an output array where each element is the cumulative sum of the preceding elements from the initial array. Args: arr (List[int...
evol_instruct_66k
4,719
Write a Python function to calculate the distance between two points in a two-dimensional Cartesian plane and determine the quadrant of a given point. The function should handle points with floating-point coordinates. The code should start with: ```python from typing import Tuple def calculate_distance_and_quadrant(po...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import math def calculate_distance_and_quadrant(point1: Tuple[float, float], point2: Tuple[float, float]) -> Tuple[float, int]: """ Calculate the distance between two points in a two-dimensional Cartesi...
evol_instruct_66k
4,721
Write a Python function to count the occurrences of each alphabetic character in a given 2D matrix. The function should ignore case differences and return a dictionary where the keys are the lowercase letters and the values are their respective counts. The code should start with: ```python from typing import List, Dic...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_alphabetic_chars(matrix: List[List[str]]) -> Dict[str, int]: """ Count the occurrences of each alphabetic character in a given 2D matrix, ignoring case differences. Args: mat...
evol_instruct_66k
4,723
Write a Python function to generate a dictionary where each key is an integer ranging from 1 to `n` (inclusive) and the corresponding value is the square of the respective key. The function should handle the case where `n` is less than 1 by returning an empty dictionary. The code should start with: ```python def gener...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_square_dict(n: int) -> dict: """ Generate a dictionary where each key is an integer from 1 to n (inclusive) and the corresponding value is the square of the key. Args: n (int): The upper limit for t...
evol_instruct_66k
4,727
Write a Python function to sort a dictionary by its values in ascending order. The dictionary contains string keys and integer values. The function should return a new dictionary with the same keys and values, but sorted by the values. The code should start with: ```python from typing import Dict def sort_dict_by_val...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dict_by_values(my_dict: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary by its values in ascending order. Args: my_dict (Dict[str, int]): The dictionary to be sorted. ...
evol_instruct_66k
4,744
Write a Python function to construct a JSON structure that encapsulates the given individual characteristics. The characteristics include the full personal name, age in calendar years, and occupation. The function should ensure that the JSON structure is grammatically flawless and follows the specified format. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python import json def create_personal_json(full_name: str, age: int, occupation: str) -> str: """ Constructs a grammatically flawless JSON structure that encapsulates the given individual characteristics. Args: full_name...
evol_instruct_66k
4,751
Write a Python function to generate an updated list by multiplying each element in a given list by a specified factor. The function should handle lists of integers and allow for a custom factor to be applied to each element. The code should start with: ```python from typing import List def multiply_list_elements(origi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def multiply_list_elements(original_list: List[int], factor: int) -> List[int]: """ Generate an updated list by multiplying each element in the given list by the specified factor. Args: orig...
evol_instruct_66k
4,757
Write a Python function to find all unique divisors of a given numeric value (excluding 1 and the number itself) and determine the prime factors of each identified divisor. The function should return a dictionary where the keys are the divisors and the values are lists of their prime factors. The function should be opt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def find_divisors_and_prime_factors(n: int) -> Dict[int, List[int]]: """ Finds all unique divisors of a given number (excluding 1 and the number itself) and determines the prime factors of each...
evol_instruct_66k
4,769
Write a Python function to generate a list of the first `n` multiples of a given integer `k`. The function should handle edge cases such as `n` being zero or negative, and `k` being zero. The code should start with: ```python from typing import List def generate_multiples(k: int, n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_multiples(k: int, n: int) -> List[int]: """ Generate a list of the first n multiples of a given integer k. Args: k (int): The integer whose multiples are to be generated. ...
evol_instruct_66k
4,790
Write a Python function to perform exponentiation of an n x n matrix by a given power using the matrix multiplication method. The function should handle the case where the power is 0 by returning the identity matrix of size n x n. The function should also handle negative powers by raising an appropriate exception. The...
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]], n: int) -> List[List[int]]: """ Multiplies two n x n matrices A and B. Args: A (List[List[int]]): The first matrix. ...
evol_instruct_66k
4,791
Write a Python function to generate a clockwise spiral sequence from a given 2D matrix of integers. The function should traverse the matrix in a spiral order, starting from the top-left corner and moving right, down, left, and up in a cyclic manner, collecting all elements in the order they are visited. The code shoul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_spiral_sequence(matrix: List[List[int]]) -> List[int]: """ Generates a clockwise spiral sequence from a given 2D matrix of integers. Args: matrix (List[List[int]]): The 2D matri...
evol_instruct_66k
4,810
Write a Python function to accurately compute the sum of a list of numbers. The function should handle both positive and negative integers, as well as floating-point numbers. Additionally, ensure that the function can handle an empty list by returning 0. The code should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_sum(numbers: List[float]) -> float: """ Computes the sum of a list of numbers. Args: numbers (List[float]): A list of numbers (integers or floating-point numbers). Returns...
evol_instruct_66k
4,813
Write a Python function to generate an array of length `N` from a given list of values, while rotating each subsequent array element by a specified constant `K`. The function should handle boundary conditions where `N` is greater than the length of the given list or where `K` exceeds the length of the given list. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_rotated_array(given_list: List[int], N: int, K: int) -> List[int]: """ Generates an array of length N from a given list of values, while rotating each subsequent array element by a specified...
evol_instruct_66k
4,819
Write a Python function to merge two dictionaries into a single dictionary. If both dictionaries have the same key, the value from the second dictionary should overwrite the value from the first dictionary. The function should handle any number of dictionaries provided as input. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any, List def merge_dictionaries(dicts: List[Dict[Any, Any]]) -> Dict[Any, Any]: """ Merge a list of dictionaries into a single dictionary. If there are duplicate keys, the value from the last dicti...
evol_instruct_66k
4,821
Write a Python function that prints each element of a given list using a `while` loop instead of a `for` loop. The function should take a list as input and print each element on a new line. The code should start with: ```python from typing import List def print_elements_while(mylist: List[int]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_elements_while(mylist: List[int]) -> None: """ Prints each element of the given list using a while loop. Args: mylist (List[int]): The list of integers to be printed. Returns:...
evol_instruct_66k
4,822
Write a Python function to generate a matrix where each row represents the prime factors of the corresponding number starting from 2 up to a given integer `n`. The function should return a list of lists, where each inner list contains the prime factors of the corresponding number. 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 prime_factors(n: int) -> List[int]: """ Returns a list of prime factors of the given integer n. Args: n (int): The integer to factorize. Returns: List[int]: A list of prime ...
evol_instruct_66k
4,824
Write a Python function to calculate the median compensation of employees within a specific occupational sector (either "Data Science" or "Software Engineering") from a given list of employee records. Each employee record is represented as a dictionary with keys `"_id"`, `"name"`, `"occupation"`, and `"salary"`. The fu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def median_compensation(employees: List[Dict[str, str]], occupation: str) -> float: """ Calculate the median compensation of employees within a specific occupational sector. Args: empl...
evol_instruct_66k
4,827
Implement a Python function to sort a list of integers in ascending order using the Quick Sort algorithm. The function should be able to handle lists of varying lengths, including empty lists and lists with duplicate elements. The code should start with: ```python from typing import List def quick_sort(lst: List[int])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def quick_sort(lst: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the Quick Sort algorithm. Args: lst (List[int]): The list of integers to be sorted. Re...
evol_instruct_66k
4,845
Write a Python function to count the frequency of a specific number in a given list of integers. The function should return the count of the specified number in the list. The code should start with: ```python from typing import List def count_frequency(numbers: List[int], target: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_frequency(numbers: List[int], target: int) -> int: """ Counts the frequency of a specific number in a given list of integers. Args: numbers (List[int]): The list of integers in whi...
evol_instruct_66k
4,862
Write a Python function to transform all instances of a specified punctuation symbol within a given text string into another specified character. The function should replace each occurrence of the punctuation symbol with the specified character and return the resultant manipulated string. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python def transform_punctuation(text: str, punctuation: str, replacement: str) -> str: """ Transforms all instances of a specified punctuation symbol within a given text string into another specified character. Args: text...
evol_instruct_66k
4,863
Write a Python function to search for an item in a 2D array (list of lists) and return its coordinates if found. If the item is not found, return `None`. The function should handle any rectangular 2D array, including empty arrays. The code should start with: ```python from typing import List, Tuple, Optional def sear...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Optional def search_2d_array(arr: List[List[int]], item: int) -> Optional[Tuple[int, int]]: """ Searches for an item in a 2D array and returns its coordinates if found. Args: arr (Li...
evol_instruct_66k
4,875
Write a Python function to sort a dictionary of dwarfs' names and their corresponding ages in ascending order based on their ages. If two dwarfs have the same age, sort them alphabetically by their names. The function should return the sorted dictionary. The code should start with: ```python from typing import Dict d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dwarfs_by_age(dwarfs: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary of dwarfs' names and ages in ascending order based on their ages. If two dwarfs have the same age, they are so...
evol_instruct_66k
4,889
Write a Python function to count the number of negative numbers in a given 2D matrix that is sorted in decreasing order both row-wise and column-wise. The function should efficiently utilize the properties of the matrix to achieve better performance than a simple brute-force approach. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_negative_numbers(matrix: List[List[int]]) -> int: """ Counts the number of negative numbers in a given 2D matrix that is sorted in decreasing order both row-wise and column-wise. Args: ...
evol_instruct_66k
4,893
Write a Python function to calculate the arithmetic sum of integers from `a` to `b` (inclusive) efficiently. The function should handle cases where `a` is greater than `b` by raising a `ValueError`. The function should also be optimized to avoid the use of loops, leveraging mathematical formulas instead. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python def arithmetic_sum(a: int, b: int) -> int: """ Calculate the arithmetic sum of integers from `a` to `b` (inclusive). Args: a (int): The start of the range (inclusive). b (int): The end of the range (inclusiv...
evol_instruct_66k
4,896
Write a Python function to calculate the minimum number of steps required to get exactly `n` 'A' characters on a notepad, starting with one 'A'. The allowed operations are: 1. **Copy All**: Copy all characters present on the notepad. 2. **Paste**: Paste the characters which were copied last time. 3. **Delete**: Delete ...
Here is the Python code to solve the given problem in the markdown block: ```python def min_steps_to_n_A(n: int) -> int: """ Calculate the minimum number of steps required to get exactly `n` 'A' characters on a notepad. Args: n (int): The target number of 'A' characters. Returns: int: ...
evol_instruct_66k
4,900
Write a Python function to generate a list of all even integers within a specified range [m, n], where both m and n are positive integers. The function should handle cases where m is greater than n by returning an empty list. The code should start with: ```python from typing import List def generate_even_numbers(m: in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_even_numbers(m: int, n: int) -> List[int]: """ Generate a list of all even integers within the range [m, n]. Args: m (int): The start of the range (inclusive). n (int): ...
evol_instruct_66k
4,929
Design a Python data structure to efficiently store and retrieve all prime numbers up to a given limit `n`. The data structure should be optimized for both storage and retrieval operations. The code should start with: ```python from typing import List def generate_primes(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def generate_primes(n: int) -> List[int]: """ Generate a list of all prime numbers up to a given limit n using the Sieve of Eratosthenes algorithm. Args: n (int): The upper limit...
evol_instruct_66k
4,944
Write a Python function to generate a new list where each element is the square of the corresponding element in the input list. The function should use list comprehension for this purpose. The code should start with: ```python from typing import List def square_elements(input_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def square_elements(input_list: List[int]) -> List[int]: """ Generates a new list where each element is the square of the corresponding element in the input list. Args: input_list (List[int]...
evol_instruct_66k
4,947
Write a Python function to segregate a list of integers into two separate lists: one containing all even numbers and the other containing all odd numbers. The function should return a tuple containing the two lists. The code should start with: ```python from typing import List, Tuple def segregate_numbers(numbers: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def segregate_numbers(numbers: List[int]) -> Tuple[List[int], List[int]]: """ Segregates a list of integers into two lists: one for even numbers and one for odd numbers. Args: numbers...
evol_instruct_66k
4,997
Write a Python function to invert the order of an array of integers without utilizing any predefined or built-in methods for reversing the array. The function should handle potential edge cases, such as empty arrays or arrays of length 1. The code should be efficient and should start with: ```python from typing import ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_array(input_arr: List[int]) -> List[int]: """ Reverses the order of an array of integers without using any built-in methods. Args: input_arr (List[int]): The array of integers to...
evol_instruct_66k
4,998
Write a Python function to randomly shuffle the elements of a given list of integers. The function should take a list of integers as input and return a new list with the same elements but in a random order. The original list should not be modified. The code should start with: ```python from typing import List import r...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def shuffle_list(numbers: List[int]) -> List[int]: """ Randomly shuffles the elements of a given list of integers. Args: numbers (List[int]): The list of integers to be shuffle...
evol_instruct_66k
5,002
Write a Python function to find the smallest positive integer that is not present in a given list of integers. The function should handle arrays with negative numbers and non-contiguous sequences efficiently. The code should start with: ```python from typing import List def find_smallest_missing_positive(arr: List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_smallest_missing_positive(arr: List[int]) -> int: """ Find the smallest positive integer that is not present in the given list. Args: arr (List[int]): The list of integers to search...
evol_instruct_66k
5,012
Write a Python function to remove sequential duplicate entries from a given list of strings. The function should return a new list with all sequential duplicates removed, preserving the order of the first occurrence of each unique element. The code should start with: ```python from typing import List def remove_seque...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_sequential_duplicates(arr: List[str]) -> List[str]: """ Removes sequential duplicate entries from a given list of strings. Args: arr (List[str]): The list of strings from which to...
evol_instruct_66k
5,035
Write a Python function to remove consecutive duplicate elements from a given list. The function should return a new list with all consecutive duplicates removed, preserving the order of the first occurrence of each element. The code should start with: ```python from typing import List def remove_consecutive_duplicat...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_consecutive_duplicates(array: List[str]) -> List[str]: """ Removes consecutive duplicate elements from the given list of strings. Args: array (List[str]): The list of strings from...
evol_instruct_66k
5,039
Write a Python function to calculate the aggregate tally of elements within a compound, multi-tiered data structure. The data structure can contain both discrete values and nested sequences (lists). The function should recursively traverse the structure to sum all the elements. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List def get_aggregate_tally(array: Union[List, int]) -> int: """ Calculate the aggregate tally of elements within a compound, multi-tiered data structure. Args: array (Union[List, int]): ...
evol_instruct_66k
5,046
Write a Python function to sort a given list of names alphabetically in ascending order. The function should handle lists of varying lengths and should be case-insensitive. The code should start with: ```python from typing import List def sort_names(names: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sort_names(names: List[str]) -> List[str]: """ Sorts a given list of names alphabetically in ascending order, case-insensitively. Args: names (List[str]): A list of names to be sorted....
evol_instruct_66k
5,051
Write a Python function to compute the Kronecker product of two given 2D arrays using the NumPy library. The Kronecker product is a non-commutative operation that produces a block matrix from two input matrices. The code should start with: ```python from typing import List import numpy as np def kronecker_product(arra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import numpy as np def kronecker_product(array1: List[List[int]], array2: List[List[int]]) -> np.ndarray: """ Compute the Kronecker product of two 2D arrays. Args: array1 (List[List[int]]): ...
evol_instruct_66k
5,072
Write a Python function to display the elements of a bi-dimensional matrix in a spiral order starting from the top left corner. The matrix could be of different widths and heights. The function should handle matrices of any size, including empty matrices. The code should start with: ```python from typing import List ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def spiral_order(matrix: List[List[int]]) -> List[int]: """ Display the elements of a bi-dimensional matrix in a spiral order starting from the top left corner. Args: matrix (List[List[int]]...
evol_instruct_66k
5,103
Write a Python function to implement an optimized Bubble Sort algorithm that is adaptive, meaning it should recognize if the input array is already sorted or nearly sorted and finish in linear time complexity. The function should return the sorted array. The code should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def optimized_bubble_sort(arr: List[int]) -> List[int]: """ Sorts the input array using an optimized Bubble Sort algorithm. The algorithm is adaptive, meaning it will terminate early if the array is ...
evol_instruct_66k
5,113
Write a Python function to perform the mathematical operation of addition on a list of integers. The function should take a list of integers as input and return the sum of all the integers in the list. The code should start with: ```python from typing import List def sum_of_integers(numbers: 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_integers(numbers: List[int]) -> int: """ Calculate the sum of all integers in the given list. Args: numbers (List[int]): A list of integers to be summed. Returns: int...
evol_instruct_66k
5,115
Write a Python function to determine if any number in a given list of integers is a perfect square. The function should return a list of boolean values, where each boolean value indicates whether the corresponding integer in the input list is a perfect square. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def check_perfect_squares(num_array: List[int]) -> List[bool]: """ Determines if each number in the given list is a perfect square. Args: num_array (List[int]): A list of integer...
evol_instruct_66k
5,139
Write a Python function to perform integer division of two integers and return the result. The function should handle cases where the divisor is zero by returning a special value, such as `None`. The code should start with: ```python def integer_division(dividend: int, divisor: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def integer_division(dividend: int, divisor: int) -> int: """ Perform integer division of two integers and return the result. If the divisor is zero, return None to avoid division by zero errors. Args: dividend ...
evol_instruct_66k
5,140
Write a Python function to generate a list of prime numbers within a specified range `[start, end]` and another function to verify if a given number is prime. The generated list should only include numbers within the specified range. The code should start with: ```python from typing import List def is_prime(n: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_prime(n: int) -> bool: """ Check if a given number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise...
evol_instruct_66k
5,156
Write a Python function to sort a list in ascending order using the Bubble Sort algorithm without using the built-in `sort()` method. The function should take a list of integers as input and return the sorted list. The code should start with: ```python from typing import List def bubble_sort(arr: List[int]) -> List[in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the Bubble Sort algorithm. Args: arr (List[int]): The list of integers to be sorted. ...
evol_instruct_66k
5,187
Write a Python function to generate and initialize two vacant array lists of a specified length, where each element in the arrays is initialized to a given value. The function should return the two initialized arrays. The code should start with: ```python from typing import List def initialize_arrays(length: int, val...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def initialize_arrays(length: int, value: int) -> List[List[int]]: """ Generates and initializes two vacant array lists of a specified length, where each element in the arrays is initialized to a given v...
evol_instruct_66k
5,196
Write a Python function to generate the Fibonacci sequence up to the nth term. The function should return a list containing the Fibonacci sequence. The code should start with: ```python from typing import List def fibonacci_sequence(n: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def fibonacci_sequence(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the nth term. Args: n (int): The number of terms in the Fibonacci sequence to generate. Returns:...
evol_instruct_66k
5,201
Write a Python function to create a new list from a given list, where each element in the new list is the square of the corresponding element in the original list if the element is a positive integer, and the cube if the element is negative. The function should use only lambda functions and the `map` function. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def transform_list(data: List[int]) -> List[int]: """ Transforms a list of integers such that each positive integer is squared and each negative integer is cubed. Args: data (List[int]): The...
evol_instruct_66k
5,241
Write a Python function to find the third largest element in a given list of integers. The function should handle lists with duplicate values and ensure that the third largest element is correctly identified. If the list has fewer than three unique elements, the function should return `None`. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_third_largest(numbers: List[int]) -> Optional[int]: """ Find the third largest element in a given list of integers. Args: numbers (List[int]): The list of integers from wh...
evol_instruct_66k
5,244
Write a Python function to find the maximum value in a given list of integers. The function should iterate through the list and keep track of the maximum value encountered. The code should start with: ```python from typing import List def find_max_value(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_value(arr: List[int]) -> int: """ Find the maximum value in a given list of integers. Args: arr (List[int]): The list of integers from which to find the maximum value. Retu...
evol_instruct_66k
5,258
Write a Python function to intertwine two distinct strings by alternating their characters. If the strings are of different lengths, append the remaining characters of the longer string to the result. The function should start with: ```python def intertwine_strings(str1: str, str2: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def intertwine_strings(str1: str, str2: str) -> str: """ Intertwines two strings by alternating their characters. If the strings are of different lengths, appends the remaining characters of the longer string to the result. ...
evol_instruct_66k
5,266
Write a Python function to sort an array of user data in descending order based on the user's surname. The function should ensure that the individual with the last name closest to the end of the alphabet is positioned first. The code should start with: ```python from typing import List, Dict def sort_users_by_surname(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_users_by_surname(users: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts an array of user data in descending order based on the user's surname. Args: users (List[Dict[...
evol_instruct_66k
5,268
Write a Python function to convert an angle from gradians to degrees. The function should take a single argument representing the angle in gradians and return the equivalent angle in degrees. The conversion formula is: \[ \text{degrees} = \text{gradians} \times 0.9 \] The code should start with: ```python def gradians...
Here is the Python code to solve the given problem in the markdown block: ```python def gradians_to_degrees(gradians: float) -> float: """ Convert an angle from gradians to degrees. Args: gradians (float): The angle in gradians to be converted. Returns: float: The equivalent angle in d...
evol_instruct_66k
5,276
Write a Python function to replace all occurrences of 'A' with '#' and all occurrences of 'a' with '*' in a given string while preserving the original case. The input string can contain ASCII characters only. The function should start with: ```python def replace_a_with_symbol(sentence: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def replace_a_with_symbol(sentence: str) -> str: """ Replace all occurrences of 'A' with '#' and all occurrences of 'a' with '*' in the given string. Args: sentence (str): The input string containing ASCII charact...
evol_instruct_66k
5,278
Write a Python function to convert an octal number to its equivalent hexadecimal representation. The function should take an octal number as input and return its hexadecimal equivalent as a string. The code should start with: ```python def octal_to_hexadecimal(octal: int) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def octal_to_hexadecimal(octal: int) -> str: """ Convert an octal number to its equivalent hexadecimal representation. Args: octal (int): The octal number to be converted. Returns: str: The hexadecimal ...
evol_instruct_66k
5,290
Write a Python function to divide a given list of numerical data points into two mirror-image subdivisions. The function should ensure that the two halves are mirror images of each other, meaning that the elements in the second half are the reverse of the elements in the first half. If the list has an odd number of ele...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def divide_into_mirror_halves(arr: List[int]) -> Tuple[List[int], List[int]]: """ Divides a given list of numerical data points into two mirror-image subdivisions. Args: arr (List[int...
evol_instruct_66k
5,302
Write a Python function to convert a given 24-hour time string into its corresponding 12-hour time format with AM/PM indication. The input time string is in the format "HH:MM". The function should return a string in the format "HH:MM AM/PM". The code should start with: ```python from datetime import datetime def conv...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime def convert_24_to_12_hour_format(time_str: str) -> str: """ Convert a given 24-hour time string into its corresponding 12-hour time format with AM/PM indication. Args: time_str (str): ...
evol_instruct_66k
5,308
Write a Python function to generate a random number within a specified range, allowing the user to specify whether the endpoints of the range are included or excluded. The function should ensure that the distribution of the generated numbers is uniform. The code should start with: ```python import random def generate...
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(start: int, end: int, include_start: bool = True, include_end: bool = True) -> int: """ Generates a random integer within a specified range, with customizable inclusion of the range endp...
evol_instruct_66k
5,318
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of a 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 a m x n grid. Args: m (int): The number of rows...
evol_instruct_66k
5,320
Write a Python function to extract all distinct elements from a provided data collection and return them in descending order according to their occurrences. The data collection is a list of tuples where each tuple contains an element and its occurrence count. The function should start with: ```python from typing import...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple from collections import Counter def extract_distinct_elements(data_collection: List[Tuple[str, int]]) -> List[Tuple[str, int]]: """ Extracts all distinct elements from a provided data collection a...
evol_instruct_66k
5,325
Write a Python function to substitute every occurrence of a specified digit with a specified character in a given numerical string. The function should take three parameters: the numerical string, the digit to be replaced, and the character to replace the digit with. The function should return the modified string. The...
Here is the Python code to solve the given problem in the markdown block: ```python def substitute_digit_with_char(num_str: str, digit: str, char: str) -> str: """ Substitutes every occurrence of a specified digit with a specified character in a given numerical string. Args: num_str (str): The nume...
evol_instruct_66k
5,326
Write a Python function to generate all possible permutations of `k` numbers from the sequence `[1, n]`. The sequence in which the permutations are returned does not matter. The function should start with: ```python from typing import List def generate_permutations(n: int, k: int) -> List[List[int]]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from itertools import permutations def generate_permutations(n: int, k: int) -> List[List[int]]: """ Generate all possible permutations of k numbers from the sequence [1, n]. Args: n (int): ...
evol_instruct_66k
5,332
Write a Python function to transform a given character sequence of space-separated floating-point numbers into a list of floating-point numbers. The function should handle the input as a single string and return a list of floats. The code should start with: ```python from typing import List def transform_to_float_lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def transform_to_float_list(char_sequence: str) -> List[float]: """ Transforms a character sequence of space-separated floating-point numbers into a list of floating-point numbers. Args: cha...
evol_instruct_66k
5,333
Write a Python function to substitute each occurrence of the character '0' with the character 'x' in a given 2D matrix of character elements. The function should achieve this without using nested loops, recursion, or built-in functions like `replace()`. The code should start with: ```python from typing import List def...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def replace_zero_in_matrix(matrix: List[List[str]]) -> List[List[str]]: """ Substitutes each occurrence of the character '0' with the character 'x' in a given 2D matrix of character elements. Args: ...
evol_instruct_66k
5,334
Write a Python function to manage a list of musical track titles. The function should allow adding a new track title to the list and retrieving the list of track titles. The function should handle cases where the input is not a string and should not add such inputs to the list. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def manage_track_titles(track_titles: List[str], new_track: str) -> List[str]: """ Manages a list of musical track titles by adding a new track title if it is a string. Args: track_titles (L...
evol_instruct_66k
5,337
Write a Python function to generate a "display table" for food orders in a restaurant. The function should take a list of orders, where each order is represented as a list containing the customer's name, table number, and food item. The function should return a list of lists representing the display table. The first ro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import Counter def display_table(orders: List[List[str]]) -> List[List[str]]: """ Generates a display table for food orders in a restaurant. Args: orders (List[List[str]]): ...
evol_instruct_66k
5,342
Write a Python function to convert a given binary number represented as a string to its decimal (base-10) equivalent. The function should handle binary numbers of any length and should return the decimal value as an integer. The code should start with: ```python def binary_to_decimal(binary: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def binary_to_decimal(binary: str) -> int: """ Converts a given binary number represented as a string to its decimal (base-10) equivalent. Args: binary (str): The binary number to be converted, represented as a stri...
evol_instruct_66k
5,345
Write a Python function to transform a given list of numerical values into a dictionary where the keys are the indices of the elements in the list (starting from 1) and the values are the corresponding elements from the list. The code should start with: ```python from typing import List, Dict def list_to_dict(arr: Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def list_to_dict(arr: List[int]) -> Dict[int, int]: """ Transforms a list of numerical values into a dictionary where the keys are the indices of the elements (starting from 1) and the values are t...
evol_instruct_66k
5,347
Write a Python function to calculate the arithmetic mean of a list of numerical values. The function should handle the case where the list is empty by returning 0. The code should start with: ```python from typing import List def calculate_average(numbers: List[float]) -> float: ```
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 arithmetic mean of a list of numerical values. Args: numbers (List[float]): A list of numerical values. Returns: ...
evol_instruct_66k
5,355
Write a Python function to duplicate a given list and subtract a specified value from each element in the duplicated list. The function should return the modified duplicated list. The code should start with: ```python from typing import List def duplicate_and_subtract(original_list: List[int], subtract_value: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def duplicate_and_subtract(original_list: List[int], subtract_value: int) -> List[int]: """ Duplicates the given list and subtracts a specified value from each element in the duplicated list. Args: ...
evol_instruct_66k
5,359
Write a Python function to find and return the string with the greatest length from a given list of strings. The function should handle an empty list by returning `None`. The code should start with: ```python from typing import List, Optional def find_longest_string(strings: List[str]) -> Optional[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_longest_string(strings: List[str]) -> Optional[str]: """ Finds and returns the string with the greatest length from a given list of strings. Args: strings (List[str]): A l...
evol_instruct_66k
5,362
Write a Python function to generate a random number between two given integers, inclusive of both endpoints. The function should handle cases where the start value is greater than the end value by swapping them. Additionally, the function should ensure that the input values are integers and handle cases where the input...
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(start: int, end: int) -> int: """ Generate a random integer between two given integers, inclusive of both endpoints. Args: start (int): The lower bound of the range (inclusi...
evol_instruct_66k
5,367
Write a Python function to traverse a multi-dimensional array of discrete numerical quantities, identify prime numbers, and handle any exceptions that might occur. The function should also manage memory allocation explicitly by using a generator to yield prime numbers one by one. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Generator def check_prime(n: int) -> bool: """ Check if a given number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise...
evol_instruct_66k
5,371
Write a Python function to find the suppliers who have encountered product recall issues based on a given dataset. The dataset is a list of dictionaries, where each dictionary represents a product with keys `product_id`, `product_name`, and `supplier_id`. The function should return a set of unique supplier IDs that hav...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Set def find_recall_suppliers(products: List[Dict[str, str]]) -> Set[str]: """ Find the suppliers who have encountered product recall issues. Args: products (List[Dict[str, str]]): A ...
evol_instruct_66k
5,378
Write a Python function to safely access an element in a string by its index, handling any potential errors that might occur. The function should return the character at the specified index if it is within the bounds of the string, and a default value if the index is out of range. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python def safe_access_string(s: str, index: int, default: str = None) -> str: """ Safely access an element in a string by its index, handling any potential errors. Args: s (str): The input string from which to access the ...
evol_instruct_66k
5,383
Write a Python function to check if a given number is prime and to find all prime numbers up to a given limit using the Sieve of Eratosthenes algorithm. The function should efficiently handle a large range of numbers (up to 10^6). The code should start with: ```python def is_prime(n: int) -> bool: def find_primes_up_to...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(n: int) -> bool: """ Check if a given number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. """ if n < 2: ...
evol_instruct_66k
5,384
Write a Python function to multiply two given matrices. The function should check if the matrices are compatible for multiplication (i.e., the number of columns in the first matrix should be equal to the number of rows in the second matrix). If the matrices are not compatible, the function should raise an `AssertionErr...
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]]: """ Multiplies two matrices A and B. Args: A (List[List[int]]): The first matrix. B (List[List[i...
evol_instruct_66k
5,385
Write a Python function to find the sum of all unique numbers in a given list. If a number occurs more than once in the list, it should only be counted once in the final sum. Implement this without using Python's built-in set functionality to eliminate duplicate numbers. The code 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 def sum_of_unique_numbers(numbers: List[int]) -> int: """ Calculate the sum of all unique numbers in the given list. Args: numbers (List[int]): The list of integers from which to calculate t...
evol_instruct_66k
5,390
Write a Python function to convert an integer to its corresponding Roman numeral representation. The function should handle integers between 1 and 3999, inclusive. The code should start with: ```python def int_to_roman(input_integer: int) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def int_to_roman(input_integer: int) -> str: """ Converts an integer to its corresponding Roman numeral representation. Args: input_integer (int): The integer to convert, must be between 1 and 3999, inclusive. ...
evol_instruct_66k
5,391
Write a Python function to determine if a given integer exists in a list of integers efficiently. The function should return `True` if the integer is found and `False` otherwise. The function should use an appropriate data structure to optimize the search operation. The code should start with: ```python from typing im...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def fast_search(search_num: int, num_list: List[int]) -> bool: """ Determines if a given integer exists in a list of integers efficiently. Args: search_num (int): The integer to search for i...
evol_instruct_66k
5,394
Write a Python function to apply customizable text shadow effects to different paragraphs of a given HTML text. The function should generate CSS rules for each paragraph based on the provided parameters. The first paragraph should have bold text with a shadow effect, the second paragraph should have italicized text wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_css_rules(paragraph_ids: List[str], shadow_params: List[Tuple[int, int, int, str]]) -> str: """ Generates CSS rules for different paragraphs with customizable text shadow effects. ...
evol_instruct_66k
5,396
Write a Python function to calculate the sum of all elements in a given list. The function should handle lists of integers and floating-point numbers. The code should start with: ```python from typing import List def sum_elements(lst: List[float]) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_elements(lst: List[float]) -> float: """ Calculate the sum of all elements in a given list of numbers. Args: lst (List[float]): The list of numbers (integers or floating-point number...
evol_instruct_66k
5,397
Write a Python function to reverse the characters in a given input string using a sophisticated approach that does not rely on Python's built-in slicing. The function should use a loop to manually reverse the characters and return the reversed string. The code should start with: ```python def reverse_string_manual(inp...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string_manual(input_string: str) -> str: """ Reverses the characters in a given input string using a manual approach. Args: input_string (str): The string to be reversed. Returns: str: The r...
evol_instruct_66k
5,402
Write a Python function to verify if two given verbal expressions incorporate the exact same set of words with an equal incidence rate. The function should return `True` if the word frequencies match exactly, and `False` otherwise. The function should handle case sensitivity by converting all words to lowercase. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from collections import Counter def verify_word_set_frequency(expression1: str, expression2: str) -> bool: """ Verify if two verbal expressions incorporate the exact same set of words with an equal incid...
evol_instruct_66k
5,403
Write a Python function to sort a given list of dictionaries based on the values in a specified field. The function should return the sorted list of dictionaries. The code should start with: ```python from typing import List, Dict, Any def sort_list_of_dicts(data: List[Dict[str, Any]], field: str) -> List[Dict[str, An...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def sort_list_of_dicts(data: List[Dict[str, Any]], field: str) -> List[Dict[str, Any]]: """ Sorts a list of dictionaries based on the values in a specified field. Args: data (List...
evol_instruct_66k
5,404
Write a Python function to sort a given list of integers in ascending order. The function should return the sorted list. The code should start with: ```python from typing import List def sort_list_ascending(collection: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sort_list_ascending(collection: List[int]) -> List[int]: """ Sorts a given list of integers in ascending order and returns the sorted list. Args: collection (List[int]): The list of in...
evol_instruct_66k
5,432
Write a Python function to safely access and modify a specific nested value within a complex nested dictionary. The function should handle cases where the keys might not exist and should return a default value if the key is not found. The function should also be able to modify the nested value if the key exists. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, Union def access_and_modify_nested_dict(nested_dict: Dict[str, Any], keys: Union[str, list], new_value: Any = None, default_value: Any = None) -> Any: """ Safely access and modify a specific nested...
evol_instruct_66k
5,442
Write a Python function to merge two dictionaries and compare their values. The function should: 1. Merge the two dictionaries by updating the value of common keys. 2. Return a new dictionary that contains: - The union of the keys from both input dictionaries. - For pairs of values with the same key, the absolute...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def merge_and_compare_dicts(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]: """ Merges two dictionaries and compares their values. Args: dict1 (Dict[str, int]): The first di...
evol_instruct_66k
5,477
Write a Python function to sort a given list of distinct numerical values in ascending order. The function should return the sorted list. The code should start with: ```python from typing import List def sort_distinct_numbers(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_distinct_numbers(arr: List[int]) -> List[int]: """ Sorts a list of distinct numerical values in ascending order. Args: arr (List[int]): The list of distinct numerical values to be s...
evol_instruct_66k
5,505
Write a Python function to count the number of times the element 2 appears in a given 2D array with dimensions MxN (1 <= M, N <= 100). The function should have a space complexity of O(1) and a time complexity of O(M*N). The code should start with: ```python from typing import List def count_twos(arr: List[List[int]])...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_twos(arr: List[List[int]]) -> int: """ Count the number of times the element 2 appears in a given 2D array. Args: arr (List[List[int]]): A 2D list of integers with dimensions MxN (...
evol_instruct_66k
5,530
Write a Python function to find the index of a specified item in a given list. If the item is not found in the list, the function should return `-1`. The function should handle the case where the item is not present in the list without raising an exception. The code should start with: ```python from typing import List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def find_item_index(my_list: List[Any], item: Any) -> int: """ Find the index of a specified item in a given list. If the item is not found, return -1. Args: my_list (List[Any]): The li...
evol_instruct_66k
5,536
Write a Python function to remove duplicate integers from a given list while preserving the order of their first occurrence. The function should take a list of integers as input and return a new list with all duplicate integers removed, maintaining the original order of the first occurrence of each integer. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates_preserve_order(objects: List[int]) -> List[int]: """ Removes duplicate integers from the given list while preserving the order of their first occurrence. Args: objects ...
evol_instruct_66k
5,538
Write a Python function to calculate the total number of fatalities and survivors from a list of shipwreck records. Each record is represented as a dictionary with the following keys: `"fatalities"` and `"survivors"`. The function should return a tuple containing the total number of fatalities and survivors. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def calculate_total_casualties(shipwrecks: List[Dict[str, int]]) -> Tuple[int, int]: """ Calculate the total number of fatalities and survivors from a list of shipwreck records. Args: ...