Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: Given a string s, count the number of uppercase vowels in even indices.

For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
Response:
```python
def count_upper(s):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.

Examples
>>> closest_integer("10")
10
>>> closest_integer("15.3")
15

Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 15 and closest_integer("-14.5") should return -15.
Response:
```python
def closest_integer(value):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
    - the next odd number if n is odd.
    - the next even number if n is even.
Return the number of stones in each level in a list, where element at index
i represents the number of stones in the level (i+1).

Examples:
>>> make_a_pile(3)
[3, 5, 7]
Response:
```python
def make_a_pile(n):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.

For example:
words_string("Hi, my name is John") == ["Hi", "my", "name", "is", "John"]
words_string("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"]
Response:
```python
def words_string(s):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should return -1.

For example:
choose_num(12, 15) = 14
choose_num(13, 12) = -1
Response:
```python
def choose_num(x, y):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and convert that to binary.
If n is greater than m, return -1.
Example:
rounded_avg(1, 5) => "0b11"
rounded_avg(7, 5) => -1
rounded_avg(10, 20) => "0b1111"
rounded_avg(20, 33) => "0b11010"
Response:
```python
def rounded_avg(n, m):


Prompt:
Instruction:Write a function that takes in a list of strings words and an integer n. The function should return the concatenation of the first n strings from the list words where each string contains at most three characters.

Example:
Input: words = ['abc', 'defg', 'hij', 'klmno', 'pqrstu'], n = 3
Output: 'abchijklmno'

Constraints:

1 <= len(words) <= 50
1 <= n <= len(words)
Response:
```python
def concatenate_words(words, n):
    # Initialize an empty string for the concatenated result
    result = ""

    # Iterate through the first n elements of words
    for word in words[:n]:
        # Check if the length of the word is at most three characters
        if len(word) <= 3:
            # Concatenate the word to the result
            result += word

    return result
```

Instruction: Write a Python function called 'is_square_number' that takes an integer 'num' as input and returns True if 'num' is a perfect square, and False otherwise.
Response:
```python
def is_square_number(num: int) -> bool:
    """
    Checks if an integer is a perfect square.

    Args:
        num (int): The integer to check.

    Returns:
        bool: True if the integer is a perfect square, False otherwise.
    """
    if num < 0:
        return False

    square_root = int(num ** 0.5)
    return square_root * square_root == num

# Test cases
print(is_square_number(1))   # Output should be True
print(is_square_number(2))   # Output should be False
print(is_square_number(-1))  # Output should be False
print(is_square_number(64))  # Output should be True
print(is_square_number(0))   # Output should be True
print(is_square_number(180)) # Output should be False
```

Instruction: Create a function that returns True if the first character
of a given string is a digit and is not followed by another digit,
and False otherwise.
Note: A "digit" refers to a character from '0' to '9'.

Examples:
check_if_first_char_is_digit("123 apple") ➞ False
check_if_first_char_is_digit("123 456 apple") ➞ False
check_if_first_char_is_digit("1234 apple") ➞ True
check_if_first_char_is_digit("4 apple") ➞ True
check_if_first_char_is_digit("") ➞ False
Response:
```python
def check_if_first_char_is_digit(txt):
    if txt == "":
        return False
    first_char = txt[0]
    if first_char.isdigit():
        if len(txt) == 1:
            return True
        elif not txt[1].isdigit():
            return True
    return False
```

Instruction: Write a function sort_array that sorts an array of tuples based on the sum of their elements in ascending order. For tuples with the same sum of elements, sort based on the maximum element in the tuple.
Response:
```python
def sort_array(arr):
    return sorted(arr, key=lambda x: (sum(x), max(x)))

# Test cases
print(sort_array([(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
print(sort_array([(3, 2), (1, 4), (5, 6), (7, 8), (9, 10)]))  # Output: [(1, 4), (3, 2), (5, 6), (7, 8), (9, 10)]
```

