source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_evol_110k
89,389
Write a Python function to implement a sorting algorithm that sorts an array of integer elements in a single iteration. The algorithm should handle potential duplicates and negative numbers in the array. The code should start with: ```python from typing import List def single_iteration_sort(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 single_iteration_sort(arr: List[int]) -> List[int]: """ Sorts an array of integers in a single iteration using a counting sort approach. Args: arr (List[int]): The array of integers to b...
magic_evol_110k
89,395
Write a Python function to generate the first `n` numbers in the Fibonacci sequence. The function should return a list containing the Fibonacci numbers. Additionally, provide a detailed explanation of the mathematical principle that underlies the Fibonacci sequence. 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 generate_fibonacci(n: int) -> List[int]: """ Generate the first n numbers in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two precedi...
magic_evol_110k
89,400
Write a Python function to calculate the maximum profit that can be made by buying and selling a stock once. The function should take a list of stock prices where the index represents the day and the value represents the price of the stock on that day. The function should return the maximum profit that can be achieved ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_profit(prices: List[int]) -> int: """ Calculate the maximum profit that can be achieved by buying and selling a stock once. Args: prices (List[int]): A list of stock prices where the...
magic_evol_110k
89,408
Write a Python function to calculate the product of two integers `x` and `y` without using the built-in multiplication, division, or modulo operators. The function should handle edge cases where `x` or `y` is 0 or negative. The code should start with: ```python def multiply_integers(x: int, y: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_integers(x: int, y: int) -> int: """ Calculate the product of two integers x and y without using built-in multiplication, division, or modulo operators. Args: x (int): The first integer. y (int)...
magic_evol_110k
89,415
Write a Python function to identify the lone integer in a given non-empty array of integers where every element appears twice except for one unique integer. The function should operate with a linear runtime complexity and without using additional memory (i.e., it should use constant space). The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_lone_integer(nums: List[int]) -> int: """ Identifies the lone integer in a given non-empty array of integers where every element appears twice except for one unique integer. Args: n...
magic_evol_110k
89,420
Write a Python function to sort a given list of integers using the Cocktail Shaker Sort algorithm. The Cocktail Shaker Sort is a variation of the Bubble Sort that sorts the list in both directions, first from the beginning to the end (like Bubble Sort), and then from the end to the beginning. This bidirectional approac...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cocktail_shaker_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers using the Cocktail Shaker Sort algorithm. Args: arr (List[int]): The list of integers to be sorted. R...
magic_evol_110k
89,426
Write a Python function to delete the nth item from a given list. The function should handle cases where n is out of bounds by returning the original list unchanged. The code should start with: ```python from typing import List def delete_nth_item(lst: List[str], n: int) -> List[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def delete_nth_item(lst: List[str], n: int) -> List[str]: """ Deletes the nth item from the given list. Args: lst (List[str]): The list from which to delete the item. n (int): The po...
magic_evol_110k
89,450
Write a Python function to print all odd integers from 1 to a given positive integer `n` and calculate their sum without using any built-in functions or methods. The function should start with: ```python def print_and_sum_odd_numbers(n: int) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python def print_and_sum_odd_numbers(n: int) -> None: """ Prints all odd integers from 1 to n and calculates their sum. Args: n (int): The upper limit of the range (inclusive). Returns: None: This function doe...
magic_evol_110k
89,452
Write a Python function to remove all duplicated words from an input sentence, keeping only the first occurrence of each word. The function should handle various edge cases, such as empty sentences, sentences with all unique words, and sentences with all duplicate words. The code should start with: ```python def remove...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_duplicates(sentence: str) -> str: """ Removes all duplicated words from the input sentence, keeping only the first occurrence of each word. Args: sentence (str): The input sentence from which to remove du...
magic_evol_110k
89,457
Write a Python function to evaluate an expression written in reverse Polish notation (RPN) with variable substitution. The function should handle variable substitution with precedence order, where a variable can be replaced by another variable or a number. The code should start with: ```python from typing import Dict ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict from operator import add, sub, mul def evaluate_rpn_with_substitution(expression: str, substitution_dict: Dict[str, str]) -> int: """ Evaluate an expression written in reverse Polish notation with variab...
magic_evol_110k
89,461
Write a Python function to rearrange the elements of a given list in decreasing order using a custom sorting algorithm. The function should not use Python's built-in `sorted()` function or any other built-in sorting functions. Instead, implement a sorting algorithm such as Bubble Sort, Selection Sort, or Insertion Sort...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def rearrange_in_decreasing_order(arr: List[int]) -> List[int]: """ Rearranges the elements of the given list in decreasing order using Bubble Sort. Args: arr (List[int]): The list of intege...
magic_evol_110k
89,463
Write a Python function to analyze the structure of a provided collection of variables, potentially consisting of a diverse medley of data types such as floating point numbers, strings, and other types. The function should return a dictionary where the keys are the data types found in the collection and the values are ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Any def analyze_collection(collection: List[Any]) -> Dict[type, List[Any]]: """ Analyzes the structure of a provided collection of variables and returns a dictionary where the keys are the dat...
magic_evol_110k
89,472
Translate the given MATLAB code snippet into Python and correct potential errors. Your corrected program should behave identically to the original MATLAB code. Explain why the provided MATLAB code may give incorrect results and discuss the potential pitfalls that can occur when translating between these two languages. ...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def matlab_to_python_translation(): """ Translate the given MATLAB code snippet into Python and correct potential errors. MATLAB Code: A = [1 2 3; 4 5 6; 7 8 9]; B = A(1, :) C = A(:, 2) D...
magic_evol_110k
89,489
Write a Python function to identify and return all duplicate files in a file system based on their content. The function should take a list of strings where each string represents a directory path followed by the files in that directory and their contents. The function should return a list of lists, where each sublist ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_duplicate_files(paths: List[str]) -> List[List[str]]: """ Identifies and returns all duplicate files in a file system based on their content. Args: paths (List[str]): A list of stri...
magic_evol_110k
89,517
Write a Python function to recursively flatten a multidimensional list. The function should handle lists of arbitrary depth and return a single list containing all the elements in a flattened manner. The code should start with: ```python from typing import List, Any def flatten_list(multidimensional_list: List[Any]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def flatten_list(multidimensional_list: List[Any]) -> List[Any]: """ Recursively flattens a multidimensional list into a single list. Args: multidimensional_list (List[Any]): The multid...
magic_evol_110k
89,525
Write a Python function to process a list of strings, where each string contains only digits. The function should return a list of strings, where each string describes the number of odd digits in the corresponding input string. The format of each output string should be: "the quantity of odd components <count>n the str...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def peculiar_sum(lst: List[str]) -> List[str]: """ Given a list of strings exclusively containing digits, return a list where each element describes the number of odd digits in the corresponding inpu...
magic_evol_110k
89,532
Write a Python function to find the unique occurrences of elements in an iterable object and return a dictionary where the keys are the unique elements and the values are their respective counts. The function should handle any iterable object, such as lists, tuples, and sets. 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, Iterable from collections import defaultdict def unique_occurrences(iterable: Iterable) -> Dict[int, int]: """ Returns a dictionary where the keys are the unique elements from the iterable and the v...
magic_evol_110k
89,541
Write a Python function to calculate both the sum and the product of all integers from 1 to a given integer `n`. The function should return a tuple containing the sum and the product. The code should start with: ```python def sum_and_product_to_n(n: int) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_and_product_to_n(n: int) -> tuple: """ Calculate the sum and product of all integers from 1 to n. Args: n (int): The upper limit of the range of numbers to sum and multiply. Returns: tuple: A tu...
magic_evol_110k
89,550
Write a Python function to generate a dictionary where the keys are the individual words of a given sentence, and the values are the number of vowels in the respective word. The sentence may contain punctuation and mixed case letters. The function should handle these cases by normalizing the words (removing punctuation...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import string def count_vowels_in_words(sentence: str) -> Dict[str, int]: """ Generate a dictionary where the keys are the individual words of the sentence, and the values are the number of vowels in...
magic_evol_110k
89,554
Write a Python function to determine if a given text chain contains the term "canine" either at the beginning or the end of the chain, followed by any number of characters except the alphabets "x" and "y". The function should return `True` if the text chain matches the pattern, and `False` otherwise. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python import re def match_canine_sequence(sequence: str) -> bool: """ Determine if the given text chain contains the term "canine" either at the beginning or the end, followed by any number of characters except the alphabets "x" ...
magic_evol_110k
89,560
Write a Python function to convert a list of hexadecimal string values into their corresponding binary representations. Each binary representation should be padded with leading zeros to ensure that the binary string length is a multiple of 4. The function should start with: ```python from typing import List def hex_to...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def hex_to_binary(hex_values: List[str]) -> List[str]: """ Converts a list of hexadecimal string values into their corresponding binary representations. Each binary string is padded with leading zero...
magic_evol_110k
89,575
Write a Python function to process a given array of numerical entities according to the following steps: 1. Sort the array in descending order. 2. Remove all numbers which are multiples of 5. 3. Transform the resulting array into a string delineated by commas. 4. Add surrounding square brackets to the string. The func...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_array(arr: List[int]) -> str: """ Processes the given array of numerical entities by performing the following steps: 1. Sorts the array in descending order. 2. Removes all numbers whi...
magic_evol_110k
89,581
Write a Python function to find the nth character in a given string, where the string is provided as input and the position n is also provided as input. The function should handle cases where n is out of bounds by returning an empty string. The code should start with: ```python def get_nth_character(s: str, n: int) -> ...
Here is the Python code to solve the given problem in the markdown block: ```python def get_nth_character(s: str, n: int) -> str: """ Returns the nth character in the given string, or an empty string if n is out of bounds. Args: s (str): The input string from which to extract the character. ...
magic_evol_110k
89,584
Write a Python function to calculate the arithmetic average (mean) of a given list of numerical data points. The function should handle lists of any length, including empty lists, and return the mean value. If the list is empty, the function should return `None`. The code should start with: ```python from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def calculate_mean(data_points: List[float]) -> Optional[float]: """ Calculate the arithmetic average (mean) of a given list of numerical data points. Args: data_points (List[float...
magic_evol_110k
89,585
Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should return `True` if the two strings are anagrams, and `False` othe...
Here is the Python code to solve the given problem in the markdown block: ```python def are_anagrams(str1: str, str2: str) -> bool: """ Determine if two given strings are anagrams of each other. Args: str1 (str): The first string to compare. str2 (str): The second string to compare. Re...
magic_evol_110k
89,587
Write a Python function to calculate the total sales across all regions from a given list of sales data. Each item in the list is a dictionary containing the region and the corresponding sales amount. The function should sum up all the sales amounts and return the total sales. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def calculate_total_sales(sales_data: List[Dict[str, int]]) -> int: """ Calculate the total sales across all regions from a given list of sales data. Args: sales_data (List[Dict[str, i...
magic_evol_110k
89,594
Write a Python function to generate a list of all even numbers between two given numbers, and identify and label any prime numbers within that range. The function should return a dictionary where each key-value pair represents an even number and a boolean value indicating whether it is prime. The function should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def even_prime_numbers(min_num: int, max_num: int) -> dict: """ Generates a list of all even numbers between min_num and max_num (inclusive), and identifies whether each even number is prime. Returns a dictionary where e...
magic_evol_110k
89,603
Write a Python function to detect sequences that comprise only lowercase letters, digits, and exactly one special character '@'. The function should return `True` if the input string matches the pattern, and `False` otherwise. The code should start with: ```python import re def detect_special_sequences(input_string: s...
Here is the Python code to solve the given problem in the markdown block: ```python import re def detect_special_sequences(input_string: str) -> bool: """ Detects if the input string comprises only lowercase letters, digits, and exactly one '@' character. Args: input_string (str): The string to be...
magic_evol_110k
89,617
Write a Python function to create a dictionary where each element from a given list serves as a distinct key, and its corresponding value is the element's retrograde index (i.e., the index of the element from the end of the list). The function should start with: ```python from typing import List, Dict def create_retro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def create_retrograde_index_dict(my_list: List[int]) -> Dict[int, int]: """ Creates a dictionary where each element from the given list serves as a distinct key, and its corresponding value is ...
magic_evol_110k
89,623
Write a Python function to generate the Fibonacci sequence up to the nth term. The function should return a list containing the Fibonacci sequence. Additionally, provide a detailed explanation of the mathematical principle driving the Fibonacci sequence. The code should start with: ```python from typing import List d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_fibonacci_sequence(n: int) -> List[int]: """ Generate the Fibonacci sequence up to the nth term. The Fibonacci sequence is a series of numbers where each number is the sum of the two pr...
magic_evol_110k
89,631
Write a Python function that adds an item to a given sorted list in a way that the list remains sorted after the addition. The list consists of numbers and is sorted in ascending order. The function should not use built-in Python functions to sort the list. The function should have a time complexity of O(n) and a space...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_item_to_sorted_list(lst: List[int], item: int) -> List[int]: """ Adds an item to a sorted list in a way that the list remains sorted. Args: lst (List[int]): The sorted list to which ...
magic_evol_110k
89,640
Write a Python function to retrieve the last element from a given list of integers. If the list is empty, the function should return `None`. The function should be efficient and handle edge cases appropriately. The code should start with: ```python from typing import List, Optional def get_last_element(lst: List[int]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def get_last_element(lst: List[int]) -> Optional[int]: """ Retrieves the last element from a given list of integers. Args: lst (List[int]): The list of integers from which to retri...
magic_evol_110k
89,643
Write a Python function to sort a given array of numbers in ascending order without using any built-in sort functions. The function should work for both arrays of integers and float numbers. The code should start with: ```python from typing import List, Union def custom_sort(numbers: List[Union[int, float]]) -> List[U...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def custom_sort(numbers: List[Union[int, float]]) -> List[Union[int, float]]: """ Sorts a given array of numbers in ascending order using the Bubble Sort algorithm. Args: numbers (Lis...
magic_evol_110k
89,657
Write a Python function to determine whether the keys in a provided dictionary are all in lower case, all in upper case, or mixed. Additionally, the function should check if the values corresponding to lower case keys are in lower case and values corresponding to upper case keys are in upper case. If the dictionary is ...
Here is the Python code to solve the given problem in the markdown block: ```python def check_dict_case(dct: dict) -> bool: """ Determine whether the keys in the provided dictionary are all in lower case, all in upper case, or mixed. Additionally, check if the values corresponding to lower case keys are in ...
magic_evol_110k
89,663
Write a Python function to efficiently merge a list of strings into a single string with a specified delimiter. The function should handle edge cases such as an empty list or a list containing only empty strings. The code should start with: ```python from typing import List def merge_strings(list_of_strings: List[str]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_strings(list_of_strings: List[str], delimiter: str = ' ') -> str: """ Merges a list of strings into a single string with a specified delimiter. Args: list_of_strings (List[str]): T...
magic_evol_110k
89,674
Write a Python function to filter out email addresses that are associated with the domain name "example.com" using a regular expression. The function should take a list of email addresses as input and return a list of email addresses that match the specified domain. 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 import re def filter_example_com_emails(emails: List[str]) -> List[str]: """ Filters out email addresses that are associated with the domain "example.com". Args: emails (List[str]): A list o...
magic_evol_110k
89,683
Write a Python function to convert a binary number represented as a string to its decimal (base 10) equivalent. The function should handle binary strings of any length and should return the decimal representation of the given binary number. The code should start with: ```python def binary_to_decimal(binary: str) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python def binary_to_decimal(binary: str) -> int: """ Converts a binary number represented as a string to its decimal (base 10) equivalent. Args: binary (str): The binary number to be converted, represented as a string of ...
magic_evol_110k
89,684
Write a Python function to generate the first `n` numbers in the Fibonacci series. The function should handle edge cases such as when `n` is less than or equal to 0, or when `n` is exactly 1 or 2. The code should start with: ```python from typing import List def generate_fibonacci_series(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_fibonacci_series(n: int) -> List[int]: """ Generate the first n numbers in the Fibonacci series. Args: n (int): The number of Fibonacci numbers to generate. Returns: ...
magic_evol_110k
89,690
Write a Python function to round each element in a list of floating-point numbers to the nearest integer, ensuring that the rounding is done in a way that minimizes the absolute difference between the original floating-point number and its rounded integer counterpart. The function should handle both positive and negati...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def round_to_nearest_integer(numbers: List[float]) -> List[int]: """ Rounds each floating-point number in the input list to the nearest integer. Args: numbers (List[float]): A list of floati...
magic_evol_110k
89,702
Write a Python function to reorder a given dictionary object based on the numerical values contained within, handling both negative and decimal values. The function should return a new dictionary with the keys sorted by their corresponding values in ascending order. The code should start with: ```python from collectio...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import OrderedDict def sort_dict_by_value(d: dict) -> OrderedDict: """ Reorders the given dictionary based on the numerical values of its items in ascending order. Args: d (dict): The dictionary to...
magic_evol_110k
89,706
Write a Python function to convert a matrix of hexadecimal strings to their corresponding decimal values. The matrix is represented as a list of strings, where each string is a hexadecimal number prefixed with '0x'. The function should return a list of integers, each representing the decimal equivalent of the correspon...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_hex_matrix_to_decimal(matrix: List[str]) -> List[int]: """ Converts a matrix of hexadecimal strings to their corresponding decimal values. Args: matrix (List[str]): A list of str...
magic_evol_110k
89,710
Write a Python function to reverse a list of integers and concatenate them into a single string. The function should take a list of integers as input and return a string where the integers are concatenated in reverse order. The code should start with: ```python from typing import List def reverse_and_concatenate(numb...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_and_concatenate(numbers: List[int]) -> str: """ Reverses a list of integers and concatenates them into a single string. Args: numbers (List[int]): A list of integers to be revers...
magic_evol_110k
89,720
Write a Python function `get_positive_and_sort` that filters out all positive integers from a given list, removes duplicates, and sorts the remaining numbers in ascending order without using Python's built-in `sort()` or `sorted()` functions. Additionally, implement a helper function `swap_elements` to facilitate the s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_positive_and_sort(l: List[int]) -> List[int]: """ Returns only unique positive numbers from the list, sorted in ascending order. Args: l (List[int]): The input list of integers. ...
magic_evol_110k
89,730
Write a Python function to rotate the elements of an n-dimensional array in a spiral pattern. The function should start with: ```python from typing import List def rotate_spiral(matrix: 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 rotate_spiral(matrix: List[List[int]]) -> List[int]: """ Rotates the elements of an n-dimensional array in a spiral pattern. Args: matrix (List[List[int]]): The input matrix to be rotate...
magic_evol_110k
89,732
Write a Python function to convert a given string to lowercase, ensuring that all characters in the string are converted to their lowercase equivalents. The function should handle strings with mixed case characters, punctuation, and spaces. The code should start with: ```python def convert_to_lowercase(input_str: str) ...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_lowercase(input_str: str) -> str: """ Converts all uppercase letters in the input string to lowercase. Args: input_str (str): The string to be converted to lowercase. Returns: str: The in...
magic_evol_110k
89,733
Write a Python function to find the maximum sum of a contiguous sub-array within a given array of integers. The function should efficiently handle arrays with both positive and negative numbers. The code should start with: ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def max_subarray_sum(arr: List[int]) -> int: """ Find the maximum sum of a contiguous sub-array within the given array. Args: arr (List[int]): The array of integers to search for the maxim...
magic_evol_110k
89,762
Write a Python function to organize an array of real, non-integer numbers in a sequential pattern. The function should take into account both positive and negative values and should return the sorted array. Additionally, the function should provide an option to sort the array in ascending or descending order based on a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def organize_numbers(numbers: List[float], ascending: bool = True) -> List[float]: """ Organizes an array of real, non-integer numbers in a sequential pattern. Args: numbers (List[float]): T...
magic_evol_110k
89,775
Write a Python function to generate a list of prime numbers within a given range `[start, end]` without using any built-in math or prime-generating libraries. The function should implement a custom function to check if a number is prime and ensure the time complexity is optimal. 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 is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
magic_evol_110k
89,781
Write a Python function to perform the multiplication of two integers and return the result. The function should be flexible enough to handle any two integers provided as input. Additionally, write a test function to verify the correctness of the multiplication function using various test cases. The code should start ...
Here is the Python code to solve the given problem in the markdown block: ```python def multiply_integers(num1: int, num2: int) -> int: """ Multiplies two integers and returns the result. Args: num1 (int): The first integer to be multiplied. num2 (int): The second integer to be multiplied. ...
magic_evol_110k
89,797
Write a Python function to calculate the absolute numerical disparity between two given values. The function should take two integers as input and return the absolute difference between them. The code should start with: ```python def calculate_disparity(value1: int, value2: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_disparity(value1: int, value2: int) -> int: """ Calculate the absolute numerical disparity between two given values. Args: value1 (int): The first value. value2 (int): The second value. Re...
magic_evol_110k
89,821
Write a Python function to locate the positions of every instance of a specific integer within a given array. The function should return a list of indices where the integer is found. The code should start with: ```python from typing import List def find_positions(array: List[int], integer: int) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_positions(array: List[int], integer: int) -> List[int]: """ Locate the positions of every instance of a specific integer within a given array. Args: array (List[int]): The array in ...
magic_evol_110k
89,827
Write a Python function to detect if the balance of a bank account falls below zero at any point during a series of deposit and withdrawal operations. The function should also include an optional `case_insensitive` flag that, when set to `True`, will return `True` if the balance equals zero as well. The function should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def below_zero(operations: List[int], case_insensitive: bool = False) -> bool: """ Detects if the balance of a bank account falls below zero at any point during a series of deposit and withdrawal operati...
magic_evol_110k
89,834
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...
magic_evol_110k
89,841
Write a Python function to display each element of a provided list of incomplete sentences, ensuring each fragment occupies a distinct line. The function should accept a list of strings as input and print each string on a new line. The code should start with: ```python from typing import List def display_sentences(sen...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def display_sentences(sentences: List[str]) -> None: """ Displays each element of the provided list of incomplete sentences, ensuring each fragment occupies a distinct line. Args: sentences ...
magic_evol_110k
89,843
Write a Python function to transform all the animal names in a given array into uppercase letters without using built-in Python functions like `str.upper()`. The function should also validate that the array contains only strings. If any element in the array is not a string, the function should return an error message: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def uppercase_animals(animal_arr: List[str]) -> List[str] or str: """ Transforms all animal names in the given array to uppercase without using built-in str.upper(). Also validates that the array con...
magic_evol_110k
89,853
Write a Python function to create a structured NumPy array that contains the square values of consecutive integers starting from a given initial value up to a specified terminal value (exclusive). The structured array should have a single field named `square_val` that stores the square values. The function should handl...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def create_square_values_array(initial_value: int, terminal_value: int) -> np.ndarray: """ Creates a structured NumPy array containing the square values of consecutive integers starting from the initial v...
magic_evol_110k
89,856
Write a Python function to compute the n-th element of a modified Tribonacci sequence where the sequence is defined as follows: - `tribonacci_prime(0) == 0` - `tribonacci_prime(1) == 0` - `tribonacci_prime(2) == 1` - For `n > 2`, `tribonacci_prime(n) == tribonacci_prime(n-1) + tribonacci_prime(n-2) + tribonacci_prime(n...
Here is the Python code to solve the given problem in the markdown block: ```python def tribonacci_prime(n: int, k: int) -> int: """ Compute the n-th element of a modified Tribonacci sequence where: - tribonacci_prime(0) == 0 - tribonacci_prime(1) == 0 - tribonacci_prime(2) == 1 - For n > 2, tri...
magic_evol_110k
89,867
Write a Python function to manipulate a two-dimensional list of floating-point numbers based on the parity (odd or even) of the count of numbers in each sublist. If the count of numbers in a sublist is odd, round each number down to the nearest whole number. If the count is even, round each number up to the nearest who...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def manipulate_list(lst: List[List[float]]) -> List[List[int]]: """ Manipulate a two-dimensional list of floating-point numbers based on the parity of the count of numbers in each sublist. ...
magic_evol_110k
89,884
Write a Python function to construct a new array where each element is the cube of the corresponding element in the original array. The function should take a list of integers as input and return a new list of integers where each element is the cube of the corresponding element in the input list. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cube_array(arr: List[int]) -> List[int]: """ Constructs a new array where each element is the cube of the corresponding element in the original array. Args: arr (List[int]): The original...
magic_evol_110k
89,909
Write a Python function to determine if it is possible to arrange a list of strings, each containing only brackets (i.e., '(', ')', '[', ']', '{', '}'), in such a way that the resulting sequence forms a valid nested and matching bracket structure. The function should return 'Yes' if such an arrangement is possible, and...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def match_brackets(lst: List[str]) -> str: """ Determines if it is possible to arrange the given list of bracket strings to form a valid nested and matching bracket structure. Args: lst (Lis...
magic_evol_110k
89,914
Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should return a boolean value indicating whether the two strings are a...
Here is the Python code to solve the given problem in the markdown block: ```python def are_anagrams(str1: str, str2: str) -> bool: """ Determines if two given strings are anagrams of each other. Args: str1 (str): The first string to compare. str2 (str): The second string to compare. R...
magic_evol_110k
89,931
Write a Python function to process a nested list of strings by performing two distinct operations: 1. Remove any repetitive string elements within each unique inner list. 2. Arrange each inner list in ascending lexicographical order, considering the case sensitivity of the string elements. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def process_nested_list(nested_list: List[List[str]]) -> List[List[str]]: """ Processes a nested list of strings by removing duplicates within each inner list and sorting each inner list in ascending...
magic_evol_110k
89,934
Write a Python function to remove all occurrences of a specified numerical value from a given list of integers. The function should return a new list with the specified value removed. The code should start with: ```python from typing import List def remove_all_occurrences(input_list: List[int], value_to_remove: int) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_all_occurrences(input_list: List[int], value_to_remove: int) -> List[int]: """ Removes all occurrences of a specified numerical value from a given list of integers. Args: input_li...
magic_evol_110k
89,961
Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should return a boolean value indicating whether the two strings are a...
Here is the Python code to solve the given problem in the markdown block: ```python def are_anagrams(str1: str, str2: str) -> bool: """ Determine if two given strings are anagrams of each other. Args: str1 (str): The first string to compare. str2 (str): The second string to compare. Re...
magic_evol_110k
89,965
Write a Python function to rearrange the elements of a given tuple such that all even numbers appear first, followed by all odd numbers, both in ascending order. The function should return the rearranged tuple. The code should start with: ```python from typing import Tuple def rearrange_tuple(tup: Tuple[int]) -> Tupl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple def rearrange_tuple(tup: Tuple[int]) -> Tuple[int]: """ Rearranges the elements of a given tuple such that all even numbers appear first, followed by all odd numbers, both in ascending order. A...
magic_evol_110k
89,967
Write a Python function to reverse each string in a given list and concatenate the reversed strings with a specified delimiter. The function should include validation to ensure that the input list contains only strings and that the delimiter is also a string. The function should raise appropriate exceptions if the inpu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def concatenate_reversed_strings(array: List[str], delimiter: str) -> str: """ Reverses each string in the given list and concatenates them with the specified delimiter. Args: array (List[st...
magic_evol_110k
89,973
Write a Python function to generate the first `n` Fibonacci numbers, where each number is the sum of the two preceding ones. The function should return a list of these Fibonacci numbers. The code should start with: ```python from typing import List def generate_fibonacci(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_fibonacci(n: int) -> List[int]: """ Generate the first n Fibonacci numbers. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usu...
magic_evol_110k
89,974
Write a Python function to construct a unified shell script that integrates two subsequent commands. The first command should display the text "FileName: File1". The second command should utilize the `cat` command to display the contents of the file named "File1.txt". The function should return the complete shell scrip...
Here is the Python code to solve the given problem in the markdown block: ```python def construct_shell_script() -> str: """ Constructs a unified shell script that integrates two subsequent commands. The first command displays the text "FileName: File1". The second command utilizes the cat command to di...
magic_evol_110k
89,975
Write a Python function to categorize the distinct characters present in a given string, specifically focusing on the English alphabet 'abcdefghijklmnopqrstuvwxyz'. The function should return a dictionary where the keys are the distinct characters from the alphabet and the values are their respective counts in the inpu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import collections def categorize_characters(s: str) -> Dict[str, int]: """ Categorizes the distinct characters present in a given string, specifically focusing on the English alphabet 'abcdefghijklmnopq...
magic_evol_110k
89,977
Write a Python function to convert a base-10 numerical value into a standardized dollar (USD) currency format. The function should handle both positive and negative amounts, and should format the amount to two decimal places, with commas as thousand separators. The function should also handle edge cases such as zero an...
Here is the Python code to solve the given problem in the markdown block: ```python def format_usd(amount: float) -> str: """ Converts a base-10 numerical value into a standardized dollar (USD) currency format. Args: amount (float): The numerical value to be formatted. Returns: str: Th...
magic_evol_110k
89,980
Write a Python function to apply a cubic transformation to each element in a given two-dimensional array (matrix). The function should return a new matrix where each element is the cube of the corresponding element in the input matrix. The code should start with: ```python from typing import List def cubic_transform(m...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cubic_transform(matrix: List[List[int]]) -> List[List[int]]: """ Applies a cubic transformation to each element in a given two-dimensional array (matrix). Args: matrix (List[List[int]]):...
magic_evol_110k
89,994
Write a Python function to distribute a given sum of money equally among a specified number of people and return the amount each person receives and the amount left undistributed. The function should handle cases where the number of people is zero or negative by returning a message indicating that the distribution is n...
Here is the Python code to solve the given problem in the markdown block: ```python def distribute_money(total_sum: int, people: int) -> tuple: """ Distributes a given sum of money equally among a specified number of people and returns the amount each person receives and the amount left undistributed. Args...
magic_evol_110k
90,011
Write a Python function to convert a given list of integers into a NumPy array and then compute the sum of all elements in the array. The function should return the sum as an integer. The code should start with: ```python from typing import List import numpy as np def sum_of_array_elements(numbers: List[int]) -> int: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import numpy as np def sum_of_array_elements(numbers: List[int]) -> int: """ Converts a list of integers into a NumPy array and computes the sum of all elements in the array. Args: numbers (...
magic_evol_110k
90,032
Write a Python function to reverse the order of elements in a given list. The function should not use the built-in `reverse` method or slicing with `[::-1]`. Instead, it should use an iterative approach to reverse the list in place. The code should start with: ```python from typing import List def reverse_list(arr: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(arr: List[int]) -> None: """ Reverses the order of elements in the given list in place. Args: arr (List[int]): The list of integers to be reversed. Returns: Non...
magic_evol_110k
90,035
Write a Python function to find the maximum value and its index from a given list of integers. If there are multiple maximum values, return the index of the first occurrence. The function should handle edge cases such as an empty list or a list with all identical elements. The code should start with: ```python from typ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_max_value_and_index(lst: List[int]) -> Tuple[int, int]: """ Find the maximum value and its index in a list of integers. Args: lst (List[int]): The list of integers from which...
magic_evol_110k
90,037
Write a Python function to calculate the disparity between two provided Unix timestamps in both seconds and minutes. The function should ensure that the timestamps are processed in chronological order, regardless of their initial order. The code should start with: ```python def calculate_disparity(timestamp1: int, time...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_disparity(timestamp1: int, timestamp2: int) -> tuple: """ Calculate the disparity between two Unix timestamps in both seconds and minutes. Args: timestamp1 (int): The first Unix timestamp. time...
magic_evol_110k
90,040
Write a Python function to combine two lists into a dictionary, where the first list serves as the keys and the second list serves as the values. Ensure that the function handles cases where the lists are of different lengths by ignoring the extra elements in the longer list. 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, Dict def combine_lists_to_dict(keys: List[str], values: List[str]) -> Dict[str, str]: """ Combines two lists into a dictionary where the first list serves as the keys and the second list serves as the v...
magic_evol_110k
90,052
Write a Python function to generate a list of odd numbers up to a given upper limit. The function should be efficient, handle improper inputs gracefully, and raise appropriate exceptions when the input deviates from the expected format or type. The function should start with: ```python def get_odds(input_limit: int) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_odds(input_limit: int) -> List[int]: """ Generate a list of odd numbers up to a given upper limit. Args: input_limit (int): The upper limit (exclusive) up to which odd numbers are to...
magic_evol_110k
90,056
Write a Python function to determine if a given string `s` containing only the characters `'('`, `')'`, and `'*'` is a valid parenthesis string. The string is considered valid if: 1. Every left parenthesis `'('` has a corresponding right parenthesis `')'`. 2. Every right parenthesis `')'` has a corresponding left paren...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_parenthesis_string(s: str) -> bool: """ Determine if the given string `s` is a valid parenthesis string. Args: s (str): The string to be checked, containing only '(', ')', and '*'. Returns: ...
magic_evol_110k
90,060
Write a Python function to identify and replace all email addresses in a given string with the term "EMAIL" using regular expressions. The function should handle various email formats and ensure that only valid email addresses are replaced. The code should start with: ```python import re def replace_emails_with_EMAIL(...
Here is the Python code to solve the given problem in the markdown block: ```python import re def replace_emails_with_EMAIL(text: str) -> str: """ Replaces all email addresses in the given text with the term "EMAIL". Args: text (str): The input string containing email addresses. Returns: ...
magic_evol_110k
90,071
Write a Python function to find the `k` closest elements to a given integer `x` in a sorted integer array `arr`. The output should be a list of `k` integers from `arr` that are closest to `x`, sorted in ascending order. The function should be optimized to run in O(log n) time complexity and should not use any built-in ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_k_closest_elements(arr: List[int], k: int, x: int) -> List[int]: """ Find the k closest elements to x in a sorted array arr. Args: arr (List[int]): A sorted list of integers. ...
magic_evol_110k
90,073
Write a Python function to create an associative array (dictionary) where the keys are the unique words in a given sentence, and the values are the counts of vowel phonetics (a, e, i, o, u) in each corresponding word. The function should handle case insensitivity and punctuation. The code should start with: ```python ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import string def count_vowels_in_words(sentence: str) -> Dict[str, int]: """ Counts the number of vowel phonetics (a, e, i, o, u) in each word of a given sentence and returns an associative array. ...
magic_evol_110k
90,085
Write a Python function to split a given string into a list of words based on a specified delimiter. The function should handle multiple consecutive delimiters by treating them as a single delimiter and should not include empty strings in the result. The code should start with: ```python from typing import List def sp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def split_string(input_str: str, delimiter: str = " ") -> List[str]: """ Splits a given string into a list of words based on a specified delimiter. Multiple consecutive delimiters are treated as a si...
magic_evol_110k
90,088
Write a Python function to print all odd numbers from a given list, ignoring even numbers, and ensure the loop terminates correctly. The function should start with: ```python def print_odd_numbers(values: List[int]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def print_odd_numbers(values: List[int]) -> None: """ Prints all odd numbers from the given list, ignoring even numbers. Args: values (List[int]): The list of integers from which to print ...
magic_evol_110k
90,091
Write a Python function to calculate the product of all elements in a given array. The function should handle arrays with negative numbers, zeros, and arrays of size up to \(10^6\). The function should return 0 if the array is empty. The code should start with: ```python from typing import List def calculate_product(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List from functools import reduce import operator def calculate_product(arr: List[int]) -> int: """ Calculate the product of all elements in the given array. Args: arr (List[int]): The array of i...
magic_evol_110k
90,093
Write a Python function to determine whether a particular item is present within a provided list using two different methods: one using a linear search and the other using Python's built-in membership operator. The function should return a tuple containing the results of both methods. The code should start with: ```py...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def is_item_present(list: List[int], item: int) -> Tuple[bool, bool]: """ Determines whether a particular item is present within a provided list using two different methods. Args: lis...
magic_evol_110k
90,098
Write a Python function to generate a random number between a given range `[min_value, max_value]`. The function should ensure that the generated number is within the specified range and should handle cases where `min_value` is greater than `max_value` by swapping them. The function should also handle cases where `min_...
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(min_value: int, max_value: int) -> int: """ Generates a random integer within the specified range [min_value, max_value]. Args: min_value (int): The lower bound of the range...
magic_evol_110k
90,112
Write a Python function to generate a list of all prime numbers between 2 and N using an optimized algorithm. The function should also validate if N is a legitimate input and return an error message if N is not a positive integer. The value of N can reach up to 10^5. The function should start with: ```python def genera...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_primes(n: int) -> list[int] | str: """ Generate a list of all prime numbers between 2 and N using the Sieve of Eratosthenes algorithm. If N is not a positive integer, return an error message. Args: ...
magic_evol_110k
90,119
Write a Python function to print all prime numbers between a given range `[start, end]`. The function should be efficient and correctly handle edge cases such as negative numbers, zero, and one. The code should start with: ```python def print_primes_in_range(start: int, end: int) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(num: int) -> bool: """ Check if a given number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ""...
magic_evol_110k
90,124
Write a Python function to find the smallest absolute value among a list of negative floating point numbers. The function should take a list of negative floating point numbers as input and return the smallest absolute value. The code should start with: ```python from typing import List def find_smallest_absolute_value...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_smallest_absolute_value(numbers: List[float]) -> float: """ Find the smallest absolute value among a list of negative floating point numbers. Args: numbers (List[float]): A list of ...
magic_evol_110k
90,136
Write a Python function to reverse the sequence of words in a given sentence and then reverse each word individually. The function should take a sentence as input and return the modified sentence. The code should start with: ```python def reverse_sentence_and_words(sentence: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_sentence_and_words(sentence: str) -> str: """ Reverses the sequence of words in the given sentence and then reverses each word individually. Args: sentence (str): The input sentence to be modified. ...
magic_evol_110k
90,137
Write a Python function to create a sequence of `n` non-repetitive elements in descending order, selected from a given numeric array. The function should ensure that the selected elements are unique and sorted in descending order. The code should start with: ```python from typing import List def select_n_descending(nu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def select_n_descending(num_array: List[int], n: int) -> List[int]: """ Selects the n largest non-repetitive elements from the given numeric array in descending order. Args: num_array (List[...
magic_evol_110k
90,139
Write a Python function to remove all instances of the number 3 from a given list, including nested lists, while maintaining the original nested structure. The function should handle lists that contain other lists, ensuring that the integrity of the nested structure is preserved. The function should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def eradicate_threes(mylist: List[Union[int, List]]) -> List[Union[int, List]]: """ Removes all instances of the number 3 from a given list, including nested lists, while maintaining the origi...
magic_evol_110k
90,186
Write a Python function to filter out and exclude any words with a length exceeding 5 letters from a given dataset. The dataset is a list of strings. The function should return a new list containing only the words that have a length of 5 or fewer characters. The code should start with: ```python from typing import Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_short_words(dataset: List[str]) -> List[str]: """ Filters out and excludes any words with a length exceeding 5 letters from the given dataset. Args: dataset (List[str]): The datas...
magic_evol_110k
90,193
Write a Python function to detect if the balance of a bank account falls below zero at any point given a list of deposit and withdrawal operations. The operations can be integers or strings representing integers. Additionally, include an optional `case_insensitive` flag to return `True` if the balance equals zero as we...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def below_zero(operations: List[Union[int, str]], case_insensitive: bool = False) -> bool: """ Detect if the balance of a bank account falls below zero at any point given a list of deposit and wit...
magic_evol_110k
90,195
Write a Python function to convert a given time from Central Daylight Time (CDT) to Eastern Standard Time (EST). The input time is provided in the format "HH:MM" and should be returned in the same format. The function should handle the time zone conversion by adjusting the time by 1 hour. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime, timedelta def convert_cdt_to_est(cdt_time_str: str) -> str: """ Converts a given time from Central Daylight Time (CDT) to Eastern Standard Time (EST). Args: cdt_time_str (str): The ti...
magic_evol_110k
90,203
Write a Python function to implement a linear search algorithm that locates a specific element within a one-dimensional list. The list may contain a mix of integers, strings, lists, and dictionaries. The function should return the index of the target element if found, otherwise return -1. The solution must ensure a tim...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, List def linear_search(arr: List[Any], target: Any) -> int: """ Perform a linear search to locate a specific element within a one-dimensional list. Args: arr (List[Any]): The list to search ...
magic_evol_110k
90,213
Write a Python function to intersperse a delimiter into a given list of elements. Additionally, provide an option to reverse the list before performing the insertion. The function should accept a list of elements, a delimiter, and a boolean flag indicating whether to reverse the list before insertion. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def intersperse(numbers: List[Any], delimeter: Any, reverse: bool = False) -> List[Any]: """ Intersperses a delimiter into a given list of elements. Optionally, reverses the list before insertion. ...
magic_evol_110k
90,223
Write a Python function to calculate the sum of all 0 to 9 pandigital numbers that exhibit a specific sub-string divisibility property. A pandigital number is a number that contains each of the digits from 0 to 9 exactly once. The sub-string divisibility property is defined as follows: - The substring formed by the 2nd...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import itertools def sum_pandigital_numbers_with_property() -> int: """ Calculate the sum of all 0 to 9 pandigital numbers that exhibit the sub-string divisibility property. Returns: int: Th...
magic_evol_110k
90,233
Write a Python function that performs the following tasks: 1. **Concatenate List Elements**: Concatenate all elements in a given list into a single string. Each word in the list should be capitalized and separated by a specified separator. 2. **String Replacement**: Replace all instances of a user-provided string in t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def process_and_count(input_list: List[str], separator: str, first_string: str, second_string: str, count_string: str) -> Tuple[str, int]: """ Concatenates all elements in a list into a string wit...