source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
evol_instruct_66k
13,007
Write a Python function to evaluate the total sum of a 2-dimensional list. The function should utilize nested loops while making sure to iteratively parse through each sub-list efficiently. The code should start with: ```python from typing import List def sum_2d_list(arr: List[List[int]]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_2d_list(arr: List[List[int]]) -> int: """ Calculate the total sum of a 2-dimensional list of integers. Args: arr (List[List[int]]): A 2-dimensional list of integers. Returns: ...
evol_instruct_66k
13,029
Write a Python function to remove all instances of a specified character from a given text input while maintaining the original sentence structure. The function should handle both uppercase and lowercase instances of the specified character. The code should start with: ```python def remove_character(text: str, char: st...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_character(text: str, char: str) -> str: """ Removes all instances of the specified character from the given text while maintaining the original sentence structure. Args: text (str): The input text from wh...
evol_instruct_66k
13,045
Write a Python function to determine the maximum value among three given integers. The function should take three integers as input and return the maximum value. The code should start with: ```python def find_max_value(a: int, b: int, c: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_max_value(a: int, b: int, c: int) -> int: """ Determine the maximum value among three given integers. Args: a (int): The first integer. b (int): The second integer. c (int): The third intege...
evol_instruct_66k
13,089
Write a Python function to calculate the sum of the first `n` natural numbers efficiently. The function should be optimized for performance and clarity. The code should start with: ```python def sum_of_first_n_natural_numbers(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_first_n_natural_numbers(n: int) -> int: """ Calculate the sum of the first n natural numbers. Args: n (int): The number of natural numbers to sum. Returns: int: The sum of the first n natural...
evol_instruct_66k
13,099
Write a Python function to construct a new array that consists of elements in the reverse order from the original array, without using any built-in reverse methods. The original array should remain unmodified, and the function should have a linear time complexity. 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 def reverse_array(arr: List[int]) -> List[int]: """ Constructs a new array with elements in the reverse order from the original array. The original array remains unmodified. Args: arr (L...
evol_instruct_66k
13,128
Write a Python function to normalize a list of complex numbers. Normalizing a complex number means dividing it by its magnitude (absolute value). The function should take a list of complex numbers as input and return a list of normalized complex numbers. The code should start with: ```python from typing import List de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def normalize_complex_numbers(complex_list: List[complex]) -> List[complex]: """ Normalizes a list of complex numbers by dividing each complex number by its magnitude. Args: complex_list (Li...
evol_instruct_66k
13,133
Write a Python function to convert a given string to its lowercase equivalent. The function should handle any string input, including those with special characters and numbers, and return the string with all alphabetic characters converted to lowercase. The code should start with: ```python def to_lowercase(input_str:...
Here is the Python code to solve the given problem in the markdown block: ```python def to_lowercase(input_str: str) -> str: """ Converts the given string to its lowercase equivalent. Args: input_str (str): The string to be converted to lowercase. Returns: str: The lowercase equivalent...
evol_instruct_66k
13,145
Write a Python function to safely add an integer and a string representing an integer, and concatenate an integer and a string. The function should handle the conversion and concatenation operations correctly. The code should start with: ```python def safe_add_and_concat(x: int, y: str) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def safe_add_and_concat(x: int, y: str) -> tuple: """ Safely adds an integer and a string representing an integer, and concatenates an integer and a string. Args: x (int): The integer to be added and concatenated. ...
evol_instruct_66k
13,146
Write a Python function to replace all vowel characters in a given string with the asterisk symbol '*'. The function should handle both uppercase and lowercase vowels. The code should start with: ```python def replace_vowels_with_asterisk(message: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def replace_vowels_with_asterisk(message: str) -> str: """ Replace all vowel characters (both uppercase and lowercase) in the given string with the asterisk symbol '*'. Args: message (str): The input string in whi...
evol_instruct_66k
13,160
Write a Python function to calculate the median of a list of five floating-point numbers. The function should handle the sorting of the numbers and determine the median based on whether the length of the list is odd or even. Additionally, create a function to repeat this calculation for five different sets of input num...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_median(numbers: List[float]) -> float: """ Calculate the median of a list of five floating-point numbers. Args: numbers (List[float]): A list of five floating-point numbers. ...
evol_instruct_66k
13,163
Write a Python function to extract the details of the secondary element from a given one-dimensional, map-like data structure. The data structure is a dictionary where each key maps to another dictionary containing details such as name, age, and city. The function should return a dictionary containing the details of th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def extract_secondary_element(data: Dict[str, Dict[str, str]]) -> Dict[str, str]: """ Extracts the details of the secondary element from a given one-dimensional, map-like data structure. Args: ...
evol_instruct_66k
13,165
Write a Python function to generate a random number within a specified interval [lower_limit, upper_limit]. The function should ensure that the generated number is uniformly distributed within the given range. The code should start with: ```python import random def generate_random_number(lower_limit: float, upper_limi...
Here is the Python code to solve the given problem in the markdown block: ```python import random def generate_random_number(lower_limit: float, upper_limit: float) -> float: """ Generates a random floating-point number within the specified interval [lower_limit, upper_limit]. Args: lower_limit (f...
evol_instruct_66k
13,180
Write a Python function to calculate the cumulative sum of elements in a given list of integers. The function should iterate through the list, add each element to a running total, and return the final cumulative sum. The code should start with: ```python from typing import List def cumulative_sum(my_list: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_sum(my_list: List[int]) -> int: """ Calculate the cumulative sum of elements in a given list of integers. Args: my_list (List[int]): The list of integers to calculate the cumu...
evol_instruct_66k
13,181
Write a Python function to find the minimum value in a given array and return both the minimum value and its index. If the array is empty, the function should return `None` for both the minimum value and the index. The function should be efficient and handle edge cases such as empty arrays. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_min_value_and_index(arr: List[int]) -> Tuple[int, int]: """ Find the minimum value and its index in a given array. Args: arr (List[int]): The array in which to find the minim...
evol_instruct_66k
13,188
Write a Python function to determine if a given string is a valid IPv4 address. An IPv4 address consists of four decimal numbers separated by dots, where each number ranges from 0 to 255. The function should return `True` if the string is a valid IPv4 address and `False` otherwise. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_ipv4(ip: str) -> bool: """ Determines if the given string is a valid IPv4 address. Args: ip (str): The string to be checked for IPv4 validity. Returns: bool: True if the string is a valid I...
evol_instruct_66k
13,201
Write a Python function to compute the volume of multiple different types of perfectly symmetrical, three-dimensional objects such as spheres, cubes, cylinders, and cones. The function should be flexible enough to handle any of the mentioned objects while keeping the code efficient. Additionally, implement error handli...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union import math def compute_volume(object_type: str, *args) -> Union[float, str]: """ Computes the volume of a perfectly symmetrical three-dimensional object. Args: object_type (str): The type ...
evol_instruct_66k
13,210
Write a Python function to find the minimum value in a given list of integers. The function should iterate through the list and update the minimum value if a smaller value is found. The code should start with: ```python from typing import List def find_minimum_value(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_minimum_value(numbers: List[int]) -> int: """ Find the minimum value in a given list of integers. Args: numbers (List[int]): A list of integers from which to find the minimum value....
evol_instruct_66k
13,215
Write a Python function to calculate the reciprocals of numbers in a given range, handling potential errors using try-except blocks. The function should return a list of tuples where each tuple contains the number and its reciprocal if it was successfully calculated, or the number and an error message if an error occur...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_reciprocals(n: int) -> List[Tuple[int, float or str]]: """ Calculate the reciprocals of numbers in the range from 0 to n-1, handling potential errors. Args: n (int): The...
evol_instruct_66k
13,236
Write a Python function to calculate the Euclidean distance between two points in a Cartesian coordinate system. The points are represented as tuples of two integers, representing the x and y coordinates. The function should handle points in any position within the Cartesian system. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python import math def euclidean_distance(point1: tuple, point2: tuple) -> float: """ Calculate the Euclidean distance between two points in a Cartesian coordinate system. Args: point1 (tuple): A tuple of two integers rep...
evol_instruct_66k
13,260
Write a Python function to convert a JSON-like object (a dictionary in Python) to a string, while handling circular references and maintaining a custom indentation level. The function should detect and handle circular references by replacing them with a placeholder string (e.g., `"[Circular]"`) and should allow specify...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict, Union import json def json_to_string_with_indent(obj: Union[Dict, Any], indent: int) -> str: """ Convert a JSON-like object (a dictionary in Python) to a string, handling circular references and ma...
evol_instruct_66k
13,261
Write a Python function to convert an ASCII string to an integer array. The function should handle special characters and whitespace, and return an error message for non-ASCII characters. The code should start with: ```python from typing import List, Union def ascii_to_int_array(s: str) -> Union[List[int], str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def ascii_to_int_array(s: str) -> Union[List[int], str]: """ Converts an ASCII string to an integer array. Returns an error message for non-ASCII characters. Args: s (str): The input ...
evol_instruct_66k
13,262
Write a Python function to sort a given list of integers in descending order and return the sorted list. The function should handle lists of any length, including empty lists. The code should start with: ```python from typing import List def sort_descending(numbers: 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_descending(numbers: List[int]) -> List[int]: """ Sorts a list of integers in descending order. Args: numbers (List[int]): The list of integers to be sorted. Returns: ...
evol_instruct_66k
13,286
Write a Python function to merge two sorted arrays without using any additional memory or built-in functions for merging/sorting. The function should preserve the original arrays and return a new merged array sorted in ascending order. The code should start with: ```python from typing import List def merge_sorted_arra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]: """ Merge two sorted arrays into a single sorted array without using additional memory or built-in functions. Args: ar...
evol_instruct_66k
13,301
Write a Python function to verify if a supplied argument is a perfect square or not, returning `True` for perfect squares and `False` otherwise. The function should handle edge cases such as non-integer inputs and negative numbers. The function should be named `is_perfect_square` and should start with: ```python def is...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_perfect_square(n: int) -> bool: """ Verifies if a supplied argument is a perfect square. Args: n (int): The number to check. Returns: bool: True if the number is a perfect square, Fa...
evol_instruct_66k
13,311
Write a Python function to find the smallest disparity (absolute difference) between any pair of elements within a provided array. The function should efficiently traverse the array and compare elements to determine the minimum difference. The code should start with: ```python from typing import List def find_min_diff...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_min_difference(arr: List[int]) -> int: """ Find the smallest disparity (absolute difference) between any pair of elements in the provided array. Args: arr (List[int]): The array of ...
evol_instruct_66k
13,314
Write a Python function to calculate the sum of the three largest numbers in an unordered list of whole numbers. The function should be efficient and handle cases where the list has fewer than three elements. The code should start with: ```python from typing import List def sum_of_three_largest(numbers: List[int]) ->...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import heapq def sum_of_three_largest(numbers: List[int]) -> int: """ Calculate the sum of the three largest numbers in an unordered list of whole numbers. Args: numbers (List[int]): An un...
evol_instruct_66k
13,319
Write a Python function to remove duplicate characters from a given string while maintaining the order of the first occurrence of each character. The function should be efficient and should not use any additional data structures except for the list to store the result. 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_maintain_order(s: str) -> str: """ Removes duplicate characters from the given string while maintaining the order of the first occurrence of each character. Args: s (str): The input string from...
evol_instruct_66k
13,323
Write a Python function to count the number of occurrences of a specified integer in a given list of integers. The function should take two parameters: the list of integers and the integer to count. The function should return the count of the specified integer in the list. The code should start with: ```python from ty...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_occurrences(numbers: List[int], target: int) -> int: """ Counts the number of occurrences of a specified integer in a given list of integers. Args: numbers (List[int]): The list of...
evol_instruct_66k
13,325
Write a Python function to find the most frequent items in a given array of integers. The function should return a list of the items that have the highest frequency in the array. If there are multiple items with the same highest frequency, the function should return all of them. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def most_frequent_items(arr: List[int]) -> List[int]: """ Find the most frequent items in a given array of integers. Args: arr (List[int]): The array of integers from which to find the most ...
evol_instruct_66k
13,331
Write a Python function to recursively substitute a designated entity within a multi-dimensional array. The function should handle nested lists and ensure that all occurrences of the target entity are replaced with the substitution entity. The function should also include input validation to ensure that the input is a ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, List def recursive_substitute(arr: List[Any], target: Any, substitution: Any) -> List[Any]: """ Recursively substitutes a designated entity within a multi-dimensional array. Args: arr (List[...
evol_instruct_66k
13,342
Write a Python function to concatenate two given strings with a space in between and append an exclamation mark at the end using f-string formatting. The function should take two parameters, `a` and `b`, which are the strings to be concatenated. The function should return the resulting string. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_with_exclamation(a: str, b: str) -> str: """ Concatenates two given strings with a space in between and appends an exclamation mark at the end. Args: a (str): The first string to be concatenated. ...
evol_instruct_66k
13,343
Write a Python function to convert a given temperature from one scale to another. The function should support conversions between Fahrenheit, Celsius, and Kelvin. The function should take three parameters: the temperature value, the current temperature scale, and the target temperature scale. The function should return...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_temperature(value: float, from_scale: str, to_scale: str) -> float: """ Convert a temperature from one scale to another. Args: value (float): The temperature value to be converted. from_scale (st...
evol_instruct_66k
13,346
Write a Python function to evaluate the symmetry of two provided dictionaries. The function should check if the two dictionaries have the same keys and corresponding values, regardless of the order of the keys. The function should return `True` if the dictionaries are symmetric, and `False` otherwise. The code should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def are_dictionaries_symmetric(dict1: Dict[str, str], dict2: Dict[str, str]) -> bool: """ Evaluates whether two dictionaries are symmetric, meaning they have the same keys and corresponding values, r...
evol_instruct_66k
13,354
Write a Python function to find the minimum element in an unordered 2D array without using built-in Python functions like `min()` and sorting algorithms like `quickSort` or `mergeSort`. The function should iterate through the array to find the smallest element. The code should start with: ```python from typing import ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_minimum_element(arr: List[List[int]]) -> int: """ Find the minimum element in an unordered 2D array. Args: arr (List[List[int]]): The 2D array in which to find the minimum element. ...
evol_instruct_66k
13,356
Write a Python function to calculate the sum of two integers. The function should take two integer arguments and return their sum. The code should start with: ```python def sum_of_two_integers(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_two_integers(a: int, b: int) -> int: """ Calculate the sum of two integers. Args: a (int): The first integer. b (int): The second integer. Returns: int: The sum of the two integers. ...
evol_instruct_66k
13,357
Write a Python function to analyze and compute the sum of elements in a 4D array along specified axes. The function should take a 4D array and a list of axes as input and return a dictionary where the keys are the axes and the values are the sums of the elements along those axes. The function should also handle the cas...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import numpy as np def compute_sums_along_axes(array_4d: np.ndarray, axes: List[int] = None) -> Dict[int, np.ndarray]: """ Compute the sum of elements in a 4D array along specified axes. Args:...
evol_instruct_66k
13,361
Write a Python function to extract the integer part of a given floating-point number, handling both positive and negative numbers correctly. The function should return the largest integer that is less than or equal to the input number. The code should start with: ```python import math def extract_integer(number: floa...
Here is the Python code to solve the given problem in the markdown block: ```python import math def extract_integer(number: float) -> int: """ Extracts the integer part of a given floating-point number. This function uses the `math.floor` method to determine the largest integer that is less than or eq...
evol_instruct_66k
13,376
Write a Python function to compute a holistic assessment score for each product based on weighted ratings of its features. The function should take a list of dictionaries as input, where each dictionary contains `product_id`, `feature_id`, `rating`, and `weight`. The function should return a dictionary where the keys a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import defaultdict def compute_weighted_scores(data: List[Dict[str, int]]) -> Dict[int, float]: """ Compute a holistic assessment score for each product based on weighted ratings o...
evol_instruct_66k
13,380
Write a Python function to traverse a multi-layered dictionary, including nested arrays, and return the aggregate of all numeric values within. The structure also allows strings containing numerical values. The function should handle dictionaries, lists, strings, and integers. 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 Union, Dict, List def aggregate_numeric_values(data: Union[Dict, List, str, int]) -> int: """ Traverse a multi-layered dictionary, including nested arrays, and return the aggregate of all numeric values withi...
evol_instruct_66k
13,384
Write a Python function to generate a triad of cryptic sequences, each composed of a random fusion of alphanumeric characters intermingled with miscellaneous special characters. Each sequence should have a specified length. The function should return a list of these three sequences. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random import string def generate_cryptic_triad(length: int) -> List[str]: """ Generates a triad of cryptic sequences, each composed of a random fusion of alphanumeric characters intermingled ...
evol_instruct_66k
13,391
Write a Python function to combine two dictionaries into a single set, retaining only the unique keys from both dictionaries. The function should start with: ```python from typing import Dict, Set def combine_dicts_to_set(dict1: Dict[str, int], dict2: Dict[str, int]) -> Set[str]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Set def combine_dicts_to_set(dict1: Dict[str, int], dict2: Dict[str, int]) -> Set[str]: """ Combines the keys of two dictionaries into a single set of unique keys. Args: dict1 (Dict[str, in...
evol_instruct_66k
13,415
Write a Python function to compute the number of ones in a given binary string. The function should efficiently count the occurrences of the character '1' in the string. The code should start with: ```python def count_ones(binary_string: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_ones(binary_string: str) -> int: """ Counts the number of ones in a given binary string. Args: binary_string (str): The binary string in which to count the ones. Returns: int: The number of on...
evol_instruct_66k
13,424
Write a Python function to create a dictionary from a given tuple where each element of the tuple is used as a key, and its corresponding index in the tuple is used as the value. The function should handle tuples of any length and ensure that the dictionary is correctly constructed. The code should start with: ```pyth...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Dict def tuple_to_dict(t: Tuple) -> Dict: """ Converts a given tuple into a dictionary where each element of the tuple is a key, and its corresponding index in the tuple is the value. Args: ...
evol_instruct_66k
13,425
Write a Python function to filter out and return a list of fruit items from a given collection of grocery products. The function should take a list of grocery items and a set of fruit names as input and return a list containing only the items that are fruits. The code should start with: ```python from typing import Li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Set def filter_fruits(items: List[str], fruits: Set[str]) -> List[str]: """ Filters out and returns a list of fruit items from a given collection of grocery products. Args: items (List[str]...
evol_instruct_66k
13,431
Write a Python function to calculate the sum of all distinct numerical digits found in a given mixed alphanumeric string. The function should ignore any non-digit characters and only consider unique digits. The code should start with: ```python def sum_distinct_digits(input_str: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_distinct_digits(input_str: str) -> int: """ Calculate the sum of all distinct numerical digits found in the given mixed alphanumeric string. Args: input_str (str): The mixed alphanumeric string from which to...
evol_instruct_66k
13,447
Write a Python function to segment a given list of integers into two separate lists: one containing all even numbers and the other containing all odd numbers. The function should return a tuple containing the two lists. The code should start with: ```python from typing import List, Tuple def segment_even_odd(lst: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def segment_even_odd(lst: List[int]) -> Tuple[List[int], List[int]]: """ Segments a list of integers into two lists: one containing all even numbers and the other containing all odd numbers. ...
evol_instruct_66k
13,449
Write a Python function to calculate the product of a list of numbers, ensuring the input meets specific constraints. The function should take a list of numbers as input and return their product. The list must contain at least 2 but not more than 5 elements, and each element must be a number between 1 and 500. If these...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def multiply_numbers(lst: List[float]) -> float: """ Calculate the product of a list of numbers, ensuring the input meets specific constraints. Args: lst (List[float]): A list of numbers to ...
evol_instruct_66k
13,450
Write a Python function to replace all instances of a given character in a string with a different character. The function should take three parameters: the original string, the character to be replaced, and the replacement character. The function should return the modified string. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_character(original_string: str, character: str, replace_character: str) -> str: """ Replace all instances of a given character in a string with a different character. Args: original_string (str): The ori...
evol_instruct_66k
13,452
Write a Python function to generate the first 'n' components of the Fibonacci series. The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. The function should return a list containing the first 'n' Fibonacci numbers. 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 generate_fibonacci(n: int) -> List[int]: """ Generate the first 'n' components of the Fibonacci series. The Fibonacci series is a sequence of numbers where each number is the sum of the two prec...
evol_instruct_66k
13,454
Write a Python function to verify if a specified textual content is comprised of alphanumeric characters using a multi-step reasoning process. The function should check each character individually and ensure that it is either a letter or a digit. The function should return `True` if all characters in the text are alpha...
Here is the Python code to solve the given problem in the markdown block: ```python def is_alphanumeric_multi_step(text: str) -> bool: """ Verifies if the specified textual content is comprised of alphanumeric characters using a multi-step reasoning process. Args: text (str): The input text to be v...
evol_instruct_66k
13,455
Write a Python function to create a nested dictionary based on a given mapping of specified keys to respective subkeys and their corresponding values. The function should take a dictionary `mapped_keys_values` as input, where each key maps to another dictionary of subkeys and values. The function should return a nested...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def create_nested_dict(mapped_keys_values: Dict[str, Dict[str, int]]) -> Dict[str, Dict[str, int]]: """ Creates a nested dictionary based on a given mapping of specified keys to respective subkeys and th...
evol_instruct_66k
13,456
Write a Python function to simulate the behavior of a bash script that outputs the phrase "Hello World" and handles command-line argument passing and error handling. The function should accept a list of command-line arguments and return a string indicating the output or an error message. If the script is called with ex...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def simulate_bash_script(args: List[str]) -> str: """ Simulates the behavior of a bash script that outputs "Hello World" and handles command-line argument passing and error handling. Args: a...
evol_instruct_66k
13,467
Write a Python function to determine if the elements in a given numeric array form an ascending progression. An ascending progression means that each element in the array is strictly greater than the previous element. The function should return `True` if the array is in ascending order, and `False` otherwise. The code...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_ascending_progression(array: List[int]) -> bool: """ Determines if the elements in the given numeric array form an ascending progression. Args: array (List[int]): The numeric array to...
evol_instruct_66k
13,474
Write a Python function to find the minimum value in a given array of integers without using the built-in `min()` function. The function should iterate through the array and keep track of the smallest value encountered. The code should start with: ```python from typing import List def find_min_value(arr: List[int]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_min_value(arr: List[int]) -> int: """ Finds the minimum value in a given array of integers without using the built-in min() function. Args: arr (List[int]): The array of integers fr...
evol_instruct_66k
13,475
Write a Python function to magnify each element in a given list by threefold. If an element is a multiple of 5, it should be magnified by an additional twofold. The function should handle negative numbers and floats. The code should start with: ```python from typing import List def magnify_elements(lst: List[float]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def magnify_elements(lst: List[float]) -> List[float]: """ Magnifies each element in the given list by threefold. If an element is a multiple of 5, it is magnified by an additional twofold. Args...
evol_instruct_66k
13,486
Write a Python function to calculate the factorial of each element in a given list of non-negative integers. The function should return a new list containing the factorial of each corresponding element in the input list. The code should start with: ```python from typing import List def factorial_of_elements(arr: List[...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def factorial_of_elements(arr: List[int]) -> List[int]: """ Calculate the factorial of each element in the given list of non-negative integers. Args: arr (List[int]): A list of non-negativ...
evol_instruct_66k
13,491
Write a Python function to compare two integers and return the larger one. The function should handle negative numbers and equal values. The code should start with: ```python def compare_integers(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def compare_integers(a: int, b: int) -> int: """ Compares two integers and returns the larger one. If the integers are equal, returns either of them. Args: a (int): The first integer to compare. b (int): The...
evol_instruct_66k
13,500
Write a Python function to validate whether a given string is a valid IPv6 address according to standard IP address specifications. The function should use a regular expression to match the IPv6 address pattern. The code should start with: ```python import re def is_valid_ipv6(address: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def is_valid_ipv6(address: str) -> bool: """ Validate whether a given string is a valid IPv6 address according to standard IP address specifications. Args: address (str): The string to be validated as an ...
evol_instruct_66k
13,508
Write a Python function to compute the factorial of a given prime number and return the result. The function should validate if the input number is a prime number before computing its factorial. If the input is not a prime number, the function should return `None`. The code should start with: ```python import math de...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(number: int) -> bool: """ Helper function to check if a given number is a prime number. Args: number (int): The number to check for primality. Returns: bool: True if the number...
evol_instruct_66k
13,522
Write a Python function to compute the centroid of a given set of points in a 3D space. The points are provided as a list of tuples, where each tuple represents the coordinates (x, y, z) of a point. The function should return the centroid as a tuple of three floats representing the average x, y, and z coordinates. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def compute_centroid(points: List[Tuple[float, float, float]]) -> Tuple[float, float, float]: """ Compute the centroid of a given set of points in a 3D space. Args: points (List[Tuple...
evol_instruct_66k
13,524
Write a Python function to compute the factorial of a predetermined non-negative integer using a recursion-centric approach. The function should handle large numbers using a big number library or technique, and include a mechanism to detect and handle potential stack overflow due to deep recursion. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python import sys import math from functools import lru_cache def factorial(n: int) -> int: """ Compute the factorial of a non-negative integer using a recursion-centric approach. Args: n (int): The non-negative integer f...
evol_instruct_66k
13,530
Write a Python function to find the nested list with the greatest number of items within a given list of lists. The function should return the nested list that has the maximum length. The code should start with: ```python from typing import List def find_largest_list(list_of_lists: 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_largest_list(list_of_lists: List[List[int]]) -> List[int]: """ Finds the nested list with the greatest number of items within a given list of lists. Args: list_of_lists (List[List[i...
evol_instruct_66k
13,531
Write a Python function to find the longest common subsequence (LCS) of two given strings. The function should return the length of the LCS. The code should start with: ```python from typing import List def longest_common_subsequence(str1: str, str2: str) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def longest_common_subsequence(str1: str, str2: str) -> int: """ Calculate the length of the longest common subsequence (LCS) of two given strings. Args: str1 (str): The first string. ...
evol_instruct_66k
13,539
Write a Python function to reverse the order of command-line arguments and check for invalid inputs. A valid input contains only alphanumeric characters. If an invalid input is detected, the function should display an error message and return an empty list. The function should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def reverse_args_and_validate(args: List[str]) -> List[str]: """ Reverses the order of command-line arguments and checks for invalid inputs. A valid input contains only alphanumeric charact...
evol_instruct_66k
13,548
Write a Python function that continuously reduces a specified integer towards zero. With each decrement, the current integer should be added to a list. The function should return the list of integers after the process is complete. The function should start with: ```python from typing import List def reduce_to_zero(n: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reduce_to_zero(n: int) -> List[int]: """ Reduces the specified integer towards zero and collects each decremented value in a list. Args: n (int): The integer to be reduced towards zero. ...
evol_instruct_66k
13,564
Write a Python function to create a dictionary where the keys are integers from 1 to `n` (inclusive) and the values are the square roots of the corresponding keys. Use dictionary comprehension to achieve this. The function should start with: ```python from typing import Dict import math def generate_sqrt_dict(n: int) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import math def generate_sqrt_dict(n: int) -> Dict[int, float]: """ Generate a dictionary where the keys are integers from 1 to n (inclusive) and the values are their square roots. Args: n (...
evol_instruct_66k
13,613
Write a Python function to calculate the sum of elements in a given list efficiently. The function should be optimized for performance and should handle lists of varying sizes. The code should start with: ```python from typing import List def optimized_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 optimized_sum(arr: List[int]) -> int: """ Calculate the sum of elements in a given list efficiently. Args: arr (List[int]): The list of integers to sum. Returns: int: The ...
evol_instruct_66k
13,619
Write a Python function to split a given list into two sublists of equal size. If the length of the list is odd, the first sublist should contain the extra element. The function should return a tuple containing the two sublists. The code should start with: ```python from typing import List, Tuple def split_array(arr:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def split_array(arr: List[int]) -> Tuple[List[int], List[int]]: """ Splits a given list into two sublists of equal size. If the length of the list is odd, the first sublist contains the extra elem...
evol_instruct_66k
13,623
Write a Python function to replace all occurrences of the word "Hello" with "Goodbye" in a given string, ensuring that the replacement is case-insensitive and can handle multiple occurrences of the word "Hello". The function should return the modified string. The code should start with: ```python def replace_hello(tex...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_hello(text: str) -> str: """ Replace all occurrences of the word "Hello" with "Goodbye" in the given string, ensuring the replacement is case-insensitive. Args: text (str): The input string in which ...
evol_instruct_66k
13,639
Write a Python function to validate and differentiate between short form (e.g., `#abc`) and long form (e.g., `#aabbcc`) hexadecimal color codes. The function should also ensure that the short form codes accurately correlate to their long form counterparts (e.g., `#abc` -> `#aabbcc`). The function should return a tuple ...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_hex_color_code(code: str) -> tuple: """ Validate and differentiate between short form and long form hexadecimal color codes. Args: code (str): The hexadecimal color code to validate. Ret...
evol_instruct_66k
13,641
Write a Python function to calculate the sum of two provided integer values, ensuring attention to potential errors and validation of input types. The function should handle cases where the inputs are not integers and return an appropriate error message. The code should start with: ```python def sum_of_integers(a: str...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_integers(a: str, b: str) -> str: """ Calculate the sum of two provided integer values, ensuring input validation. Args: a (str): The first input value as a string. b (str): The second input value ...
evol_instruct_66k
13,645
Write a Python function to calculate the maximum sum of a contiguous subarray within a given array of integers. The function should handle both positive and negative numbers. The code should start with: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_subarray_sum(nums: List[int]) -> int: """ Calculate the maximum sum of a contiguous subarray within the given array. Args: nums (List[int]): The array of integers. Returns: ...
evol_instruct_66k
13,647
Write a Python function to determine the ordinal position of a specified character within a given alphanumeric string. The function should return the position as an integer, where the first character is at position 1. The code should start with: ```python def find_character_position(phrase: str, char: str) -> int: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def find_character_position(phrase: str, char: str) -> int: """ Determine the ordinal position of a specified character within a given alphanumeric string. Args: phrase (str): The alphanumeric string in which to sea...
evol_instruct_66k
13,651
Write a Python function to identify elements in a list that do not have a corresponding numerical pair. Each element in the list should be checked, and only those elements that appear exactly once should be returned in a new list. The code should start with: ```python from typing import List def find_single_elements(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_single_elements(lst: List[int]) -> List[int]: """ Identify and return elements in the list that do not have a corresponding numerical pair. Args: lst (List[int]): The list of intege...
evol_instruct_66k
13,655
Write a Python function to construct a square matrix from a given numeric array. The function should ensure that the length of the array is a perfect square before attempting to reshape it into a square matrix. If the length of the array is not a perfect square, the function should raise a `ValueError`. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def array_to_square_matrix(arr: List[int]) -> List[List[int]]: """ Constructs a square matrix from a given numeric array. Args: arr (List[int]): The numeric array to be reshaped ...
evol_instruct_66k
13,659
Write a Python function to calculate the sum of every fourth element in a given integer array. The function should start with: ```python from typing import List def sum_every_fourth(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sum_every_fourth(arr: List[int]) -> int: """ Calculate the sum of every fourth element in a given integer array. Args: arr (List[int]): The input array of integers. Returns: ...
evol_instruct_66k
13,673
Write a Python function to find the tuple with the maximum sum from a given list of tuples. Each tuple contains exactly two integers. The function should return the tuple with the highest sum. The code should start with: ```python from typing import List, Tuple def find_max_sum_tuple(tuples: List[Tuple[int, int]]) ->...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_max_sum_tuple(tuples: List[Tuple[int, int]]) -> Tuple[int, int]: """ Find the tuple with the maximum sum from a given list of tuples. Args: tuples (List[Tuple[int, int]]): A ...
evol_instruct_66k
13,676
Write a Python function to generate a right-angled triangle pattern using a specified character and height. The function should return the triangle as a list of strings, where each string represents a line of the triangle. The code should start with: ```python from typing import List def generate_triangle(character: s...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def generate_triangle(character: str, height: int) -> List[str]: """ Generate a right-angled triangle pattern using the specified character and height. Args: character (str): The character...
evol_instruct_66k
13,687
Write a Python function to create a dictionary that encapsulates the components present in two given arrays, `x` and `y`, and their corresponding frequency counts. The function should combine the two arrays and count the frequency of each element. The code should start with: ```python from typing import List, Dict fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict from collections import Counter def count_elements_frequency(x: List[int], y: List[int]) -> Dict[int, int]: """ Create a dictionary that encapsulates the components present in two given arrays and ...
evol_instruct_66k
13,698
Write a Python function to compute the cubes of all integers within specified ranges provided as a list of tuples. The function should validate the input to ensure it is correctly formatted as a list of tuples, where each tuple contains two integers representing the start and end of a range (inclusive). If the input is...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def compute_cubes_in_ranges(input_ranges: List[Tuple[int, int]]) -> List[List[int]]: """ Computes the cubes of all integers within specified ranges provided as a list of tuples. Args: ...
evol_instruct_66k
13,708
Write a Python function to count the frequency of each word in a given text and return the result as a dictionary where the keys are the words and the values are their respective frequencies. Additionally, create a set of unique words from the text. The function should start with: ```python from typing import Dict, Set...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Set def word_frequency(text: str) -> (Dict[str, int], Set[str]): """ Counts the frequency of each word in the given text and returns a dictionary of word frequencies along with a set of unique words...
evol_instruct_66k
13,711
Write a Python function to sort a given list of integers in ascending order using the built-in `sorted` function. The function should return the sorted list. Additionally, ensure that the function handles edge cases such as an empty list or a list with all identical elements. 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 sort_list(input_list: List[int]) -> List[int]: """ Sorts the given list of integers in ascending order. Args: input_list (List[int]): The list of integers to be sorted. Returns: ...
evol_instruct_66k
13,734
Write a Python function to reduce a given 3-dimensional NumPy array into a 2-dimensional matrix. The function should take a 3-dimensional NumPy array and a tuple representing the desired shape of the resulting 2-dimensional matrix. The function should ensure that the new shape is compatible with the original shape of t...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import Tuple def reduce_3d_to_2d(arr: np.ndarray, new_shape: Tuple[int, int]) -> np.ndarray: """ Reduces a 3-dimensional NumPy array to a 2-dimensional matrix with the specified shape. Args: ...
evol_instruct_66k
13,748
Write a Python function to compute the Least Common Multiple (LCM) of two given positive integers. The function should use the Euclidean algorithm to find the Greatest Common Divisor (GCD) and then use the relationship between GCD and LCM to compute the result. The code should start with: ```python def compute_lcm(a: ...
Here is the Python code to solve the given problem in the markdown block: ```python def compute_lcm(a: int, b: int) -> int: """ Compute the Least Common Multiple (LCM) of two positive integers. Args: a (int): The first positive integer. b (int): The second positive integer. Returns: ...
evol_instruct_66k
13,750
Write a Python function to calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The function should start with: ```python from typing import List def unique_paths(m: int, n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def unique_paths(m: int, n: int) -> int: """ Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid. Args: m (int): The number of row...
evol_instruct_66k
13,758
Write a Python function to validate an email address using regular expressions. The function should ensure that the email address has a valid format and a top-level domain (TLD) from a specific set (i.e., `.com`, `.net`, `.edu`). Additionally, the function should validate for the absence of consecutive special characte...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_email(email: str) -> bool: """ Validates an email address using regular expressions. Ensures the email has a valid format, a top-level domain (TLD) from a specific set (.com, .net, .edu), and no conse...
evol_instruct_66k
13,765
Write a Python function to simulate a sequence of sound effects with specified timing. The function should handle a dictionary of sound effects, where each key is a sound effect name and each value is a function that simulates the sound effect. The function should also accept a list of tuples, where each tuple contains...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple, Callable import time def play_sound_sequence(sound_effects: Dict[str, Callable[[], None]], sequence: List[Tuple[str, int]]) -> None: """ Simulates a sequence of sound effects with specified...
evol_instruct_66k
13,776
Write a Python function to append multiple elements to the end of a given numerical array. The function should accept a list of integers and a variable number of integer arguments to be added to the list. The function should return the modified list with the new elements appended. 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 append_multiple_elements(lista: List[int], *elements: int) -> List[int]: """ Appends multiple elements to the end of a given numerical array. Args: lista (List[int]): The list of integer...
evol_instruct_66k
13,778
Write a Python function to safely divide two numbers and handle potential exceptions. The function should return the result of the division if successful, and a custom error message if an exception occurs. The code should start with: ```python def safe_division(numerator: float, denominator: float) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def safe_division(numerator: float, denominator: float) -> str: """ Safely divides two numbers and returns the result or a custom error message if an exception occurs. Args: numerator (float): The numerator in the...
evol_instruct_66k
13,779
Write a Python function to remove superfluous whitespace characters from a given string while maintaining the integrity of the remaining characters. The function should ensure that only single spaces remain between words, and any leading or trailing whitespace should be removed. The code should start with: ```python de...
Here is the Python code to solve the given problem in the markdown block: : ```python def remove_superfluous_whitespace(input_string: str) -> str: """ Removes superfluous whitespace characters from the given string. This function splits the input string into words based on whitespace, then joins the wo...
evol_instruct_66k
13,789
Write a Python function to create a multi-dimensional array of size 10x10, initialize all elements to zero, and then increment each element by 1. The function should return the modified array. The code should avoid using any built-in or library methods for array manipulation or initialization. The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def initialize_and_increment_array() -> List[List[int]]: """ Initializes a 10x10 multi-dimensional array with all elements set to zero, then increments each element by 1, and returns the modified arr...
evol_instruct_66k
13,793
Write a Python function to generate the first `n` numbers in the Lucas sequence. The Lucas sequence is similar to the Fibonacci sequence but starts with the numbers 2 and 1. The `n`th number in the Lucas sequence is defined as the sum of the two preceding numbers. The function should return a list containing the first ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_lucas_sequence(n: int) -> List[int]: """ Generate the first n numbers in the Lucas sequence. The Lucas sequence is similar to the Fibonacci sequence but starts with the numbers 2 and 1....
evol_instruct_66k
13,802
Write a Python function to parse and isolate the first and last names from a given full name string. The function should handle names with multiple middle names or initials. The code should start with: ```python def parse_name(full_name: str) -> tuple: ```
Here is the Python code to solve the given problem in the markdown block: ```python def parse_name(full_name: str) -> tuple: """ Parses and isolates the first and last names from a given full name string. Args: full_name (str): The full name string to be parsed. Returns: tuple: A tuple...
evol_instruct_66k
13,806
Write a Python function to create and return a dictionary containing detailed data of an undergraduate student. The dictionary should include the student's legally recognized name, academic discipline within the domain of science and technology, and their current cumulative point average. The function should accept thr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def create_student_data(name: str, discipline: str, cgpa: float) -> Dict[str, str | float]: """ Create and return a dictionary containing detailed data of an undergraduate student. Args: nam...
evol_instruct_66k
13,820
Write a Python function to analyze a given text and produce an output that prints the position, letter of each vowel, and the number of times it appears in the text. The function should handle both uppercase and lowercase vowels and ensure that the output is formatted correctly. The code should start with: ```python d...
Here is the Python code to solve the given problem in the markdown block: ```python def analyze_vowels(text: str) -> None: """ Analyzes the given text and prints the position, letter of each vowel, and the number of times it appears in the text. Args: text (str): The text to analyze. Returns: ...
evol_instruct_66k
13,833
Write a Python function to perform a binary search on a sorted array to find the lowest index of a given element `x`. The array may contain duplicate elements, and the function should return the index of the first occurrence of `x`. If `x` is not found in the array, the function should return `-1`. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_first_occurrence(arr: List[int], x: int) -> int: """ Perform a binary search to find the lowest index of the element `x` in a sorted array. If `x` is not found, return -1. Args: ...
evol_instruct_66k
13,847
Write a Python function to determine if the sum of squares of all elements in a given list of integers lies within a specified inclusive range. The function should return `True` if the sum of squares is within the range, and `False` otherwise. The code should start with: ```python from typing import List def sum_of_s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_squares_in_range(l: List[int], min_val: int, max_val: int) -> bool: """ Determine if the sum of squares of all elements in the list l lies within the inclusive range of min_val and max_val. ...
evol_instruct_66k
13,849
Write a Python function to simulate the basic operations of a vehicle, including accelerating, braking, and honking. The function should maintain the current speed of the vehicle and allow the user to perform the specified operations. The code should start with: ```python def vehicle_operations(initial_speed: int, oper...
Here is the Python code to solve the given problem in the markdown block: ```python def vehicle_operations(initial_speed: int, operations: list) -> int: """ Simulate the basic operations of a vehicle, including accelerating, braking, and honking. Args: initial_speed (int): The initial speed of the ...
evol_instruct_66k
13,850
Write a Python function to transform a given string of Hypertext Markup Language (HTML) instructions, which are provided in uppercase letters, into its equivalent all-lowercase rendition. The function should handle any HTML string, regardless of its content or length. The code should start with: ```python def transfor...
Here is the Python code to solve the given problem in the markdown block: ```python def transform_html_to_lowercase(html_str: str) -> str: """ Transforms a given HTML string from uppercase to lowercase. Args: html_str (str): The HTML string to be transformed. Returns: str: The HTML str...
evol_instruct_66k
13,860
Write a Python function to analyze a thesaurus and perform the following tasks: 1. Count and display the number of synonyms each word in the thesaurus has. 2. List all synonyms for each word in the thesaurus. 3. Identify and display words that share at least one synonym. 4. For a specified word, find and display a 'syn...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Optional import collections def analyze_thesaurus(thesaurus: Dict[str, List[str]], start_word: str, end_word: str) -> None: """ Analyzes a thesaurus and performs the following tasks: 1. Counts...