

--------------------------------------------------HumanEval/133--------------------------------------------------



def sum_squares(lst):
    """You are given a list of numbers.
    You need to return the sum of squared numbers in the given list,
    round each element in the list to the upper int(Ceiling) first.
    Examples:
    For lst = [1,2,3] the output should be 14
    For lst = [1,4,9] the output should be 98
    For lst = [1,3,5,7] the output should be 84
    For lst = [1.4,4.2,0] the output should be 29
    For lst = [-2.4,1,1] the output should be 6
    

    """
    
    squared_numbers = []
    for element in lst:
        squared_numbers.append(round(element**2))
    return sum(squared_numbers)



--------------------------------------------------HumanEval/134--------------------------------------------------


def check_if_last_char_is_a_letter(txt):
    '''
    Create a function that returns True if the last character
    of a given string is an alphabetical character and is not
    a part of a word, and False otherwise.
    Note: "word" is a group of characters separated by space.

    Examples:
    check_if_last_char_is_a_letter("apple pie") ➞ False
    check_if_last_char_is_a_letter("apple pi e") ➞ True
    check_if_last_char_is_a_letter("apple pi e ") ➞ False
    check_if_last_char_is_a_letter("") ➞ False 
    '''
    txt = txt.lower()
    last_char = txt[-1]
    return not last_char.isalpha() and not last_char.isnumeric()




--------------------------------------------------HumanEval/135--------------------------------------------------


def can_arrange(arr):
    """Create a function which returns the largest index of an element which
    is not greater than or equal to the element immediately preceding it. If
    no such element exists then return -1. The given array will not contain
    duplicate values.

    Examples:
    can_arrange([1,2,4,3,5]) = 3
    can_arrange([1,2,3]) = -1
    """
    index = -1
    for i in range(len(arr)):
        if arr[i] >= arr[i-1]:
            index = i
    return index



--------------------------------------------------HumanEval/136--------------------------------------------------


def largest_smallest_integers(lst):
    '''
    Create a function that returns a tuple (a, b), where 'a' is
    the largest of negative integers, and 'b' is the smallest
    of positive integers in a list.
    If there is no negative or positive integers, return them as None.

    Examples:
    largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
    largest_smallest_integers([]) == (None, None)
    largest_smallest_integers([0]) == (None, None)
    '''
    largest = None
    smallest = None
    integers = lst
    for integer in integers:
        if largest == None or largest < integer:
            largest = integer
        if smallest == None or smallest > integer:
            smallest = integer
    return (largest, smallest)




--------------------------------------------------HumanEval/137--------------------------------------------------


def compare_one(a, b):
    """
    Create a function that takes integers, floats, or strings representing
    real numbers, and returns the larger variable in its given variable type.
    Return None if the values are equal.
    Note: If a real number is represented as a string, the floating point might be. or,

    compare_one(1, 2.5) ➞ 2.5
    compare_one(1, "2,3") ➞ "2,3"
    compare_one("5,1", "6") ➞ "6"
    compare_one("1", 1) ➞ None
    """
    if type(a) == type(b):
        return max(a, b)
    elif type(a) == float or type(a) == int:
        return max(a, b)
    elif type(a) == str:
        return max(a, b)
    else:
        return None




--------------------------------------------------HumanEval/138--------------------------------------------------


def is_equal_to_sum_even(n):
    """Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
    Example
    is_equal_to_sum_even(4) == False
    is_equal_to_sum_even(6) == False
    is_equal_to_sum_even(8) == True
    """
    if n < 4:
        return False
    if n % 4 == 0:
        return True
    return is_equal_to_sum_even(n - 2 * (n % 4))




--------------------------------------------------HumanEval/139--------------------------------------------------


def special_factorial(n):
    """The Brazilian factorial is defined as:
    brazilian_factorial(n) = n! * (n-1)! * (n-2)! *... * 1!
    where n > 0

    For example:
    >>> special_factorial(4)
    288

    The function will receive an integer as input and should return the special
    factorial of this integer.
    """
    if n == 0:
        return 1
    elif n == 1:
        return 1
    else:
        return n * special_factorial(n - 1) * special_factorial(n - 2) *... * 1




--------------------------------------------------HumanEval/140--------------------------------------------------


def fix_spaces(text):
    """
    Given a string text, replace all spaces in it with underscores, 
    and if a string has more than 2 consecutive spaces, 
    then replace all consecutive spaces with - 
    
    fix_spaces("Example") == "Example"
    fix_spaces("Example 1") == "Example_1"
    fix_spaces(" Example 2") == "_Example_2"
    fix_spaces(" Example   3") == "_Example-3"
    """
    
    # First, check if string has more than 2 consecutive spaces
    # If so, replace consecutive spaces with - 
    #
    # Fix_spaces("Example") == "Example"
    # Fix_spaces("Example 1") == "Example_1"
    # Fix_spaces(" Example 2") == "_Example_2"
    # Fix_spaces(" Example   3") == "_Example-3"
    
    # Second, check if string