Instruction: Write a Python function called 'custom_list' that takes a positive integer 'n' as input and returns a list of size 'n'. The value of the element at index 'i' is the factorial of 'i' if 'i' is even, or the sum of numbers from 1 to 'i' otherwise. Indexing starts from 1.
Response:
```python
def custom_list(n: int) -> List[int]:
    """
    Constructs a list of size n, where the value of the element at index i is the factorial of i if i is even,
    or the sum of numbers from 1 to i otherwise.

    Args:
        n (int): The size of the list.

    Returns:
        List[int]: The constructed list.
    """
    def factorial(num):
        if num == 0 or num == 1:
            return 1
        else:
            return num * factorial(num - 1)

    custom = []
    for i in range(1, n + 1):
        if i % 2 == 0:
            custom.append(factorial(i))
        else:
            custom.append(sum(range(1, i + 1)))
    return custom

# Test case
print(custom_list(5))   # Output should be [1, 2, 6, 24, 15]
```

Instruction: Write a Python function called 'alternate_sort_list' that takes a list of integers as input and returns the list sorted in a strange order. In this strange order, you start with the minimum value, then the maximum of the remaining integers, then the minimum, and so on.
Response:
```python
def alternate_sort_list(lst):
    """
    Sorts a list of integers in a strange order.

    Args:
        lst (list): The list of integers to be sorted.

    Returns:
        list: The list sorted in a strange order.
    """
    sorted_lst = []
    lst.sort()
    while lst:
        sorted_lst.append(lst.pop(0))
        if lst:
            sorted_lst.append(lst.pop(-1))
    return sorted_lst

# Test cases
print(alternate_sort_list([1, 2, 3, 4]))   # Output should be [1, 4, 2, 3]
print(alternate_sort_list([5, 5, 5, 5]))   # Output should be [5, 5, 5, 5]
print(alternate_sort_list([]))             # Output should be []
```

Instruction: You are given a string representing a password.
If a character in the password is a letter, reverse its case (convert uppercase to lowercase and vice versa).
If a character in the password is a digit, replace it with its complement (9 - digit).
If a character in the password is a special character (not a letter or a digit), keep it as it is.
The function should return the modified password string.

Examples:
modify_password("AbCd1234") ➞ "aBcD8765" (A -> a, b -> B, C -> c, d -> D, 1 -> 8, 2 -> 7, 3 -> 6, 4 -> 5)
modify_password("P@𝑤0𝑟𝑑")➞"p@W9RD" (P -> p, @ -> @, $ -> $, $ -> $, w -> W, 0 -> 9, r -> R, d -> D)
Response:
```python
def modify_password(password):
    modified = ""
    for char in password:
        if char.isalpha():
            modified += char.swapcase()
        elif char.isdigit():
            modified += str(9 - int(char))
        else:
            modified += char
    return modified
```

Instruction: Write a Python function called 'sum_even_odd_indices' that takes a non-empty list of integers as input and returns the sum of the even elements that are at odd indices.
Response:
```python
def sum_even_odd_indices(lst):
    """
    Adds the even elements that are at odd indices in a list of integers.

    Args:
        lst (list): The list of integers.

    Returns:
        int: The sum of the even elements at odd indices.
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

# Test cases
print(sum_even_odd_indices([4, 2, 6, 7]))  # Output should be 2
```

Instruction: Write a Python function called 'intersperse_chars' that takes a list of characters as input and returns a new list where a given character delimiter is inserted between every two consecutive characters of the input list.
Response:
```python
from typing import List

def intersperse_chars(chars: List[str], delimiter: str) -> List[str]:
    """
    This function inserts a character delimiter between every two consecutive characters of the input list.

    Args:
        chars (list): List of characters.
        delimiter (str): Character delimiter to be inserted between characters.

    Returns:
        list: List with delimiter inserted between consecutive characters.
    """
    if not chars:
        return []
    result = []
    for char in chars[:-1]:
        result.extend([char, delimiter])
    result.append(chars[-1])
    return result

# Test cases
print(intersperse_chars([], "-"))       # Output should be []
print(intersperse_chars(["a", "b", "c"], "-"))  # Output should be ['a', '-', 'b', '-', 'c']
```

Instruction: Write a function that takes a list of strings as input and returns the number of strings that have both their first and last characters as vowels ('a', 'e', 'i', 'o', 'u').

