

--------------------------------------------------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
    

    """
    
    return sum([round(x**2) for x in lst])



--------------------------------------------------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 
    '''
    if txt[-1] in ALPHABETICAL_CHARACTERS:
        return False
    else:
        return True



--------------------------------------------------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
    """
    # TODO: Write your code here
    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
    for num in lst:
        if num < 0:
            if smallest is None:
                smallest = num
            else:
                if largest is None:
                    largest = num
                else:
                    if largest < num:
                        largest = num
                    else:
                        smallest = num
    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 % 2 == 0:
        return True
    if n % 2 == 1:
        return is_equal_to_sum_even(n - 1)
    return is_equal_to_sum_even(n - 2)




--------------------------------------------------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)




--------------------------------------------------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, replace all spaces with -
    text = text.replace(" ", "_")
    
    # Then, replace consecutive spaces with -
    for i in range(len(text) - 2):
        if text[i] == " ":
            text = text[:i] + "_" + text[i + 1:]
    
    # Finally, replace consecutive spaces with -
    for i in range(len(text) - 2):
        if text[i] == " ":
            text = text[:i] + "-_" + text[i + 1:]
    
    return text



--------------------------------------------------HumanEval/141--------------------------------------------------


def file_name_check(file_name):
    """Create a function which takes a string representing a file's name, and returns
    'Yes' if the the file's name is valid, and returns 'No' otherwise.
    A file's name is considered to be valid if and only if all the following conditions 
    are met:
    - There should not be more than three digits ('0'-'9') in the file's name.
    - The file's name contains exactly one dot '.'
    - The substring before the dot should not be empty, and it starts with a letter from 
    the latin alphapet ('a'-'z' and 'A'-'Z').
    - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
    Examples:
    file_name_check("example.txt") # => 'Yes'
    file_name_check("1example.dll") # => 'No' (the name should start with a latin alphapet letter)
    """
    # Create a regex