source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
magic_evol_110k
104,184
Write a Python function to filter out all elements at even ordinal positions (1st, 3rd, 5th, etc.) from a given list of integers. The function should return a new list containing only the elements at odd ordinal positions (1st, 3rd, 5th, etc.). The code should start with: ```python from typing import List def filter_e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_even_ordinal_positions(arr: List[int]) -> List[int]: """ Filters out all elements at even ordinal positions (1st, 3rd, 5th, etc.) from the given list. Args: arr (List[int]): The l...
magic_evol_110k
104,188
Write a Python function to determine the English grade (A, B, C, D, F) based on a numerical score input. The function should use a switch-case construct to map the score to the corresponding grade. The code should start with: ```python def get_grade(score: int) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def get_grade(score: int) -> str: """ Determine the English grade (A, B, C, D, F) based on the numerical score input. Args: score (int): The numerical score to be converted to a grade. Returns: str: T...
magic_evol_110k
104,199
Write a Python function to sort a given list using the insertion sort algorithm. The function should modify the list in place and return the sorted list. The code should start with: ```python from typing import List def insertion_sort(unsorted_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 insertion_sort(unsorted_list: List[int]) -> List[int]: """ Sorts the given list using the insertion sort algorithm. Args: unsorted_list (List[int]): The list of integers to be sorted. ...
magic_evol_110k
104,207
Write a Python function that dynamically calculates the sum of a variable number of integer arguments. The function should accept any number of integer arguments and return their sum. Additionally, the function should handle cases where no arguments are provided by returning 0. 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 sum_of_integers(*args: int) -> int: """ Calculate the sum of a variable number of integer arguments. Args: *args (int): A variable number of integer arguments. Returns: int:...
magic_evol_110k
104,218
Write a Python function to concatenate an array of lexical items with a specified delimiter. The function should handle cases where the array is empty or the delimiter is an empty string. The code should start with: ```python from typing import List def concatenate_with_delimiter(arr: List[str], delimiter: str) -> st...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def concatenate_with_delimiter(arr: List[str], delimiter: str) -> str: """ Concatenates an array of lexical items with a specified delimiter. Args: arr (List[str]): The array of lexical item...
magic_evol_110k
104,243
Write a Python function to compute the greatest common divisor (GCD) of two integers using the Euclidean Algorithm. The function should be able to handle both positive and negative integers. The code should start with: ```python def gcd(a: int, b: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def gcd(a: int, b: int) -> int: """ Compute the greatest common divisor (GCD) of two integers using the Euclidean Algorithm. Args: a (int): The first integer. b (int): The second integer. Returns: ...
magic_evol_110k
104,244
Write a Python function to calculate the exact count of T-shirts sold given the total money accumulated and the price per T-shirt. The function should return the count as an integer. The code should start with: ```python def calculate_tshirts_sold(total_money: int, price_per_tshirt: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_tshirts_sold(total_money: int, price_per_tshirt: int) -> int: """ Calculate the exact count of T-shirts sold given the total money accumulated and the price per T-shirt. Args: total_money (int): The to...
magic_evol_110k
104,266
Write a Python function that removes all elements from one set that are present in another set and returns the distinct elements between the two sets. The function should also handle errors such as passing variables that are not sets, duplication of elements, or empty sets. Additionally, the function should ensure that...
Here is the Python code to solve the given problem in the markdown block: ```python def distinct_elements(setA, setB): """ Removes all elements from setA that are present in setB and returns the distinct elements between the two sets. Handles errors such as passing variables that are not sets, duplication o...
magic_evol_110k
104,283
Write a Python function to determine whether a given number is a prime number. The function should return `True` if the number is prime and `False` otherwise. The function should handle edge cases such as negative numbers, 0, and 1, which are not prime numbers. The function should also be optimized to reduce the number...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(n: int) -> bool: """ Determine whether a given number is a prime number. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False oth...
magic_evol_110k
104,289
Write a Python function to eliminate repetitive elements from a list containing integers, strings, and nested lists. The list can include up to two levels of nested lists. The function should maintain the order of the first occurrence of elements. The code should start with: ```python from typing import List, Union de...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def remove_repetitions(arr: List[Union[int, str, List]]) -> List[Union[int, str, List]]: """ Removes repetitive elements from a list containing integers, strings, and nested lists. The list ca...
magic_evol_110k
104,310
Write a Python function to construct a dictionary from the given input arrays of keys and values, and then sort the dictionary by the length of the values in descending order. The function should return the sorted dictionary. The code should start with: ```python from typing import List, Dict def sort_dict_by_value_le...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_dict_by_value_length(key_arr: List[int], value_arr: List[str]) -> Dict[int, str]: """ Constructs a dictionary from the given key and value arrays, and sorts the dictionary by the length of...
magic_evol_110k
104,323
Write a Python function to search and return the depth of a key-value pair in a potentially nested object. If the key-value pair is not found, the function should return -1. The object can contain integers or other nested objects. The function should start with: ```python from typing import Any, Dict def find_key_dept...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Any, Dict def find_key_depth(search_key: str, obj: Dict[str, Any], search_value: int) -> int: """ Search and return the depth of a key-value pair in a potentially nested object. Args: search_key ...
magic_evol_110k
104,329
Write a Python function to find the first negative number in each sub-array of a given multidimensional array. If no negative number is found in a sub-array, return `None` for that sub-array. The function should demonstrate the use of a "do-while" loop emulation pattern and compare it with a traditional "for" loop appr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union import numpy as np def find_first_negative(arr: Union[List[List[int]], np.ndarray]) -> List[Union[int, None]]: """ Find the first negative number in each sub-array of a given multidimensional arra...
magic_evol_110k
104,332
Write a Python function to sort a given list of integers in ascending order using the merge sort algorithm. The merge sort algorithm is a divide-and-conquer algorithm that recursively divides the list into halves until each sublist contains a single element, then merges these sublists back together in sorted order. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sort(arr: List[int]) -> List[int]: """ Sorts a list of integers in ascending order using the merge sort algorithm. Args: arr (List[int]): The list of integers to be sorted. Re...
magic_evol_110k
104,342
Write a Python function to generate a random sequence of 5 distinct alphanumeric characters, ensuring that it starts with a letter and ends with a numeral, and no character is repeated. The function should return the generated sequence as a string. The code should start with: ```python import random import string def...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_random_sequence() -> str: """ Generates a random sequence of 5 distinct alphanumeric characters, ensuring that it starts with a letter and ends with a numeral, and no character is repeat...
magic_evol_110k
104,344
Write a Python function to calculate the cumulative sum of all numeric values in a given tuple list, including nested tuples. Non-numeric values should be ignored. The function should be able to handle arbitrarily nested tuples. The code should start with: ```python from typing import Union def cumulative_sum_of_tupl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Union def cumulative_sum_of_tuples(tuples: Union[tuple, int, float]) -> Union[int, float]: """ Calculate the cumulative sum of all numeric values in a given tuple list, including nested tuples. Non-numeri...
magic_evol_110k
104,345
Write a Python function to check if any rotational arrangement of a given string `b` forms a continuous subsequence within another string `a`. The function should be case-insensitive and should ignore non-alphanumeric characters during the subsequence inspection. The code should start with: ```python def cycpattern_ch...
Here is the Python code to solve the given problem in the markdown block: ```python def cycpattern_check(a: str, b: str) -> bool: """ Check if any rotational arrangement of string `b` forms a continuous subsequence within string `a`. Args: a (str): The main string in which to search for the subsequ...
magic_evol_110k
104,350
Write a Python function to filter entries from a dictionary of string-integer pairs whose keys start with a provided string of more than one alphabetic character. The function should use dictionary comprehension to achieve this. The code should start with: ```python from typing import Dict def filter_dictionary_by_key...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def filter_dictionary_by_key_prefix(dictionary: Dict[str, int], prefix: str) -> Dict[str, int]: """ Filters entries from a dictionary of string-integer pairs whose keys start with a provided prefix. ...
magic_evol_110k
104,358
Write a Python function to merge two sorted lists of integers into a single sorted list containing distinct elements only. The function should return `None` if either of the input lists is `None` or empty. The solution must run within a time complexity of O(m + n), where m and n are the sizes of the input lists. The c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def merge_sorted_lists(list1: Optional[List[int]], list2: Optional[List[int]]) -> Optional[List[int]]: """ Merges two sorted lists of integers into a single sorted list containing distinct elem...
magic_evol_110k
104,361
Write a Python function to randomly select one element from a given array. The function should handle arrays of various lengths, including empty arrays. If the array is empty, the function should return `None`. The code should start with: ```python from typing import List, Optional import random def select_random_elem...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional import random def select_random_element(arr: List[int]) -> Optional[int]: """ Selects a random element from the given array. Args: arr (List[int]): The array from which to select a...
magic_evol_110k
104,366
Write a Python function to calculate the sum of all even-valued Fibonacci numbers that do not exceed a given limit. The Fibonacci sequence starts with 1 and 2, and each subsequent term is the sum of the previous two terms. The function should take an integer `limit` as input and return the sum of all even Fibonacci num...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_even_fibonacci(limit: int) -> int: """ Calculate the sum of all even-valued Fibonacci numbers that do not exceed the given limit. Args: limit (int): The upper bound for the Fibonacci numbers to consider. ...
magic_evol_110k
104,372
Write a Python function to determine the element(s) occurring with the highest frequency in a given list. If there are multiple elements with the same highest frequency, the function should return all such elements. The function should be efficient and handle edge cases such as an empty list or a list with all elements...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union from collections import Counter def most_frequent_elements(mylist: List[int]) -> Union[int, List[int]]: """ Determine the element(s) occurring with the highest frequency in a given list. Args...
magic_evol_110k
104,373
Write a Python function to construct a dictionary by correlating every element from two given lists. The function should ensure that the dictionary is created correctly even if the lengths of the two lists are not equal. If the lists have different lengths, the function should only map the elements that have correspond...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def correlate_lists(list_a: List[int], list_b: List[str]) -> Dict[int, str]: """ Constructs a dictionary by correlating every element from two given lists. Args: list_a (List[int]): Th...
magic_evol_110k
104,377
Write a Python function to calculate the factorial of a given number `n` using an iterative approach. The function should correctly handle the factorial calculation and return the result. The code should start with: ```python def factorial(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def factorial(n: int) -> int: """ Calculate the factorial of a given non-negative integer n. Args: n (int): The non-negative integer for which to calculate the factorial. Returns: int: The factorial of ...
magic_evol_110k
104,378
Write a Python function to perform a binary search on a sorted array to find the index of a specified element `x`. If the element is not found, return `-1`. The function should be efficient and leverage the properties of a sorted array to minimize the number of comparisons. The code should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(array: List[int], x: int) -> int: """ Perform a binary search on a sorted array to find the index of the specified element `x`. Args: array (List[int]): A sorted list of in...
magic_evol_110k
104,381
Write a Python function to find the minimum element in a rotated sorted array that may contain duplicates, without using any in-built functions or libraries. The function should only use loops and conditionals. The array is guaranteed to be sorted in ascending order before being rotated between 1 and `n` times, where `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_min_in_rotated_array(nums: List[int]) -> int: """ Find the minimum element in a rotated sorted array that may contain duplicates. Args: nums (List[int]): The rotated sorted array. ...
magic_evol_110k
104,390
Write a Python function to determine if a given string of brackets is correctly bracketed. The string contains only the characters '<' and '>'. The function should return `True` if every opening bracket '<' has a corresponding closing bracket '>', otherwise, it should return `False`. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python def is_correctly_bracketed(brackets: str) -> bool: """ Determines if the given string of brackets is correctly bracketed. Args: brackets (str): A string containing only the characters '<' and '>'. Returns: ...
magic_evol_110k
104,398
Write a Python function to find all prime numbers up to a given limit using the Sieve of Eratosthenes algorithm. The function should be optimized for performance and should return a list of prime numbers. The code should start with: ```python from typing import List def find_primes_up_to(limit: int) -> List[int]: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_primes_up_to(limit: int) -> List[int]: """ Find all prime numbers up to a given limit using the Sieve of Eratosthenes algorithm. Args: limit (int): The upper limit up to which to fi...
magic_evol_110k
104,403
Write a Python function to remove all spaces from a given string, including leading, trailing, and in-between spaces. The function should be optimized for strings with multiple spaces and should handle edge cases such as empty strings and strings with only spaces. The code should start with: ```python def remove_space...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_spaces(input_string: str) -> str: """ Removes all spaces from the given input string. Args: input_string (str): The string from which spaces are to be removed. Returns: str: The input string ...
magic_evol_110k
104,424
Write a Python function to generate the Fibonacci sequence up to a specified limit `n`. The function should return a list of Fibonacci numbers that are less than or equal to `n`. The code should start with: ```python from typing import List def generate_fibonacci_up_to(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_up_to(n: int) -> List[int]: """ Generate the Fibonacci sequence up to a specified limit `n`. Args: n (int): The upper limit for the Fibonacci sequence. Returns: ...
magic_evol_110k
104,444
Write a Python function to validate a file name based on a set of intricate rules. The function should return 'Yes' if the file name is valid and 'No' otherwise. The rules for a valid file name are as follows: 1. The name must feature alphanumeric characters, with at least one uppercase and one lowercase letter. 2. A m...
Here is the Python code to solve the given problem in the markdown block: ```python import re def file_name_check(file_name: str) -> str: """ Validates a file name based on a set of intricate rules. Args: file_name (str): The file name to be validated. Returns: str: 'Yes' if the file ...
magic_evol_110k
104,447
Write a Python function to determine if two given integers `n` and `m` are powers of four and two, respectively. The function should return `true` if `n` is a power of four and `m` is a power of two; otherwise, it should return `false`. The function should not use loops or recursion. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python def is_power_of_four_and_two(n: int, m: int) -> bool: """ Determine if the given integers `n` and `m` are powers of four and two, respectively. Args: n (int): The first integer to check if it is a power of four. ...
magic_evol_110k
104,477
Write a Python function to sort a given numerical dataset in ascending order using the Bubble Sort algorithm. The function should be able to handle real numbers and negative values. Additionally, identify and correct the errors in the provided erroneous code snippet. The function should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort(arr: List[float]) -> List[float]: """ Sorts a given numerical dataset in ascending order using the Bubble Sort algorithm. Args: arr (List[float]): The numerical dataset to be...
magic_evol_110k
104,486
Write a Python function to remove recurring numerals from a given list of integers. The function should return a new list containing only the unique elements from the original list, maintaining the order of their first appearance. The code should start with: ```python from typing import List def remove_recurring_numb...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_recurring_numbers(arr: List[int]) -> List[int]: """ Removes recurring numerals from a given list of integers and returns a new list containing only the unique elements, maintaining the ord...
magic_evol_110k
104,487
Write a Python function to sort an array of numerical values in ascending order using a custom sorting algorithm. The function should be efficient and handle a large number of elements. The code should start with: ```python from typing import List def custom_sort(array: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_sort(array: List[int]) -> List[int]: """ Sorts an array of numerical values in ascending order using a custom selection sort algorithm. Args: array (List[int]): The array of numer...
magic_evol_110k
104,488
Write a Python function to update the email address of a user in a predefined JSON data format using the HTTP PUT method. The function should take the user's ID, the new email address, and the URL of the API endpoint as inputs. The function should return the response text from the server. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python import requests import json def update_user_email(user_id: str, new_email: str, url: str) -> str: """ Updates the email address of a user using an HTTP PUT request. Args: user_id (str): The ID of the user whose ema...
magic_evol_110k
104,505
Create a Python function to generate a Dockerfile for an Nginx server that is configured with load balancing between two Node.js applications and enables SSL with a self-signed certificate. The function should follow the given requirements and generate a Dockerfile as a string. The code should start with: ```python de...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_nginx_dockerfile() -> str: """ Generates a Dockerfile for an Nginx server configured with load balancing between two Node.js applications and SSL with a self-signed certificate. Returns: str: The genera...
magic_evol_110k
104,511
Write a Python function to implement the Quick Sort algorithm that not only sorts the given array of integers but also efficiently handles duplicate integers. The function should be able to handle larger arrays efficiently. The code should start with: ```python from typing import List def quicksort_with_duplicates(arr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def quicksort_with_duplicates(arr: List[int]) -> List[int]: """ Sorts the given array of integers using the Quick Sort algorithm, efficiently handling duplicate integers. Args: arr (List[int...
magic_evol_110k
104,525
Write a Python function to reverse a given string without using any built-in functions, handling special characters and white spaces correctly. The function should be able to handle any string input, including those with special characters and spaces. The code should start with: ```python def reverse_string(s: str) -> ...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_string(s: str) -> str: """ Reverses a given string without using any built-in functions. Args: s (str): The input string to be reversed. Returns: str: The reversed string. """ # Init...
magic_evol_110k
104,526
Write a Python function to find the longest consecutive sequence in a given list of numbers and return the sequence along with its start and end indices. The function should efficiently handle large datasets, considering both time and space complexity. The code should start with: ```python from typing import List, Tup...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def longest_consecutive_sequence(lst: List[int]) -> Tuple[int, int, List[int]]: """ Finds the longest consecutive sequence in a given list of numbers and returns the sequence along with its start ...
magic_evol_110k
104,527
Write a Python function to compute the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm. The function should validate the input to ensure both inputs are positive integers and handle exceptions gracefully. The code should start with: ```python def calculate_gcd(num1: int, num2: int) ...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_gcd(num1: int, num2: int) -> int: """ Computes the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm. Args: num1 (int): The first positive integer. num2 (int)...
magic_evol_110k
104,528
Write a Python function to reverse the nodes in pairs of a singly linked list. If the number of nodes is odd, the last node should remain in its original position. The function should operate in `O(n)` time complexity and `O(1)` space complexity. The code should start with: ```python class ListNode: def __init__(s...
Here is the Python code to solve the given problem in the markdown block: ```python class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_linked_list_in_pairs(head: ListNode) -> ListNode: """ Reverses the nodes in pairs of a singly linked list. ...
magic_evol_110k
104,547
Write a Python function to rotate a given list by a specified number of items to the right direction. The rotation should be performed in place (i.e., without using additional memory for a new list). Additionally, the function should handle negative rotation values, which indicate rotation to the left. The function sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def rotate_list(lst: List[int], n: int) -> List[int]: """ Rotates a given list by a specified number of items to the right direction. The rotation is performed in place without using additional memor...
magic_evol_110k
104,553
Write a Python function to validate whether a given string is a valid United States telephone number. The function should adhere to the following rules: 1. The number can optionally start with "+1" followed by a space. 2. The first three digits can be optionally enclosed in parentheses. 3. The first three digits, the n...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_phone_number(number: str) -> bool: """ Validates whether the given string is a valid United States telephone number. The number can optionally start with "+1" followed by a space. The first three dig...
magic_evol_110k
104,562
Write a Python function to translocate all occurrences of the integer zero to the end of a given list while maintaining the sequential order of the non-zero elements. The function should also handle nested lists by shifting all occurrences of zero in these nested lists to the end of their respective lists. The function...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def move_zeros_to_end(lst: List[Any]) -> List[Any]: """ Translocates all occurrences of the integer zero to the end of the given list while maintaining the sequential order of the non-zero elements....
magic_evol_110k
104,569
Write a Python function to find and return the highest even integer from a given list of numbers. If the list contains no even numbers, the function should return `None`. The function should be efficient and handle edge cases such as an empty list or a list with no even numbers. 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, Optional def find_highest_even(numbers: List[int]) -> Optional[int]: """ Finds and returns the highest even integer from a given list of numbers. If the list contains no even numbers, returns None. ...
magic_evol_110k
104,602
Write a Python function to traverse a 2D array and return a list of all elements in the array in a specific order. The function should start with: ```python from typing import List def traverse_2d_array(arr: 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 traverse_2d_array(arr: List[List[int]]) -> List[int]: """ Traverse a 2D array and return a list of all elements in the order they are accessed. Args: arr (List[List[int]]): A 2D array of...
magic_evol_110k
104,620
Write a Python function to sort the keys of a given dictionary in reverse alphabetical order while maintaining the integrity of the original dictionary. The function should return a new dictionary with the sorted keys and their corresponding values. The code should start with: ```python from typing import Dict def so...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_dict_keys_reverse_alphabetical(prog_dict: Dict[str, int]) -> Dict[str, int]: """ Sorts the keys of a given dictionary in reverse alphabetical order while maintaining the integrity of the origina...
magic_evol_110k
104,621
Write a Python function to generate a list of cubes of the first n natural numbers. The function should take an integer `n` as input and return a list of cubes of numbers from 1 to `n`. The function should use a while loop to compute the cubes. The code should start with: ```python from typing import List def generat...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_cubes(n: int) -> List[int]: """ Generate a list of cubes of the first n natural numbers using a while loop. Args: n (int): The number of natural numbers for which to generate cu...
magic_evol_110k
104,632
Write a Python function to transform yes/no inquiries into binary input. The function should handle multiple-step reasoning, such as converting user responses to a standardized format (e.g., "yes" to 1 and "no" to 0), and should be case-insensitive. The function should also handle variations in user responses (e.g., "y...
Here is the Python code to solve the given problem in the markdown block: ```python def yes_no_to_binary(answer: str) -> int: """ Transforms a yes/no inquiry into a binary input. Args: answer (str): The user's response to a yes/no question. Returns: int: The binary representation of th...
magic_evol_110k
104,634
Write a Python function to determine if a given year is a leap year. The function should take an integer representing a year and return a boolean indicating whether the year is a leap year. The function should follow the rules for determining leap years: 1. A year is a leap year if it is divisible by 4. 2. However, if ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_leap_year(year: int) -> bool: """ Determine if a given year is a leap year. Args: year (int): The year to check. Returns: bool: True if the year is a leap year, False otherwise. """ # Che...
magic_evol_110k
104,638
Write a Python function to replace all space characters in a given string with hyphen characters. The function should handle strings of varying lengths, including empty strings, and should return the modified string. The code should start with: ```python def replace_spaces_with_hyphens(sentence: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def replace_spaces_with_hyphens(sentence: str) -> str: """ Replace all space characters in the given string with hyphen characters. Args: sentence (str): The input string in which spaces need to be replaced. Re...
magic_evol_110k
104,639
Write a Python function to handle a simple arithmetic operation using AWS Lambda. The function should take two numbers as input and return their sum. The function should be designed to handle potential errors gracefully, such as missing or invalid input data. The code should start with: ```python def lambda_handler(eve...
Here is the Python code to solve the given problem in the markdown block: ```python def lambda_handler(event, context): """ AWS Lambda function to handle a simple arithmetic operation. This function takes two numbers as input and returns their sum. It also handles potential errors such as missing or invali...
magic_evol_110k
104,655
Write a Python function to count the number of words in a given sentence and initialize a new dictionary to display each unique word along with its number of occurrences in the sentence. The solution should be case-insensitive, meaning "Hello" and "hello" should be considered the same word. Additionally, handle possibl...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple def count_words_in_sentence(sentence: str) -> Tuple[Dict[str, int], int]: """ Counts the number of words in a given sentence and initializes a dictionary to display each unique word along with its...
magic_evol_110k
104,698
Write a Python function to sort a nested JSON dataset based on two criteria: the primary sorting parameter is 'public_id' in descending order, and the secondary sorting parameter is 'name' in ascending order. The function should group entries with the same 'name' together and sort the associated 'public_id's in descend...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_nested_json(data: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a nested JSON dataset based on two criteria: 1. 'public_id' in descending order. 2. 'name' in ascending o...
magic_evol_110k
104,714
Write a Python function to check if a given integer value is divisible by both 3 and 5, as well as divisible by 7, without using the modulus operator. The function should return a boolean value indicating whether the conditions are met. The code should start with: ```python def is_divisible_by_3_5_7(value: int) -> boo...
Here is the Python code to solve the given problem in the markdown block: ```python def is_divisible_by_3_5_7(value: int) -> bool: """ Check if a given integer value is divisible by 3, 5, and 7 without using the modulus operator. Args: value (int): The integer value to check for divisibility. ...
magic_evol_110k
104,717
Write a Python function to replace all numerical digits in a given string with a specific character. The function should be able to handle any string input and replace all occurrences of digits (0-9) with the specified character. The code should start with: ```python def replace_digits_with_char(input_string: str, repl...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_digits_with_char(input_string: str, replacement_char: str) -> str: """ Replace all numerical digits in the given input string with the specified replacement character. Args: input_string (str): The input...
magic_evol_110k
104,718
Write a Python function to calculate the dot product of two 1D arrays, where the first array is the result of multiplying a 1D array by a scalar, and the second array is the result of applying a map function to a 1D array. The function should handle scenarios where the arrays are not of the same length by filling in th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Callable import itertools def calculate_dot_product(array1: List[int], scalar: int, array2: List[int], map_func: Callable[[int], int]) -> int: """ Calculate the dot product of two 1D arrays, where the f...
magic_evol_110k
104,721
Write a Python function to generate a new list where each element is the product of the corresponding elements from two given lists (`list_one` and `list_two`) and the index position in `list_one`. If `list_two` does not have an element at the corresponding index, use `2` as the default multiplier. The function should ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_product_list(list_one: List[int], list_two: List[int]) -> List[int]: """ Generates a new list where each element is the product of the corresponding elements from two lists and the index pos...
magic_evol_110k
104,724
Write a Python function to determine if a given integer is a perfect square without using the built-in `math.sqrt` function. The function should efficiently check if the integer can be expressed as the square of another integer. The code should start with: ```python def is_perfect_square(n: int) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def is_perfect_square(n: int) -> bool: """ Determines if a given integer is a perfect square without using the math.sqrt function. Args: n (int): The integer to check if it is a perfect square. Returns: ...
magic_evol_110k
104,725
Write a Python function to perform a mathematical operation on a range of numbers and convert the result to a specified base. The function should accept four parameters: `n` (the starting number of the range), `m` (the ending number of the range), `base` (the base to convert the result to), and `operation` (the mathema...
Here is the Python code to solve the given problem in the markdown block: ```python def bespoke_base_mathematics(n: int, m: int, base: int, operation: str) -> str: """ Perform a mathematical operation on a range of numbers and convert the result to a specified base. Args: n (int): The starting numb...
magic_evol_110k
104,729
Write a Python function to compute the Least Common Multiple (LCM) of three distinct non-negative and non-zero integers efficiently. The function should consider computational time complexity, code readability, and efficiency. The code should start with: ```python import math def compute_lcm_of_three(a: int, b: int, c...
Here is the Python code to solve the given problem in the markdown block: ```python import math def compute_lcm_of_three(a: int, b: int, c: int) -> int: """ Compute the Least Common Multiple (LCM) of three distinct non-negative and non-zero integers. Args: a (int): The first non-negative and non-z...
magic_evol_110k
104,741
Write a Python function to determine if a given string is entirely numerical, considering all numeric forms such as integers, decimals, negative numbers, and numbers in scientific notation. The function should handle large strings efficiently and gracefully handle exceptions. The code should start with: ```python def ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_numeric(string: str) -> bool: """ Determines if a given string is entirely numerical, considering all numeric forms such as integers, decimals, negative numbers, and numbers in scientific notation. Args: stri...
magic_evol_110k
104,768
Write a Python function to find the maximum value from a list of floating-point numbers, considering both the integer and decimal parts. The function should handle numbers with a wide range of decimal places efficiently. The code should start with: ```python from typing import List def find_max_decimal(decimal_list: L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_max_decimal(decimal_list: List[float]) -> float: """ Finds the maximum value from a list of floating-point numbers. Args: decimal_list (List[float]): A list of floating-point number...
magic_evol_110k
104,776
Write a Python function to find all rows in a given list of dictionaries where at least one of the specified columns (minimum five) contains a `None` value. The function should return a list of dictionaries representing these rows. The code should start with: ```python from typing import List, Dict def find_rows_with...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def find_rows_with_nulls(data: List[Dict[str, any]], columns: List[str]) -> List[Dict[str, any]]: """ Find all rows in the given list of dictionaries where at least one of the specified columns con...
magic_evol_110k
104,786
Write a Python function to identify the lone integer in a given non-empty list of integers, where every integer appears twice except for one unique integer. The function should return the unique integer and its index in the list. If no unique integer is found, the function should raise a `ValueError` with an appropriat...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_lone_integer(nums: List[int]) -> Tuple[int, int]: """ Identifies the lone integer in a list where every other integer appears twice. Args: nums (List[int]): A non-empty list ...
magic_evol_110k
104,796
Write a Python function to convert an array of binary string representations into an array of octal integer equivalents. Each binary string in the input array should be converted to its corresponding octal integer. The function should handle any valid binary string input. 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 def binary_to_octal_conversion(binary_arr: List[str]) -> List[int]: """ Converts an array of binary string representations into an array of octal integer equivalents. Args: binary_arr (List[...
magic_evol_110k
104,807
Write a Python function to find the smallest non-negative value in a given list of real numbers. The function should return `None` if there are no non-negative values in the list. The code should start with: ```python from typing import List, Optional def find_smallest_non_negative(numbers: List[float]) -> Optional[f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_smallest_non_negative(numbers: List[float]) -> Optional[float]: """ Find the smallest non-negative value in a given list of real numbers. Args: numbers (List[float]): A li...
magic_evol_110k
104,808
Write a Python function to remove consecutive duplicate characters from a given string. The function should iterate through the string and construct a new string that contains only the first occurrence of each consecutive duplicate character. The code should start with: ```python def remove_consecutive_duplicates(strin...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_consecutive_duplicates(string: str) -> str: """ Removes consecutive duplicate characters from the given string. Args: string (str): The input string from which consecutive duplicates are to be removed. ...
magic_evol_110k
104,844
Write a Python function to create a 3D array of size 4x4x4 filled with random integers between -100 and 100, and then find the maximum value in the array along with its location (indices). The function should return the maximum value and its location as a tuple. The code should start with: ```python import numpy as np...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def find_max_in_3d_array() -> tuple: """ Creates a 3D array of size 4x4x4 filled with random integers between -100 and 100, and finds the maximum value in the array along with its location (indices). ...
magic_evol_110k
104,846
Write a Python function to search for a given number in a 2D array where each sub-array can have varying lengths. If the number is found, return the indices of the number in the 2D array as a tuple. If the number is not found, return -1. The code should start with: ```python from typing import List, Tuple, Union def ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def search_2D_array(arr: List[List[int]], num: int) -> Union[Tuple[int, int], int]: """ Searches for a given number in a 2D array where each sub-array can have varying lengths. Args: ...
magic_evol_110k
104,848
Write a Python function to remove successive duplicate elements from a given list. The function should iterate through the list and ensure that only the first occurrence of each successive duplicate is retained. The function should start with: ```python from typing import List def remove_successive_duplicates(input_li...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_successive_duplicates(input_list: List[str]) -> List[str]: """ Removes successive duplicate elements from the given list. Args: input_list (List[str]): The list from which success...
magic_evol_110k
104,850
Write a Python function to sort an array of positive integers based on the length of their binary representation in ascending order. If multiple integers have the same binary length, sort them by their numerical (decimal) value. The function should start with: ```python from typing import List def sort_by_binary_len(a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_by_binary_len(arr: List[int]) -> List[int]: """ Sorts an array of positive integers based on the length of their binary representation in ascending order. If multiple integers have the same ...
magic_evol_110k
104,869
Write a Python function to count the number of even numbers in a given list of integers. The function should be efficient and handle both positive and negative integers. The code should start with: ```python from typing import List def count_even_numbers(num_list: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_even_numbers(num_list: List[int]) -> int: """ Counts the number of even numbers in a given list of integers. Args: num_list (List[int]): A list of integers. Returns: i...
magic_evol_110k
104,874
Write a Python function to calculate the cumulative product of elements in a list within a user-defined range. The function should accept a list of integers and two indices, `n` and `m`, where `n` is the starting index (inclusive) and `m` is the ending index (exclusive). The function should return the cumulative produc...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cumulative_product(arr: List[int], n: int, m: int) -> int: """ Calculate the cumulative product of elements in a list within a user-defined range. Args: arr (List[int]): The list of inte...
magic_evol_110k
104,876
Write a Python function to sort a list of numeric integers using the bubble sort technique. The function should also perform rigorous error checking to handle potential erroneous inputs. The function should raise a `ValueError` if the input is not a list or if the list contains elements that are not integers. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort(num_list: List[int]) -> List[int]: """ Sorts a list of numeric integers using the bubble sort technique. Args: num_list (List[int]): The list of integers to be sorted. R...
magic_evol_110k
104,878
Write a Python function to simulate a multithreaded environment where multiple threads read characters from standard input, store them in a thread-safe queue, and output them in the sequence they were read. The function should ensure that the characters are processed in the order they are read, even when multiple threa...
Here is the Python code to solve the given problem in the markdown block: ```python from queue import Queue from threading import Thread, Condition import sys def multithreaded_character_reader(num_threads: int): """ Simulates a multithreaded environment where multiple threads read characters from stdin, s...
magic_evol_110k
104,884
Write a Python function to solve a linear equation of the form `x + a = b` and determine the correct value for `x` from a given set of numerical options. The function should subtract `a` from both sides of the equation to isolate `x` and then compare the result with the provided options to find the correct one. The co...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def solve_linear_equation(a: float, b: float, options: List[float]) -> float: """ Solves the linear equation x + a = b and determines the correct value for x from a given set of numerical options. A...
magic_evol_110k
104,885
Write a Python function to generate, sort, and print alternating prime numbers from 3 to 1000. The function should also determine and display the total count of these prime numbers, their cumulative sum, and the highest and lowest prime numbers in the generated list. The function should use the Sieve of Eratosthenes al...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_and_display_alternating_primes(): """ Generates, sorts, and prints alternating prime numbers from 3 to 1000. Also displays the total count of these prime numbers, their cumulative sum, and the highest and lo...
magic_evol_110k
104,890
Write a Python function to divide elements of a given array into Fibonacci and non-Fibonacci numbers. The function should return two lists: one containing all Fibonacci numbers from the input array and the other containing all non-Fibonacci numbers. The function should start with: ```python from typing import List, Tup...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import math def is_fibonacci(n: int) -> bool: """ Check if a given number is a Fibonacci number. Args: n (int): The number to check. Returns: bool: True if the number is ...
magic_evol_110k
104,894
Write a Python function to reverse a given list of whole numbers without using any built-in Python functions or slicing. The function should iterate through the list and construct a new list in reverse order. The code should start with: ```python from typing import List def reverse_list(input_list: List[int]) -> List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(input_list: List[int]) -> List[int]: """ Reverses a given list of whole numbers without using built-in functions or slicing. Args: input_list (List[int]): The list of whole ...
magic_evol_110k
104,900
Write a Python function that counts the total number of characters in a given string and also calculates the frequency of each character in that string. The function should return the total count of characters and a dictionary where each key-value pair consists of a single character and its corresponding frequency. Th...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import Counter def character_analysis(submitted_string: str) -> (int, dict): """ Analyzes the characters in a given string by counting the total number of characters and calculating the frequency of each ch...
magic_evol_110k
104,906
Write a Python function to calculate and return a list of cubes of sequential integers starting from a given integer `start` and ending at a given integer `end` (inclusive). The function should handle cases where `start` is greater than `end` by returning an empty list. The function should also handle negative integers...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_cubes(start: int, end: int) -> List[int]: """ Calculate and return a list of cubes of sequential integers starting from `start` and ending at `end` (inclusive). Args: start (in...
magic_evol_110k
104,931
Write a Python function to find both the mode(s) and the median of a given list of numbers. The mode is the number(s) that appear most frequently in the list, and the median is the middle number when the list is sorted in ascending order. If the list has more than one mode, return all of them in a list. The function sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple from collections import Counter def find_mode_and_median(numbers: List[int]) -> Tuple[List[int], float]: """ Find both the mode(s) and the median of a given list of numbers. Args: num...
magic_evol_110k
104,934
Write a Python function to calculate the mean of a provided list of numbers. The function should handle edge cases such as an empty list by returning `None` instead of raising an error. The code should start with: ```python from typing import List, Optional def calculate_mean(numbers: List[float]) -> Optional[float]: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def calculate_mean(numbers: List[float]) -> Optional[float]: """ Calculate the mean of a provided list of numbers. Args: numbers (List[float]): A list of numbers for which to calcu...
magic_evol_110k
104,937
Write a Python function to identify if a number is prime and to construct a list of all prime numbers up to a specified non-negative number. The function should store the prime numbers in a hidden data structure for better efficiency in repetitive calls with the same or smaller numbers. The code should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python import math def is_prime(n: int) -> bool: """ Determine 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
104,940
Write a Python function to calculate the cumulative total of all elements within a list, considering both positive and negative numbers, and including decimal values up to 2 decimal places. The function should return a list of cumulative totals for each element in the input list. 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 cumulative_total(lst: List[float]) -> List[float]: """ Calculate the cumulative total of all elements in the input list, considering both positive and negative numbers, and including decimal valu...
magic_evol_110k
104,945
Write a Python function to determine if the elements of a given list progressively increase or decrease, taking into account the given 'strict' parameter and handling non-integer or non-floating-point elements. If 'strict' is True, successive elements must not be the same; conversely, repetitive elements are acceptable...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union def advanced_monotonic(l: List[Union[int, float, str]], strict: bool = False) -> bool: """ Determine if the elements of the list progressively increase or decrease, handling non-numerical elem...
magic_evol_110k
104,950
Write a Python function to simulate a simple data processing topology using a builder pattern. The topology consists of three components: a data source spout, a data processing bolt, and a data store bolt. The function should allow setting up these components with specified parallelism (number of instances) and define ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Callable, Dict, List, Tuple class TopologyBuilder: def __init__(self): self.components: Dict[str, Tuple[Callable, int]] = {} self.connections: Dict[str, List[str]] = {} def set_spout(self, na...
magic_evol_110k
104,965
Write a Python function to convert a JSON object to a Python dictionary. The function should handle nested JSON objects and arrays. The JSON object is represented as a string. The code should start with: ```python import json from typing import Any, Dict def json_to_dict(json_str: str) -> Dict[str, Any]: ```
Here is the Python code to solve the given problem in the markdown block: ```python import json from typing import Any, Dict def json_to_dict(json_str: str) -> Dict[str, Any]: """ Converts a JSON string to a Python dictionary. Args: json_str (str): The JSON string to be converted. Returns: ...
magic_evol_110k
104,972
Write a Python function to generate a list of `n` elements, where the element at position `i` signifies the factorial of `i` for even `i` and the sum of numbers from 1 up to `i` for odd `i`. The function should start with `i` equating to 1. The factorial of `i` denotes the multiplication of integers from 1 to `i` (1 * ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_list(n: int) -> List[int]: """ Generate a list of n elements where the element at position i signifies: - The factorial of i for even i - The sum of numbers from 1 up to i for odd i ...
magic_evol_110k
104,976
Write a Python function to find the indices of the `k` weakest rows in a given binary matrix `mat`. A row `i` is considered weaker than a row `j` if the number of soldiers (represented by `1`s) in row `i` is less than the number of soldiers in row `j`, or if both rows have the same number of soldiers and `i < j`. The f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def k_weakest_rows(mat: List[List[int]], k: int) -> List[int]: """ Find the indices of the k weakest rows in the given binary matrix. Args: mat (List[List[int]]): The binary matrix where 1's...
magic_evol_110k
104,982
Write a Python function to remove duplicate elements from a given list of numbers while preserving the order of the first occurrence of each element. The function should take a list of integers as input and return a new list with all duplicate elements removed. 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 remove_duplicates(numbers: List[int]) -> List[int]: """ Removes duplicate elements from a list while preserving the order of the first occurrence of each element. Args: numbers (List[int...
magic_evol_110k
104,983
Write a Python function to sort a binary matrix represented as a list of integers in ascending order. The binary matrix contains only 0s and 1s. The function should efficiently sort the list in place without using the built-in `sort` method. The code should start with: ```python from typing import List def sort_binar...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_binary_matrix(B: List[int]) -> None: """ Sorts a binary matrix (a list of integers containing only 0s and 1s) in ascending order in place. Args: B (List[int]): The binary matrix to ...
magic_evol_110k
104,988
Write a Python function to concatenate two given strings with a specified delimiter and return the resulting string. The function should handle cases where the delimiter is an empty string. The code should start with: ```python def concatenate_strings_with_delimiter(string1: str, string2: str, delimiter: str) -> str: ...
Here is the Python code to solve the given problem in the markdown block: ```python def concatenate_strings_with_delimiter(string1: str, string2: str, delimiter: str) -> str: """ Concatenates two strings with a specified delimiter and returns the resulting string. Args: string1 (str): The first str...
magic_evol_110k
104,996
Write a Python function to combine two lists without any duplicate items. The function should take two lists as input and return a new list that contains all unique items from both lists, maintaining the order of first occurrence. The code should start with: ```python from typing import List def combine_lists_without...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def combine_lists_without_duplicates(list1: List[str], list2: List[str]) -> List[str]: """ Combines two lists without any duplicate items, maintaining the order of first occurrence. Args: li...
magic_evol_110k
105,011
Write a Python function to reverse the digits of a given numerical value and convert them into an array of individual digits in the reversed order. The function should handle both positive and negative numbers. The code should start with: ```python from typing import List def reverse_digits_to_array(n: int) -> List[in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_digits_to_array(n: int) -> List[int]: """ Reverses the digits of a given numerical value and converts them into an array of individual digits in the reversed order. Args: n (int)...
magic_evol_110k
105,015
Write a Python function to determine if a given array of strings is in alphabetical order. Additionally, implement a function to randomly shuffle the elements of the array. The code should start with: ```python from typing import List import random def is_alphabetical(array: List[str]) -> bool: """ Determine i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def is_alphabetical(array: List[str]) -> bool: """ Determine if the given array of strings is in alphabetical order. Args: array (List[str]): The array of strings to check. ...
magic_evol_110k
105,032
Write a Python function to identify and retrieve the index and value of the element in a given tuple that matches a specified denomination. If the denomination is not found in the tuple, the function should return `None` for both the index and value. The function should handle the case where the denomination is not pre...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Optional def find_denomination(fruit_tuple: Tuple[str, ...], denomination: str) -> Tuple[Optional[int], Optional[str]]: """ Identify and retrieve the index and value of the element in the given tuple t...
magic_evol_110k
105,034
Write a Python function to find the common elements between two sets, `groupA` and `groupB`. The function should return a set containing the elements that are present in both sets. The code should start with: ```python def find_common_elements(groupA: set, groupB: set) -> set: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_common_elements(groupA: set, groupB: set) -> set: """ Find the common elements between two sets. Args: groupA (set): The first set. groupB (set): The second set. Returns: set: A set con...