source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
9,771
Write a Python function to encrypt a given string using the Caesar Cipher technique. The Caesar Cipher shifts each letter in the input string by a specified number of positions down the alphabet. Non-alphabet characters should remain unchanged. The function should be case-sensitive, meaning it should preserve the origi...
Here is the Python code to solve the given problem in the markdown block: ```python def caesar_cipher(input_string: str, shift_amount: int = 3) -> str: """ Encrypts a given string using the Caesar Cipher technique. Args: input_string (str): The string to be encrypted. shift_amount (int): Th...
evol_instruct_66k
9,773
Write a Python function to solve the 0/1 Knapsack problem, which calculates the maximum possible revenue from a set of items with given weights and values. Each item can either be included in the knapsack or not, and the goal is to maximize the total value without exceeding the given weight capacity. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def knapsack_max_revenue(weights: List[int], values: List[int], capacity: int) -> int: """ Calculate the maximum possible revenue from a set of items with given weights and values. Args: wei...
evol_instruct_66k
9,775
Write a Python function to solve the 0/1 Knapsack problem using dynamic programming. The function should take a list of items, where each item is represented as a tuple containing its weight and value, and a maximum capacity of the knapsack. The function should return the maximum value that can be obtained by selecting...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def knapsack_max_value(items: List[Tuple[int, int]], capacity: int) -> int: """ Solve the 0/1 Knapsack problem using dynamic programming to find the maximum value. Args: items (List[T...
evol_instruct_66k
9,778
Write a Python function to find all occurrences of a substring `str_1` within a main string `str_2` and return the starting and ending indices of each occurrence. If `str_1` is not found in `str_2`, return a meaningful message. The function should be case-sensitive. 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, Tuple def find_substring_indices(str_1: str, str_2: str) -> List[Tuple[int, int]] or str: """ Find all occurrences of a substring `str_1` within a main string `str_2` and return the starting and ending ...
evol_instruct_66k
9,791
Write a Python function to generate a new series by multiplying each element of a given list of unique integers by a specified numerical ratio. The function should handle the input list and the ratio, and return the new list with the transformed elements. 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 transform_series(series: List[int], ratio: float) -> List[int]: """ Transforms a series of unique integers by multiplying each element with a specified ratio. Args: series (List[int]): A...
evol_instruct_66k
9,803
Write a Python function to determine if a given integer is a perfect square. The function should return `True` if the integer is a perfect square and `False` otherwise. The function should handle edge cases such as negative numbers and zero. The code should start with: ```python def is_perfect_square(x: int) -> bool: `...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_perfect_square(x: int) -> bool: """ Determine if a given integer is a perfect square. Args: x (int): The integer to check. Returns: bool: True if the integer is a perfect square, Fal...
evol_instruct_66k
9,810
Write a Python function to split a given string of alphanumeric characters into a list of individual characters. The function should handle any string input, including empty strings and strings with mixed alphanumeric characters. The code should start with: ```python from typing import List def split_string_to_list(in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string_to_list(input_string: str) -> List[str]: """ Splits a given string of alphanumeric characters into a list of individual characters. Args: input_string (str): The string to b...
evol_instruct_66k
9,818
Write a Python function to generate an HTML table that illustrates the array of academic scores pertaining to a group of students. The function should take a list of integers representing the scores and return a string containing the HTML table. The table should have two columns: "Student" and "Mark". The "Student" col...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_html_table(scores: List[int]) -> str: """ Generates an HTML table that illustrates the array of academic scores pertaining to a group of students. Args: scores (List[int]): A li...
evol_instruct_66k
9,819
Write a Python function to compute the maximum overlap between two data samples. The function should return the number of elements that are common between the two lists. The code should start with: ```python from typing import List def max_overlap(data1: List[int], data2: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_overlap(data1: List[int], data2: List[int]) -> int: """ Compute the maximum overlap between two data samples. Args: data1 (List[int]): The first data sample. data2 (List[int]...
evol_instruct_66k
9,826
Write a Python function to filter out all negative numbers from a given list of numerical values and sort the remaining non-negative numbers in ascending order. The function should return the sorted list of non-negative numbers. The code should start with: ```python from typing import List def filter_and_sort_non_neg...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_and_sort_non_negatives(numbers: List[int]) -> List[int]: """ Filters out all negative numbers from the given list and sorts the remaining non-negative numbers in ascending order. Args: ...
evol_instruct_66k
9,842
Write a Python function to determine which of two given text entities precedes the other when ordered based on the principles of the English alphabetic system. The function should be case insensitive and should ignore non-alphabetic characters. The code should start with: ```python def compare_entities(entity1: str, en...
Here is the Python code to solve the given problem in the markdown block: ```python def compare_entities(entity1: str, entity2: str) -> str: """ Determines which of two given text entities precedes the other when ordered based on the principles of the English alphabetic system. The comparison is case insens...
evol_instruct_66k
9,874
Write a Python function to calculate the mean value of a given list of integers. The function should handle an empty list by returning `None` and should be able to handle both positive and negative integers. The code should start with: ```python from typing import List, Optional def calculate_mean(numbers: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def calculate_mean(numbers: List[int]) -> Optional[float]: """ Calculate the mean value of a given list of integers. Args: numbers (List[int]): The list of integers for which to ca...
evol_instruct_66k
9,883
Write a Python function to calculate the sum of all integer values within a provided multi-level dictionary. The dictionary may contain other dictionaries, lists, and integer values. The function should handle this complexity and return the total sum of all integer values present. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union, List, Dict def sum_values(data: Union[Dict, List, int]) -> int: """ Calculate the sum of all integer values within a provided multi-level dictionary. Args: data (Union[Dict, List, int]): T...
evol_instruct_66k
9,887
Write a Python function to find the greatest cumulative total of `k` consecutive integers within a given numerical sequence. The sequence may contain both negative and positive values. The function should have a time complexity better than O(n^2). The code should start with: ```python from typing import List def max_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_consecutive_sum(numbers: List[int], k: int) -> int: """ Find the greatest cumulative total of k consecutive integers within a given numerical sequence. Args: numbers (List[int]): The...
evol_instruct_66k
9,889
Write a Python function to find the second smallest number in a given array of floating-point numbers. The function should handle arrays with duplicate values and arrays with fewer than two elements by returning `None` in such cases. The code should start with: ```python from typing import List, Optional def find_seco...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_second_smallest(numbers: List[float]) -> Optional[float]: """ Find the second smallest number in a given array of floating-point numbers. Args: numbers (List[float]): The ...
evol_instruct_66k
9,904
Write a Python function to identify and return the numbers that occur more than once in a given list of integers. The function should return a list of these duplicate numbers, sorted in ascending order. The code should start with: ```python from typing import List def find_duplicates(my_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 find_duplicates(my_list: List[int]) -> List[int]: """ Identify and return the numbers that occur more than once in the given list of integers. Args: my_list (List[int]): The list of inte...
evol_instruct_66k
9,909
Write a Python function to find the shortest path in a weighted graph using Dijkstra's algorithm. The graph is represented as an adjacency list where each node points to a dictionary of its neighbors and the corresponding edge weights. The function should return the shortest distance from the start node to the end node...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Union import heapq def dijkstra_shortest_path(graph: Dict[str, Dict[str, int]], start: str, end: str) -> Union[int, None]: """ Find the shortest path from the start node to the end node in a weighted gr...
evol_instruct_66k
9,927
Write a Python function to create and initialize a two-dimensional array of a given size with all elements set to 0. The function should handle errors gracefully by raising a `ValueError` if the size is not a positive integer. The code should start with: ```python def create_2d_array(size: int) -> list: ```
Here is the Python code to solve the given problem in the markdown block: ```python def create_2d_array(size: int) -> list: """ Creates and initializes a two-dimensional array of the given size with all elements set to 0. Args: size (int): The size of the two-dimensional array to be created. Must b...
evol_instruct_66k
9,939
Write a Python function to calculate the factorial of a given number `n` efficiently. The function should be optimized in terms of both time and space complexity. Provide an analysis of the original and optimized functions in terms of time and space complexity. The code should start with: ```python def factorial(n: int...
Here is the Python code to solve the given problem in the markdown block: ```python import math def factorial(n: int) -> int: """ Calculate the factorial of a given number n efficiently. Args: n (int): The number to calculate the factorial for. Returns: int: The factorial of the numbe...
evol_instruct_66k
9,949
Write a Python function to construct and validate a URL based on the provided details. The function should ensure that the URL uses the correct protocol, contains a valid domain and resource path, and return an appropriate error message if any part of the URL is invalid. The function should be modular, with separate va...
Here is the Python code to solve the given problem in the markdown block: ```python import re def construct_and_validate_url(protocol: str, subdomain: str, primary_domain: str, tld: str, resource_path: str) -> str: """ Constructs a URL from the provided details and validates it. Args: protocol (st...
evol_instruct_66k
9,959
Write a Python function to simulate a stochastic motion in a bi-dimensional coordinate plane, confined to a specified number of steps. The motion should be constrained within a given rectangular boundary. The function should return the final position after the specified number of steps. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import random def stochastic_motion(steps: int, boundary: Tuple[int, int]) -> Tuple[int, int]: """ Simulate a stochastic motion in a bi-dimensional coordinate plane, confined to a specified number of st...
evol_instruct_66k
9,960
Write a Python function to sort an array of floating-point numbers in descending order. The function should return the sorted array. The code should start with: ```python from typing import List def sort_descending(arr: List[float]) -> List[float]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_descending(arr: List[float]) -> List[float]: """ Sorts an array of floating-point numbers in descending order. Args: arr (List[float]): The array of floating-point numbers to be sor...
evol_instruct_66k
9,996
Write a Python function to extract and return all keys from a given single-layer dictionary that have boolean values. The function should handle any valid single-layer dictionary and return a list of keys corresponding to boolean values. The code should start with: ```python from typing import Dict, List def find_boo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def find_boolean_keys(input_dict: Dict[str, any]) -> List[str]: """ Extracts and returns all keys from a given single-layer dictionary that have boolean values. Args: input_dict (Dict[...
evol_instruct_66k
10,003
Write a Python function to generate a geometric sequence given the first term, common ratio, and the total number of terms. The function should return a list containing the terms of the geometric sequence. The code should start with: ```python from typing import List def generate_geometric_sequence(first_term: float,...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_geometric_sequence(first_term: float, common_ratio: float, total_terms: int) -> List[float]: """ Generate a geometric sequence given the first term, common ratio, and the total number of ter...
evol_instruct_66k
10,012
Write a Python function to merge two pre-sorted lists into a single sorted list without using the built-in `sort()` functionality. The function should efficiently combine the elements of both lists while maintaining the sorted order. The code should start with: ```python from typing import List def merge_sorted_lists(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_lists(list1: List[int], list2: List[int]) -> List[int]: """ Merge two pre-sorted lists into a single sorted list without using the built-in sort() functionality. Args: list1...
evol_instruct_66k
10,015
Write a Python function to reverse a given word and determine if it is an anagram of the original word. The function should return a tuple containing the reversed word and a boolean indicating whether the word is an anagram of its reverse. The code should start with: ```python def reverse_and_check_anagram(word: str) ...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_and_check_anagram(word: str) -> tuple: """ Reverses the given word and checks if it is an anagram of the original word. Args: word (str): The word to be reversed and checked for anagram. Returns: ...
evol_instruct_66k
10,028
Write a Python function to determine if a given year is a leap year or not using a ternary operator. The function should take an integer representing a year and return a boolean value (`True` if the year is a leap year, `False` otherwise). The code should start with: ```python def is_leap_year(year: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_leap_year(year: int) -> bool: """ Determine if a given year is a leap year using a ternary operator. Args: year (int): The year to check. Returns: bool: True if the year is a leap year, False oth...
evol_instruct_66k
10,054
Write a Python function to print all numbers within a given range in a specific format, and check if these numbers are prime or not. For each number, the function should identify and mark it as prime or non-prime. The function should start with: ```python def print_prime_numbers(start: int, end: int) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python def print_prime_numbers(start: int, end: int) -> None: """ Prints all numbers within the given range [start, end] and identifies whether each number is prime or not. Args: start (int): The starting number of the ran...
evol_instruct_66k
10,058
Write a Python function to traverse a dictionary and print its key-value pairs in a custom sorted order based on the length of the keys. The function should accept a dictionary and a custom sorting function as arguments. The custom sorting function should determine the order of the keys. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Callable def traverse_and_sort_dict(dictionary: Dict[str, int], sort_func: Callable[[str], int]) -> None: """ Traverse a dictionary and print its key-value pairs in a custom sorted order based on the pr...
evol_instruct_66k
10,069
Write a Python function to calculate the accumulated total of elements in a two-dimensional numerical array, treating negative elements as zero. The function should start with: ```python from typing import List def accumulated_total(array: List[List[int]]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def accumulated_total(array: List[List[int]]) -> int: """ Calculate the accumulated total of elements in a two-dimensional numerical array, treating negative elements as zero. Args: array (L...
evol_instruct_66k
10,073
Write a Python function to efficiently print the elements of a given list in reverse order without modifying the original list. The function should use an efficient approach to avoid unnecessary computations and should handle lists of varying lengths. 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 print_reverse_list(arr: List[int]) -> None: """ Prints the elements of the given list in reverse order without modifying the original list. Args: arr (List[int]): The list of integers to...
evol_instruct_66k
10,077
Write a Python function to convert each alphabetical character of a given string into its corresponding lowercase rendition. The function should ignore any non-alphabetical characters and return the modified string. The code should start with: ```python def convert_to_lowercase(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_lowercase(input_string: str) -> str: """ Converts each alphabetical character in the input string to its corresponding lowercase rendition. Non-alphabetical characters remain unchanged. Args: inpu...
evol_instruct_66k
10,089
Write a Python function to generate the first n terms of the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. The function should return a list containing the first n terms of the sequence. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci(n: int) -> List[int]: """ Generate the first n terms of the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding...
evol_instruct_66k
10,096
Write a Python function to compute the sum of all integers within a given inclusive range `[start, end]`. The function should handle both positive and negative integers, and the range should be inclusive of both endpoints. The code should start with: ```python def sum_of_range(start: int, end: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_range(start: int, end: int) -> int: """ Compute the sum of all integers within the inclusive range [start, end]. Args: start (int): The starting integer of the range (inclusive). end (int): The en...
evol_instruct_66k
10,099
Write a Python function to retrieve the value associated with a specific key from a nested dictionary. The function should handle cases where the key or nested dictionary might not exist. If the key is not found, the function should return `None`. The code should start with: ```python from typing import Any, Dict, Opt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, List, Optional def get_nested_value(dictionary: Dict[str, Any], keys: List[str]) -> Optional[Any]: """ Retrieve the value associated with a specific key from a nested dictionary. Args: ...
evol_instruct_66k
10,102
Write a Python function to remove all occurrences of white spaces from a given string and another function to replace multiple occurrences of white spaces with a single space, while preserving the initial and final characters of the original string. The solution should not use any built-in string trimming functions and...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_all_spaces(string: str) -> str: """ Removes all occurrences of white spaces from the given string. Args: string (str): The input string from which spaces are to be removed. Returns: str: The ...
evol_instruct_66k
10,116
Write a Python function to transform a list of hexadecimal strings into their equivalent binary representations. Each hexadecimal string should be converted to its binary form without leading zeros. The code should start with: ```python from typing import List def hex_to_binary(hex_list: List[str]) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hex_to_binary(hex_list: List[str]) -> List[str]: """ Converts a list of hexadecimal strings to their equivalent binary representations. Args: hex_list (List[str]): A list of hexadecimal ...
evol_instruct_66k
10,129
Write a Python function to generate the Fibonacci sequence up to a given number `n` using Binet's Formula. Additionally, implement a function to check if a given number is part of the Fibonacci series. The code should start with: ```python import math def generate_fibonacci_sequence(n: int) -> list: ``` and ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python import math def generate_fibonacci_sequence(n: int) -> list: """ Generate the Fibonacci sequence up to the nth number using Binet's Formula. Args: n (int): The number of Fibonacci numbers to generate. Returns:...
evol_instruct_66k
10,146
Write a Python function to determine if one list is a subset of another list. The function should return `True` if all elements of the second list are present in the first list, and `False` otherwise. The function should handle lists of any length, including empty lists. The code should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_subset(A: List[int], B: List[int]) -> bool: """ Determines if all elements of list B are present in list A. Args: A (List[int]): The list to check against. B (List[int]): The ...
evol_instruct_66k
10,154
Write a Python function to calculate the sum of all even numbers between 1 and 50 and display the result. Additionally, find the smallest prime factor of each of these even numbers, if any, and display them as well. The function should return a dictionary where the keys are the even numbers and the values are their sma...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sum_of_even_numbers_and_prime_factors() -> Dict[int, int]: """ Calculate the sum of all even numbers between 1 and 50 and find the smallest prime factor of each even number. Returns: Dic...
evol_instruct_66k
10,165
Write a Python function to calculate the area of a rhombus given the lengths of its two diagonals. The function should correctly handle the provided erroneous code and ensure the correct formula is used. The code should start with: ```python def rhombus_area(d1: int, d2: int) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def rhombus_area(d1: int, d2: int) -> float: """ Calculate the area of a rhombus given the lengths of its two diagonals. Args: d1 (int): The length of the first diagonal. d2 (int): The length of the second d...
evol_instruct_66k
10,192
Write a Python function to reverse a given string without using any built-in string manipulation functions or methods from the standard library. The function should iterate through the string manually and construct the reversed string character by character. The code should start with: ```python def reverse_string(inp...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(input_string: str) -> str: """ Reverses the given string without using any built-in string manipulation functions or methods. Args: input_string (str): The string to be reversed. Returns: ...
evol_instruct_66k
10,194
Write a Python function to print numbers from 1 to 100 each in a new line using recursion. Additionally, write a second version of the function without using any loops or recursion. Consider any alternative approaches to accomplish this task, such as using list comprehensions or generator expressions. Discuss the pros ...
Here is the Python code to solve the given problem in the markdown block: ```python def print_numbers_recursive(n: int = 1) -> None: """ Prints numbers from 1 to 100 each in a new line using recursion. Args: n (int): The current number to print. Defaults to 1. Returns: None """ ...
evol_instruct_66k
10,195
Write a Python function to generate all possible unique sequences of a specified length using a given set of characters. The function should ensure that each sequence is unique and that the sequences are generated in lexicographic order. The code should start with: ```python from typing import List, Set def generate_u...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Set import itertools def generate_unique_sequences(characters: List[str], length: int) -> Set[str]: """ Generate all unique sequences of a specified length using a given set of characters. Args: ...
evol_instruct_66k
10,201
Write a Python function to compute the mode(s) of a given list of numbers without using any in-built library functions. The function should handle cases where there are multiple modes (i.e., numbers that appear the most frequently). The code should start with: ```python from typing import List def calculate_mode(numbe...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_mode(numbers: List[int]) -> List[int]: """ Compute the mode(s) of a given list of numbers without using in-built library functions. Args: numbers (List[int]): A list of integer...
evol_instruct_66k
10,208
Write a Python function to generate a pyramid pattern using asterisks (`*`). The function should take an integer `n` as input, which represents the number of rows in the pyramid. The pyramid should be centered, with each row having an increasing number of asterisks, starting from 1 at the top to `n` at the bottom. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_pyramid(n: int): """ Generates a centered pyramid pattern using asterisks. Args: n (int): The number of rows in the pyramid. Returns: None: The function prints the pyramid directly to the c...
evol_instruct_66k
10,220
Write a Python function to reverse the order of elements in a given list without using the built-in `reverse()` method or slicing techniques like `[::-1]`. The function should use an iterative approach to achieve this. The code should start with: ```python from typing import List def reverse_list(lst: List[str]) -> L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(lst: List[str]) -> List[str]: """ Reverses the order of elements in a given list without using the built-in reverse() method or slicing techniques. Args: lst (List[str]): Th...
evol_instruct_66k
10,226
Write a Python function to combine two lists without duplication, maintaining the original order of elements, and ensuring that the combined list contains only strings. The function should take two lists as input and return the combined list. The code should start with: ```python from typing import List def combine_l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def combine_lists_without_duplicates(list_one: List[str], list_two: List[str]) -> List[str]: """ Combines two lists without duplication, maintaining the original order of elements, and ensuring all eleme...
evol_instruct_66k
10,228
Write a Python function to increment a given number and return the incremented value. The function should also print a message showing the incremented value. Ensure that the function handles the type conversion correctly to avoid type errors when concatenating the incremented value with a string. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python def increment_number(x: int) -> int: """ Increments the given integer by 1 and prints the incremented value. Args: x (int): The integer to be incremented. Returns: int: The incremented value. """ ...
evol_instruct_66k
10,237
Write a Python function to move all occurrences of the integer zero to the end of a given list while maintaining the order of non-zero elements. The function should also handle nested lists by recursively moving zeros to the end of each nested list. The function should not use any built-in Python functions or libraries...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def move_zeros_to_end(lst: Union[List[Union[int, List]], int]) -> Union[List[Union[int, List]], int]: """ Moves all occurrences of the integer zero to the end of the given list while maintaining t...
evol_instruct_66k
10,242
Write a Python function to calculate the frequency of each unique character in a given string, excluding spaces. The function should return a dictionary where the keys are the characters and the values are their respective frequencies. The function should be case-insensitive, meaning 'A' and 'a' should be treated as th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def character_frequency(paragraph: str) -> Dict[str, int]: """ Calculate the frequency of each unique character in a given string, excluding spaces. The function is case-insensitive. Args: ...
evol_instruct_66k
10,245
Write a Python function to concatenate multiple strings with a specified delimiter. The function should take a list of strings and a delimiter string as input and return a single concatenated string. If the list of strings is empty, the function should return an empty string. 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 concatenate_strings(strings: List[str], delimiter: str) -> str: """ Concatenates a list of strings with a specified delimiter. Args: strings (List[str]): A list of strings to be concaten...
evol_instruct_66k
10,251
Write a Python function to alter a list of strings by replacing the last three elements with a single new entry. The function should handle lists of various lengths, ensuring that if the list has fewer than three elements, it replaces all elements with the new entry. 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 replace_last_three_elements(words: List[str], replacement: str) -> List[str]: """ Replace the last three elements of a list of strings with a single new entry. If the list has fewer than three el...
evol_instruct_66k
10,258
Write a Python function to compute the set of prime factors for a given positive integer. The function should return a list of prime factors in ascending order. The code should start with: ```python from typing import List def prime_factors(n: int) -> List[int]: ```
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]: """ Compute the set of prime factors for a given positive integer. Args: n (int): The positive integer for which to find the prime factors. Ret...
evol_instruct_66k
10,262
Write a Python function that finds the dissimilar elements in two given tuples, counts the number of occurrences of these dissimilar elements in both tuples, and identifies the tuple from which the dissimilar element originated. The function should return a dictionary where the keys are the dissimilar elements and the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Dict def find_dissimilar_elements(t1: Tuple, t2: Tuple) -> Dict[str, Tuple[int, int, int]]: """ Finds the dissimilar elements in two given tuples, counts the number of occurrences of these dissimilar e...
evol_instruct_66k
10,265
Write a Python function to calculate the factorial of a given number and then compute the sum of the digits in that factorial. Handle non-numeric and negative integer inputs by returning `None`. The function should start with: ```python def factorial_digit_sum(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def factorial_digit_sum(n: int) -> int: """ Calculate the factorial of a given number and return the sum of its digits. Args: n (int): The number to calculate the factorial of. Returns: int: The sum of ...
evol_instruct_66k
10,266
Write a Python function to convert a list of octal number strings to their equivalent binary string form. Each octal number string should be converted to its binary representation without the '0b' prefix. The code should start with: ```python from typing import List def convert_octal_to_binary(octal_numbers: List[str...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_octal_to_binary(octal_numbers: List[str]) -> List[str]: """ Converts a list of octal number strings to their equivalent binary string form. Args: octal_numbers (List[str]): A lis...
evol_instruct_66k
10,285
Write a Python function to extract the name and age of the second item from a given dictionary. The dictionary contains multiple entries, each with a name, age, and city. The function should be dynamic and work for any dictionary with a similar structure but an arbitrary number of records. The function should not extra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def extract_second_item_info(data: Dict[str, Dict[str, Any]]) -> Dict[str, Any]: """ Extracts the name and age of the second item from a given dictionary. Args: data (Dict[str, Dict[str...
evol_instruct_66k
10,292
Write a Python function to simulate the process of incrementing a counter by a random integer between 1 and 5 until it reaches or surpasses 20. The function should return the number of iterations it takes for the counter to reach or surpass 20. The code should start with: ```python import random def count_iterations_...
Here is the Python code to solve the given problem in the markdown block: ```python import random def count_iterations_to_reach_20() -> int: """ Simulate the process of incrementing a counter by a random integer between 1 and 5 until it reaches or surpasses 20. Return the number of iterations it takes. ...
evol_instruct_66k
10,297
Write a Python function to determine if a user has an active login session based on a given session dictionary. The session dictionary contains key-value pairs representing session attributes. The function should check if the "loggedIn" attribute exists and is set to `True`. 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 Dict def is_user_logged_in(session: Dict[str, any]) -> bool: """ Determines if a user has an active login session based on the session dictionary. Args: session (Dict[str, any]): A dictionary con...
evol_instruct_66k
10,306
Write a Python function to calculate the Euclidean distance between two geographical positions given as tuples of latitude and longitude. The function should take two tuples as input, where each tuple contains the latitude and longitude of a location. The function should return the Euclidean distance between these two ...
Here is the Python code to solve the given problem in the markdown block: ```python from math import sqrt def calculate_euclidean_distance(point1: tuple, point2: tuple) -> float: """ Calculate the Euclidean distance between two geographical positions given as tuples of latitude and longitude. Args: ...
evol_instruct_66k
10,307
Write a Python function to multiply each element in a given list by a specified factor and return the resulting list. The function should handle both positive and negative integers as well as zero. The code should start with: ```python from typing import List def multiply_elements(input_list: List[int], factor: int) -...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def multiply_elements(input_list: List[int], factor: int) -> List[int]: """ Multiplies each element in the input list by the specified factor and returns the resulting list. Args: input_li...
evol_instruct_66k
10,325
Write a Python function to calculate the sum of two distinct integer entities and return the result. The function should take two integer parameters and return their sum. The code should start with: ```python def add_two_integers(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def add_two_integers(a: int, b: int) -> int: """ Calculate the sum of two distinct integer entities. Args: a (int): The first integer to be added. b (int): The second integer to be added. Returns: ...
evol_instruct_66k
10,330
Write a Python function to reverse a given string. The function should handle strings of any length, including empty strings. The code should start with: ```python def reverse_string(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(s: str) -> str: """ Reverses the given string. Args: s (str): The string to be reversed. Returns: str: The reversed string. """ # Use slicing to reverse the string return ...
evol_instruct_66k
10,344
Write a Python function to implement a basic linear search algorithm that takes an array and a value, and returns the index of the value in the array if it is present. If the value is not found, the function should return -1. The code should start with: ```python from typing import List def linear_search(arr: List[int...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def linear_search(arr: List[int], x: int) -> int: """ Perform a linear search to find the index of a given value in an array. Args: arr (List[int]): The array to search through. x ...
evol_instruct_66k
10,346
Write a Python function to determine if a given integer `x` is greater than 10 and return a corresponding message. If `x` is greater than 10, the function should return the string "The value of x is greater than 10". Otherwise, it should return the string "The value of x is not greater than 10". The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def check_value(x: int) -> str: """ Determines if the given integer x is greater than 10 and returns a corresponding message. Args: x (int): The integer to be checked. Returns: str: A message indicating...
evol_instruct_66k
10,348
Write a Python function to perform a binary search on a sorted list of integers to find the index of a specified value. If the value is not present in the list, the function should return -1. The function should be efficient and utilize the binary search algorithm to achieve this. 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 binary_search(arr: List[int], target: int) -> int: """ Perform a binary search on a sorted list of integers to find the index of a specified value. Args: arr (List[int]): A sorted list o...
evol_instruct_66k
10,353
Write a Python function to sort a given list of integers in ascending order with a specific functionality where all even numbers must be arranged before odd numbers. The function should use a custom sorting algorithm, such as bubble sort, to sort the even and odd numbers separately before combining them. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_sort_even_before_odd(my_list: List[int]) -> List[int]: """ Sorts a list of integers in ascending order with all even numbers arranged before odd numbers. Args: my_list (List[int])...
evol_instruct_66k
10,368
Write a Python function to convert a given string into its equivalent Morse code representation. The function should handle both uppercase and lowercase letters and include a space character represented by '/' in the Morse code. The code should start with: ```python def string_to_morse(input_string: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def string_to_morse(input_string: str) -> str: """ Convert a given string into its equivalent Morse code representation. Args: input_string (str): The input string to be converted into Morse code. Returns: ...
evol_instruct_66k
10,385
Write a Python function to create a nested dictionary from given keys and values, where keys and values are provided in two separate lists of tuples. Additionally, implement a function to perform a deep search of a given key-value pair within the nested dictionary. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def create_nested_dict(keys: List[Tuple[str, str]], values: List[Tuple[str, str]]) -> Dict[str, Dict[str, Tuple[str, str]]]: """ Creates a nested dictionary from the given keys and values. ...
evol_instruct_66k
10,409
Write a Python function to determine the maximal length of the continuously augmenting sequence within a given list of integers. The function should return the length of the longest increasing subsequence (LIS) in the list. The code should start with: ```python from typing import List def longest_increasing_subsequen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def longest_increasing_subsequence(arr: List[int]) -> int: """ Calculate the length of the longest increasing subsequence in the given list of integers. Args: arr (List[int]): The list of in...
evol_instruct_66k
10,410
Write a Python function to add two matrices. The function should take two matrices as input and return their sum. The matrices are represented as lists of lists, where each inner list represents a row of the matrix. The function should ensure that the matrices are of the same dimensions before performing the addition. ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def add_matrices(mat1: List[List[int]], mat2: List[List[int]]) -> Optional[List[List[int]]]: """ Adds two matrices and returns the resulting matrix. Args: mat1 (List[List[int]]): T...
evol_instruct_66k
10,417
Write a Python function to enumerate and output the collection of arguments provided to it. The function should accept a variable number of arguments and return a list of tuples, where each tuple contains the index (starting from 1) and the corresponding argument. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def enumerate_arguments(*args) -> List[Tuple[int, any]]: """ Enumerates and outputs the collection of arguments provided to the function. Args: *args: A variable number of arguments. ...
evol_instruct_66k
10,418
Write a Python function to calculate the cubed values of all whole numbers within a given range. The function should handle input validation and ensure that the start value is less than the end value. The function should return a list of cubed values for the specified range. 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 calculate_cubed_values(start: int, end: int) -> List[int]: """ Calculate the cubed values of all whole numbers within a given range. Args: start (int): The starting value of the range (i...
evol_instruct_66k
10,420
Write a Python function to extract valid email addresses from a list of text strings using a regular expression. The function should consider variations in domain names like `.co`, `.gov`, `.edu`, and optional country codes like `.uk`, `.in`, etc. Additionally, the function should ignore any email addresses where the u...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_valid_emails(text_list: List[str]) -> List[str]: """ Extracts valid email addresses from a list of text strings. Args: text_list (List[str]): A list of text strings con...
evol_instruct_66k
10,428
Write a Python function to generate a three-dimensional array of dimensions `x` by `y` by `z`, where each element is chosen pseudorandomly from a given list of integers. The function should handle input validation to ensure that the dimensions are positive integers and that the list is not empty. Additionally, provide ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import numpy as np import random def generate_random_3d_array(x: int, y: int, z: int, input_list: List[int]) -> np.ndarray: """ Generates a 3D array with dimensions x, y, z. Elements of the array are...
evol_instruct_66k
10,457
Write a Python function to calculate the frequency of each letter in a given string, considering only alphabetical characters and ignoring their cases. The function should return a dictionary where the keys are the letters and the values are their respective frequencies. The code should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def letter_frequency(s: str) -> Dict[str, int]: """ Calculate the frequency of each letter in a given string, considering only alphabetical characters and ignoring their cases. Args: s (str)...
evol_instruct_66k
10,458
Write a Python function to generate a distinct cryptographic identifier using the SHA-256 hashing algorithm, ensuring the output is a fixed-length hexadecimal string of 32 characters. The function should accept an input string (identifier) and return the hashed and truncated result. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python import hashlib def generate_cryptographic_identifier(identifier: str) -> str: """ Generates a distinct cryptographic identifier using the SHA-256 hashing algorithm. The output is a fixed-length hexadecimal string of 32 char...
evol_instruct_66k
10,463
Write a Python function to calculate the exponential magnitude of a given integer `x` raised to the power of another integer `y`. The function should return the result of `x` raised to the power of `y`. The code should start with: ```python def exponential_magnitude(x: int, y: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def exponential_magnitude(x: int, y: int) -> int: """ Calculate the exponential magnitude of an integer `x` raised to the power of another integer `y`. Args: x (int): The base integer. y (int): The exponent ...
evol_instruct_66k
10,476
Write a Python function to generate a list of strings based on the "FizzBuzz" rules for numbers from 1 to n. For multiples of 3, the function should append "Fizz" to the list, for multiples of 5, it should append "Buzz", and for multiples of both 3 and 5, it should append "FizzBuzz". For all other numbers, it should ap...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def fizz_buzz(n: int) -> List[str]: """ Generate a list of strings based on the "FizzBuzz" rules for numbers from 1 to n. Args: n (int): The upper limit of the range (inclusive). Return...
evol_instruct_66k
10,479
Write a Python function that checks if the given list of tuples contains the integer `k` and returns the indices of the tuples where `k` is found. If `k` is not found in any of the tuples, the function should return a custom error message. Additionally, the function should handle cases where the input is not a tuple or...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def find_indices_of_k(tuples: List[Tuple[int, ...]], k: int) -> Union[List[int], str]: """ Finds the indices of tuples in the given list that contain the integer `k`. Args: tup...
evol_instruct_66k
10,487
Write a Python function to calculate the sum of elements in a given list. The function should iterate through the list and accumulate the sum of its elements. The code should start with: ```python from typing import List def sum_of_elements(lst: 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_elements(lst: List[int]) -> int: """ Calculate the sum of all elements in the given list. Args: lst (List[int]): The list of integers whose sum needs to be calculated. Retu...
evol_instruct_66k
10,489
Write a Python function to sort a given array of numerical entities in descending order. The function should return the sorted array. The code should start with: ```python from typing import List def sort_array_descending(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_array_descending(arr: List[int]) -> List[int]: """ Sorts a given array of numerical entities in descending order. Args: arr (List[int]): The array of numerical entities to be sort...
evol_instruct_66k
10,496
Write a Python function to convert a list of integers into a list of floats. The function should take a list of integers as input and return a new list where each integer has been converted to a float. The function should handle an empty list by returning an empty list. 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 convert_integers_to_floats(integers: List[int]) -> List[float]: """ Converts a list of integers into a list of floats. Args: integers (List[int]): A list of integers to be converted. ...
evol_instruct_66k
10,500
Write a Python function to find the longest common substring among three given distinct literary excerpts. The function should return the longest common substring itself, not just its length. The code should start with: ```python from typing import Tuple def longest_common_substring(str1: str, str2: str, str3: str) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def longest_common_substring(str1: str, str2: str, str3: str) -> Tuple[str, int]: """ Find the longest common substring among three given strings. Args: str1 (str): The first string. ...
evol_instruct_66k
10,512
Write a Python function to calculate the sum of elements in a given list of integers. The function should be optimized for readability and efficiency. The code should start with: ```python from typing import List def sum_list(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_list(numbers: List[int]) -> int: """ Calculate the sum of elements in a given list of integers. Args: numbers (List[int]): The list of integers to sum. Returns: int: T...
evol_instruct_66k
10,519
Write a Python function to calculate the cumulative differential outcome between multiple sets of quantitative entities, where each set consists of pairs of integers (x, y) with values between 1 and 50. The differential outcome for each pair is calculated as the absolute difference between x and y. The function should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def cumulative_differential_outcome(num_sets: int, num_pairs: int) -> int: """ Calculate the cumulative differential outcome between multiple sets of quantitative entities. Each set co...
evol_instruct_66k
10,549
Create a Python function that validates the file type and size of a file before allowing it to be uploaded. The function should take the file's name, type, and size as inputs and return a boolean indicating whether the file is valid for upload. Additionally, the function should provide error messages for invalid files....
Here is the Python code to solve the given problem in the markdown block: ```python def validate_file_for_upload(file_name: str, file_type: str, file_size: int) -> (bool, str): """ Validates the file type and size before allowing it to be uploaded. Args: file_name (str): The name of the file. ...
evol_instruct_66k
10,552
Write a Python function to generate the Collatz sequence starting from a given positive integer `n` up to 1, count the number of steps taken to reach 1, and determine if the sequence includes an even number. The function should return a tuple containing the number of steps and a boolean indicating whether an even numbe...
Here is the Python code to solve the given problem in the markdown block: ```python def collatz_sequence_info(n: int) -> tuple: """ Generates the Collatz sequence starting from a given integer n up to 1, counts the steps, and determines if the sequence includes an even number. Args: n (int): Th...
evol_instruct_66k
10,553
Write a Python function to determine if a target number is present in a given sorted list of integers using a binary search algorithm. The function should return `True` if the target number is found, and `False` otherwise. The code should start with: ```python from typing import List def binary_search(data: List[int],...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(data: List[int], target: int) -> bool: """ Determines if a target number is present in a given sorted list of integers using binary search. Args: data (List[int]): A sorted...
evol_instruct_66k
10,566
Write a Python function to convert a list of text-based elements into a distinct unordered set with no repetition, considering case-sensitivity and special characters. The function should also handle invalid inputs by raising a `ValueError` with an appropriate error message. 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, Set def convert_to_distinct_set(text_elements: List[str]) -> Set[str]: """ Converts a list of strings into a distinct unordered set with no repetition, considering case-sensitivity and special chara...
evol_instruct_66k
10,567
Write a Python function to generate a JSON representation of a person's details, including their name, age, location, occupation, and hobbies. The function should accept these details as parameters and return a JSON string. The code should start with: ```python import json def generate_person_json(name: str, age: int,...
Here is the Python code to solve the given problem in the markdown block: ```python import json def generate_person_json(name: str, age: int, location: str, occupation: str, hobbies: list) -> str: """ Generates a JSON representation of a person's details. Args: name (str): The name of the person. ...
evol_instruct_66k
10,571
Write a Python function to convert a given 10-digit phone number string into the standard format "XXX-XXX-XXXX". The input phone number will be a string of exactly 10 digits. The function should handle the input validation to ensure it only contains digits and is exactly 10 characters long. If the input is invalid, the...
Here is the Python code to solve the given problem in the markdown block: ```python def format_phone_number(phone_number: str) -> str: """ Converts a given 10-digit phone number string into the standard format "XXX-XXX-XXXX". Args: phone_number (str): A string of exactly 10 digits representing the ...
evol_instruct_66k
10,607
Write a Python function to find the least three unique numbers in a given array and return them in ascending order. The function should handle negative numbers and zeroes, and raise a `ValueError` if there are less than three unique numbers in the array. The time complexity of the function should not exceed O(n log n)....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def least_three_unique_numbers(array: List[int]) -> List[int]: """ Finds the least three unique numbers in a given array and returns them in ascending order. Args: array (List[int]): The inp...
evol_instruct_66k
10,637
Write a Python function to calculate the sum of all elements in an array after each element is added to a fixed value `x`. The function should return the final value of `x` after the operation. The array is a list of integers, and `x` is a fixed integer value. 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 def sum_with_fixed_value(arr: List[int], x: int) -> int: """ Calculate the sum of all elements in the array after each element is added to a fixed value `x`. Args: arr (List[int]): The array...
evol_instruct_66k
10,640
Write a Python function that processes a list of integers and stops processing when an exception is encountered. The function should simulate an error when processing a specific integer and handle the exception using a try-except block. The function should return the number of elements successfully processed before the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_list_with_exception(numbers: List[int]) -> int: """ Processes a list of integers and stops processing when an exception is encountered. The function simulates an error when processing a s...
evol_instruct_66k
10,645
Write a Python function to calculate the sum of all integers in a nested list structure. The nested list can contain other lists, which in turn can contain more lists, and so on. The function should recursively traverse through all levels of the nested list to sum up all the integers. 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 sum_of_nested_list(nested_list: List[int]) -> int: """ Calculate the sum of all integers in a nested list structure. Args: nested_list (List[int]): A nested list containing integers and ...
evol_instruct_66k
10,654
Write a Python function to determine if a given integer is a power of two. The function should return `True` if the integer is a power of two, and `False` otherwise. The code should start with: ```python def is_power_of_two(num: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_power_of_two(num: int) -> bool: """ Determine if a given integer is a power of two. Args: num (int): The integer to check. Returns: bool: True if the integer is a power of two, False otherwise. ...
evol_instruct_66k
10,656
Write a Python function to count and print the number of occurrences of each character (excluding spaces) in a given sentence, along with the total number of distinct characters found in the sentence. Perform this in a case-insensitive manner so 'a' and 'A' are considered the same character. The sentence will be provid...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import Counter def count_characters(sentence: str) -> None: """ Counts and prints the number of occurrences of each character (excluding spaces) in a given sentence, along with the total number of distinct ...
evol_instruct_66k
10,657
Write a Python function to create a new 2D array called `arr3` by combining the elements of two existing arrays `arr1` and `arr2`. The elements of `arr3` should alternate between `arr1` and `arr2`, such that the first element in `arr3` is from `arr1`, the second is from `arr2`, and so on. If the arrays are not of the s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def make_arr3(arr1: List[int], arr2: List[int]) -> List[List[int]] or str: """ Create a new 2D array by alternating elements from two existing arrays. Args: arr1 (List[int]): The first array...