For example:
count_vowel_bookends(["apple", "banana", "orange", "pear", "kiwi"]) ➞ 2 (only "apple" and "orange" have both first and last characters as vowels)
count_vowel_bookends(["cat", "dog", "bird", "fish"]) ➞ 0 (none of the strings have both first and last characters as vowels)
count_vowel_bookends(["eye", "ear", "opal", "umbrella"]) ➞ 4 (all strings have both first and last characters as vowels)
Response:
```python
def count_vowel_bookends(strings):
    vowels = "aeiouAEIOU"
    count = 0
    for string in strings:
        if string[0].lower() in vowels and string[-1].lower() in vowels:
            count += 1
    return count
```

Instruction: Write a Python function called 'make_symmetric_string' that takes a string as input and returns the shortest symmetric string that begins with the supplied string. The algorithm idea is to find the longest postfix of the supplied string that is symmetric and then append to it the reverse of the prefix of the string before the symmetric suffix.
Response:
```python
def is_symmetric(string: str) -> bool:
    """Test if given string is symmetric."""
    return string == string[::-1]

def make_symmetric_string(string: str) -> str:
    """Find the shortest symmetric string that begins with a supplied string.
    Algorithm idea is simple:
    - Find the longest postfix of the supplied string that is symmetric.
    - Append to the end of the string the reverse of a prefix of the string before the symmetric suffix.

    Args:
        string (str): The supplied string.

    Returns:
        str: The shortest symmetric string that begins with the supplied string.

    >>> make_symmetric_string('')
    ''
    >>> make_symmetric_string('cat')
    'catac'
    >>> make_symmetric_string('cata')
    'catac'
    """
    if not string:
        return ''
    for i in range(len(string), 0, -1):
        if is_symmetric(string[-i:]):
            return string + string[:-i][::-1]

# Test cases
print(make_symmetric_string(''))       # Output should be ''
print(make_symmetric_string('cat'))    # Output should be 'catac'
print(make_symmetric_string('cata'))   # Output should be 'catac'
```

Instruction: Write a Python function called 'sort_unique_chars' that takes a string as input and returns a sorted list of unique characters in the string.
Response:
```python
def sort_unique_chars(s: str):
    """
    Returns sorted unique characters in a string.

    Args:
        s (str): Input string.

    Returns:
        list: Sorted list of unique characters.
    """
    return sorted(set(s))

# Test case
print(sort_unique_chars("hello"))  # Output should be ['e', 'h', 'l', 'o']
```

Instruction: Write a Python function called 'min_abs_sum_subarray' that takes a list of integers 'nums' as input and finds the minimum sum of any non-empty sub-array of 'nums'.
Response:
```python
def min_abs_sum_subarray(nums: List[int]) -> int:
    """
    Finds the minimum sum of any non-empty sub-array of nums.

    Args:
        nums (List[int]): The list of integers.

    Returns:
        int: The minimum sum of any non-empty sub-array.
    """
    if not nums:
        return 0

    current_sum = nums[0]
    min_sum = nums[0]

    for num in nums[1:]:
        current_sum = min(num, current_sum + num)
        min_sum = min(min_sum, current_sum)

    return min_sum

# Test cases
print(min_abs_sum_subarray([2, 3, 4, 1, 2, 4]))  # Output should be 1
print(min_abs_sum_subarray([-1, -2, -3]))        # Output should be -6
```

Instruction: Write a Python function called 'calculate_stats' that takes a list of floats as input and returns a tuple consisting of the sum and the average of all the floats in the list. If the list is empty, the sum should be 0 and the average should be None.
Response:
```python
from typing import List, Tuple

def calculate_stats(numbers: List[float]) -> Tuple[float, float]:
    """
    Calculates the sum and average of all the floats in a list.

    Args:
        numbers (List[float]): List of floats.

    Returns:
        Tuple[float, float]: A tuple consisting of the sum and the average of the floats.
    """
    if not numbers:
        return 0, None
    total_sum = sum(numbers)
    average = total_sum / len(numbers)
    return total_sum, average

# Test cases
print(calculate_stats([]))             # Output should be (0, None)
print(calculate_stats([1.5, 2.5, 3.5])) # Output should be (7.5, 2.5)
```

Instruction: Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.

Note: Returned list should be sorted in increasing order.

For example:
>>> unique_digits([15, 33, 1422, 1])
[1, 15, 33]
>>> unique_digits([152, 323, 1422, 10])
[]
Response:
```python
def unique_digits(x):