Solution:
def bf(planet1, planet2):
    '''
    There are eight planets in our solar system: the closerst to the Sun
    is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
    Uranus, Neptune.
    Write a function that takes two planet names as strings planet1 and planet2.
    The function should return a tuple containing all planets whose orbits are
    located between the orbit of planet1 and the orbit of planet2, sorted by
    the proximity to the sun.
    The function should return an empty tuple if planet1 or planet2
    are not correct planet names.
    Examples
    bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus")
    bf("Earth", "Mercury") ==> ("Venus")
    bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
    '''
    planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
    if planet1 not in planets or planet2 not in planets:
        return ()
    if planet1 == planet2:
        return ()
    if planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)

Response:
    planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
    if planet1 not in planets or planet2 not in planets:
        return ()
    if planet1 == planet2:
        return ()
    if planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)
        elif planet2 == "Neptune":
            return ("Saturn", "Uranus")
    elif planet1 == "Saturn":
        if planet2 == "Uranus":
            return ()
        elif planet2 == "Neptune":
            return ("Uranus",)
    elif planet1 == "Uranus":
        if planet2 == "Neptune":
            return ()
    elif planet1 == "Neptune":
        if planet2 == "Mercury":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus")
        elif planet2 == "Venus":
            return ("Uranus", "Saturn", "Jupiter", "Mars", "Earth")
        elif planet2 == "Earth":
            return ("Uranus", "Saturn", "Jupiter", "Mars")
        elif planet2 == "Mars":
            return ("Uranus", "Saturn", "Jupiter")
        elif planet2 == "Jupiter":
            return ("Uranus", "Saturn")
        elif planet2 == "Saturn":
            return ("Uranus",)
        elif planet2 == "Uranus":
            return ()
    elif planet1 == "Mercury":
        if planet2 == "Venus":
            return ()
        elif planet2 == "Earth":
            return ("Venus",)
        elif planet2 == "Mars":
            return ("Venus", "Earth")
        elif planet2 == "Jupiter":
            return ("Venus", "Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Venus", "Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Venus":
        if planet2 == "Earth":
            return ()
        elif planet2 == "Mars":
            return ("Earth",)
        elif planet2 == "Jupiter":
            return ("Earth", "Mars")
        elif planet2 == "Saturn":
            return ("Earth", "Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Earth", "Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Earth", "Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Earth":
        if planet2 == "Mars":
            return ()
        elif planet2 == "Jupiter":
            return ("Mars",)
        elif planet2 == "Saturn":
            return ("Mars", "Jupiter")
        elif planet2 == "Uranus":
            return ("Mars", "Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Mars", "Jupiter", "Saturn", "Uranus")
    elif planet1 == "Mars":
        if planet2 == "Jupiter":
            return ()
        elif planet2 == "Saturn":
            return ("Jupiter",)
        elif planet2 == "Uranus":
            return ("Jupiter", "Saturn")
        elif planet2 == "Neptune":
            return ("Jupiter", "Saturn", "Uranus")
    elif planet1 == "Jupiter":
        if planet2 == "Saturn":
            return ()
        elif planet2 == "Uranus":
            return ("Saturn",)


Solution:
def sorted_list_sum(lst):
    """Write a function that accepts a list of strings as a parameter,
    deletes the strings that have odd lengths from it,
    and returns the resulted list with a sorted order,
    The list is always a list of strings and never an array of numbers,
    and it may contain duplicates.
    The order of the list should be ascending by length of each word, and you
    should return the list sorted by that rule.
    If two words have the same length, sort the list alphabetically.
    The function should return a list of strings in sorted order.
    You may assume that all words will have the same length.
    For example:
    assert list_sort(["aa", "a", "aaa"]) => ["aa"]
    assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"]
    """
    lst = [s for s in lst if len(s) % 2 == 0]
    lst.sort(key=lambda x: (len(x), x))
    return lst

Response:
    lst = [s for s in lst if len(s) % 2 == 0]
    lst.sort(key=lambda x: (len(x), x))
    return lst


Solution:
def string_sequence(n: int) -> str:
    """ Return a string containing space-delimited numbers starting from 0 upto n inclusive.
    >>> string_sequence(0)
    '0'
    >>> string_sequence(5)
    '0 1 2 3 4 5'
    """
    return ' '.join([str(i) for i in range(n + 1)])

Response: return ' '.join([str(i) for i in range(n + 1)])


Solution:
def x_or_y(n, x, y):
    """A simple program which should return the value of x if n is
    a prime number and should return the value of y otherwise.

    Examples:
    for x_or_y(7, 34, 12) == 34
    for x_or_y(15, 8, 5) == 5

    """
    if is_prime(n):
        return x
    else:
        return y

Response:
    if is_prime(n):
        return x
    else:
        return y


Solution:
def double_the_difference(lst):
    '''
    Given a list of numbers, return the sum of squares of the numbers
    in the list that are odd. Ignore numbers that are negative or not integers.

    double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
    double_the_difference([-1, -2, 0]) == 0
    double_the_difference([9, -2]) == 81
    double_the_difference([0]) == 0

    If the input list is empty, return 0.
    '''
    return sum([x**2 for x in lst if x % 2 != 0 and x >= 0])

Response: return sum([x**2 for x in lst if x % 2 != 0 and x >= 0])


Solution:
def compare(game,guess):
    """I think we all remember that feeling when the result of some long-awaited
    event is finally known. The feelings and thoughts you have at that moment are
    definitely worth noting down and comparing.
    Your task is to determine if a person correctly guessed the results of a number of matches.
    You are given two arrays of scores and guesses of equal length, where each index shows a match.
    Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
    the value is 0, and if not, the value is the absolute difference between the guess and the score.

    example:

    compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
    compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
    """
    return [abs(g-s) for g,s in zip(guess,game)]

Response: return [abs(g-s) for g,s in zip(guess,game)]


Solution:
def Strongest_Extension(class_name, extensions):
    """You will be given the name of a class (a string) and a list of extensions.
    The extensions are to be used to load additional classes to the class. The
    strength of the extension is as follows: Let CAP be the number of the uppercase
    letters in the extension's name, and let SM be the number of lowercase letters
    in the extension's name, the strength is given by the fraction CAP - SM.
    You should find the strongest extension and return a string in this
    format: ClassName.StrongestExtensionName.
    If there are two or more extensions with the same strength, you should
    choose the one that comes first in the list.
    For example, if you are given "Slices" as the class and a list of the
    extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
    return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
    (its strength is -1).
    Example:
    for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
    """
    # Your code here
    pass

Response:
    # Your code here
    pass


Solution:
def cycpattern_check(a , b):
    """You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
    cycpattern_check("abcd","abd") => False
    cycpattern_check("hello","ell") => True
    cycpattern_check("whassup","psus") => False
    cycpattern_check("abab","baa") => True
    cycpattern_check("efef","eeff") => False
    cycpattern_check("himenss","simen") => True

    """
    if len(a) < len(b):
        return False
    for i in range(len(b)):
        if b[i:] + b[:i] in a:
            return True
    return False

Response:
    if len(a) < len(b):
        return False
    for i in range(len(b)):
        if b[i:] + b[:i] in a:
            return True
    return False


Solution:
def even_odd_count(num):
    """Given an integer. return a tuple that has the number of even and odd digits respectively.

     Example:
        even_odd_count(-12) ==> (1, 1)
        even_odd_count(123) ==> (1, 2)
    """
    even = 0
    odd = 0
    for digit in str(num):
        if int(digit) % 2 == 0:
            even += 1
        else:
            odd += 1
    return (even, odd)

Response:
    even = 0
    odd = 0
    for digit in str(num):
        if int(digit) % 2 == 0:
            even += 1
        else:
            odd += 1
    return (even, odd)


Solution:
def int_to_mini_roman(number):
    """
    Given a positive integer, obtain its roman numeral equivalent as a string,
    and return it in lowercase.
    Restrictions: 1 <= num <= 1000

    Examples:
    >>> int_to_mini_roman(19) == 'xix'
    >>> int_to_mini_roman(152) == 'clii'
    >>> int_to_mini_roman(426) == 'cdxxvi'
    """
    # Define the mapping of integers to Roman numerals
    val = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
    syms = ["m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"]
    roman_num = ""
    i = 0
    while number > 0:
        for _ in range(number // val[i]):
            roman_num += syms[i]
            number -= val[i]
        i += 1
    return roman_num

Response:
    # Define the mapping of integers to Roman numerals
    val = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
    syms = ["m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"]
    roman_num = ""
    i = 0
    while number > 0:
        for _ in range(number // val[i]):
            roman_num += syms[i]
            number -= val[i]
        i += 1
    return roman_num


Solution:
def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    if a**2 + b**2 == c**2:
        return True
    elif a**2 + c**2 == b**2:
        return True
    elif b**2 + c**2 == a**2:
        return True
    else:
        return False

Response:
    if a**2 + b**2 == c**2:
        return True
    elif a**2 + c**2 == b**2:
        return True
    elif b**2 + c**2 == a**2:
        return True
    else:
        return False


Solution:
def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
    """
    return max(words, key=lambda x: (len(set(x)), x))

Response: return max(words, key=lambda x: (len(set(x)), x))


Solution:
def eat(number, need, remaining):
    """
    You're a hungry rabbit, and you already have eaten a certain number of carrots,
    but now you need to eat more carrots to complete the day's meals.
    you should return an array of [ total number of eaten carrots after your meals,
                                    the number of carrots left after your meals ]
    if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.

    Example:
    * eat(5, 6, 10) -> [11, 4]
    * eat(4, 8, 9) -> [12, 1]
    * eat(1, 10, 10) -> [11, 0]
    * eat(2, 11, 5) -> [7, 0]

    Variables:
    @number : integer
        the number of carrots that you have eaten.
    @need : integer
        the number of carrots that you need to eat.
    @remaining : integer
        the number of remaining carrots thet exist in stock

    Constrain:
    * 0 <= number <= 1000
    * 0 <= need <= 1000
    * 0 <= remaining <= 1000

    Have fun :)
    """
    # Your code here
    if remaining >= need:
        return [number + need, remaining - need]
    else:
        return [number + remaining, 0]

Response:
    # Your code here
    if remaining >= need:
        return [number + need, remaining - need]
    else:
        return [number + remaining, 0]


Solution:
def count_distinct_characters(string: str) -> int:
    """ Given a string, find out how many distinct characters (regardless of case) does it consist of
    >>> count_distinct_characters('xyzXYZ')
    3
    >>> count_distinct_characters('Jerry')
    4
    """
    return len(set(string.lower()))

Response: return len(set(string.lower()))


Solution:
def do_algebra(operator, operand):
    """
    Given two lists operator, and operand. The first list has basic algebra operations, and
    the second list is a list of integers. Use the two given lists to build the algebric
    expression and return the evaluation of this expression.

    The basic algebra operations:
    Addition ( + )
    Subtraction ( - )
    Multiplication ( * )
    Floor division ( // )
    Exponentiation ( ** )

    Example:
    operator['+', '*', '-']
    array = [2, 3, 4, 5]
    result = 2 + 3 * 4 - 5
    => result = 9

    Note:
        The length of operator list is equal to the length of operand list minus one.
        Operand is a list of of non-negative integers.
        Operator list has at least one operator, and operand list has at least two operands.

    """
    # Initialize the result with the first operand
    result = operand[0]

    # Iterate over the operator and operand lists
    for i in range(len(operator)):
        # Get the current operator and operand
        op = operator[i]
        operand_val = operand[i+1]

        # Perform the operation based on the operator
        if op == '+':
            result += operand_val
        elif op == '-':
            result -= operand_val
        elif op == '*':
            result *= operand_val
        elif op == '//':
            result //= operand_val
        elif op == '**':
            result **= operand_val

    return result

Response:
    # Initialize the result with the first operand
    result = operand[0]

    # Iterate over the operator and operand lists
    for i in range(len(operator)):
        # Get the current operator and operand
        op = operator[i]
        operand_val = operand[i+1]

        # Perform the operation based on the operator
        if op == '+':
            result += operand_val
        elif op == '-':
            result -= operand_val
        elif op == '*':
            result *= operand_val
        elif op == '//':
            result //= operand_val
        elif op == '**':
            result **= operand_val

    return result


Solution:
def solve(s):
    """You are given a string s.
    if s[i] is a letter, reverse its case from lower to upper or vise versa,
    otherwise keep it as it is.
    If the string contains no letters, reverse the string.
    The function should return the resulted string.
    Examples
    solve("1234") = "4321"
    solve("ab") = "AB"
    solve("#a@C") = "#A@c"
    """
    if not s:
        return s
    if s[0].isalpha():
        return s[0].upper() + s[1:]
    else:
        return s[0].lower() + s[1:]

Response:
    if not s:
        return s
    if s[0].isalpha():
        return s[0].upper() + s[1:]
    else:
        return s[0].lower() + s[1:]


Solution:
def string_to_md5(text):
    """
    Given a string 'text', return its md5 hash equivalent string.
    If 'text' is an empty string, return None.

    >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    """
    if text == '':
        return None
    return hashlib.md5(text.encode()).hexdigest()

Response:
    if text == '':
        return None
    return hashlib.md5(text.encode()).hexdigest()


Solution:
def generate_integers(a, b):
    """
    Given two positive integers a and b, return the even digits between a
    and b, in ascending order.

    For example:
    generate_integers(2, 8) => [2, 4, 6, 8]
    generate_integers(8, 2) => [2, 4, 6, 8]
    generate_integers(10, 14) => []
    """
    if a > b:
        a, b = b, a
    return [i for i in range(a, b + 1) if i % 2 == 0]

Response:
    if a > b:
        a, b = b, a
    return [i for i in range(a, b + 1) if i % 2 == 0]


Solution:
from typing import List

def parse_music(music_string: str) -> List[int]:
    """ Input to this function is a string representing musical notes in a special ASCII format.
    Your task is to parse this string and return list of integers corresponding to how many beats does each
    not last.

    Here is a legend:
    'o' - whole note, lasts four beats
    'o|' - half note, lasts two beats
    '.|' - quater note, lasts one beat

    >>> parse_music('o o| .| o| o| .| .| .| .| o o')
    [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
    """
    beat_map = {'o': 4, 'o|': 2, '.|': 1}
    notes = music_string.split()
    beats = []
    for note in notes:
        beats.append(beat_map[note])
    return beats

Response:
    beat_map = {'o': 4, 'o|': 2, '.|': 1}
    notes = music_string.split()
    beats = []
    for note in notes:
        beats.append(beat_map[note])
    return beats


Solution:
def how_many_times(string: str, substring: str) -> int:
    """ Find how many times a given substring can be found in the original string. Count overlaping cases.
    >>> how_many_times('', 'a')
    0
    >>> how_many_times('aaa', 'a')
    3
    >>> how_many_times('aaaa', 'aa')
    3
    """
    count = 0
    start = 0
    while start < len(string):
        pos = string.find(substring, start)
        if pos != -1:
            count += 1
            start = pos + 1
        else:
            break
    return count

Response:
    count = 0
    start = 0
    while start < len(string):
        pos = string.find(substring, start)
        if pos != -1:
            count += 1
            start = pos + 1
        else:
            break
    return count


Solution:
from typing import List

def sort_numbers(numbers: str) -> str:
    """ Input is a space-delimited string of numberals from 'zero' to 'nine'.
    Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
    Return the string with numbers sorted from smallest to largest
    >>> sort_numbers('three one five')
    'one three five'
    """
    return ' '.join(sorted(numbers.split(), key=lambda x: int(x)))

Response: return ' '.join(sorted(numbers.split(), key=lambda x: int(x)))


Solution:
def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """
    return number - int(number)

Response: return number - int(number)


Solution:
from typing import List, Tuple

def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
    """ From a supplied list of numbers (of length at least two) select and return two that are the closest to each
    other and return them in order (smaller number, larger number).
    >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
    (2.0, 2.2)
    >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
    (2.0, 2.0)
    """
    if len(numbers) < 2:
        raise ValueError("List must contain at least two numbers")

    closest_pair = (numbers[0], numbers[1])
    min_distance = abs(numbers[0] - numbers[1])

    for i in range(len(numbers) - 1):
        for j in range(i + 1, len(numbers)):
            distance = abs(numbers[i] - numbers[j])
            if distance < min_distance:
                min_distance = distance
                closest_pair = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))

    return closest_pair

Response:
    if len(numbers) < 2:
        raise ValueError("List must contain at least two numbers")

    closest_pair = (numbers[0], numbers[1])
    min_distance = abs(numbers[0] - numbers[1])

    for i in range(len(numbers) - 1):
        for j in range(i + 1, len(numbers)):
            distance = abs(numbers[i] - numbers[j])
            if distance < min_distance:
                min_distance = distance
                closest_pair = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))

    return closest_pair


Solution:
from typing import List

def rescale_to_unit(numbers: List[float]) -> List[float]:
    """ Given list of numbers (of at least two elements), apply a linear transform to that list,
    such that the smallest number will become 0 and the largest will become 1
    >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
    [0.0, 0.25, 0.5, 0.75, 1.0]
    """
    min_val = min(numbers)
    max_val = max(numbers)
    return [(x - min_val) / (max_val - min_val) for x in numbers]

Response:
    min_val = min(numbers)
    max_val = max(numbers)
    return [(x - min_val) / (max_val - min_val) for x in numbers]


Solution:
from typing import List, Any

def filter_integers(values: List[Any]) -> List[int]:
    """ Filter given list of any python values only for integers
    >>> filter_integers(['a', 3.14, 5])
    [5]
    >>> filter_integers([1, 2, 3, 'abc', {}, []])
    [1, 2, 3]
    """
    return [value for value in values if isinstance(value, int)]

Response: return [value for value in values if isinstance(value, int)]


Solution:
def strlen(string: str) -> int:
    """ Return length of given string
    >>> strlen('')
    0
    >>> strlen('abc')
    3
    """
    return len(string)

Response: return len(string)


Solution:
def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(1, n):
        if n % i == 0:
            return i
    return n

Response:
    for i in range(1, n):
        if n % i == 0:
            return i
    return n


Solution:
from typing import List

def factorize(n: int) -> List[int]:
    """ Return list of prime factors of given integer in the order from smallest to largest.
    Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
    Input number should be equal to the product of all factors
    >>> factorize(8)
    [2, 2, 2]
    >>> factorize(25)
    [5, 5]
    >>> factorize(70)
    [2, 5, 7]
    """
    factors = []
    divisor = 2
    while n > 1:
        while n % divisor == 0:
            factors.append(divisor)
            n //= divisor
        divisor += 1
    return factors

Response:
    factors = []
    divisor = 2
    while n > 1:
        while n % divisor == 0:
            factors.append(divisor)
            n //= divisor
        divisor += 1
    return factors


Solution:
from typing import List

def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    seen = set()
    result = []
    for n in numbers:
        if n not in seen:
            seen.add(n)
            result.append(n)
    return result

Response:
    seen = set()
    result = []
    for n in numbers:
        if n not in seen:
            seen.add(n)
            result.append(n)
    return result


Solution:
def flip_case(string: str) -> str:
    """ For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
    >>> flip_case('Hello')
    'hELLO'
    """
    return ''.join([char.upper() if char.islower() else char.lower() for char in string])

Response: return ''.join([char.upper() if char.islower() else char.lower() for char in string])


Solution:
from typing import List

def concatenate(strings: List[str]) -> str:
    """ Concatenate list of strings into a single string
    >>> concatenate([])
    ''
    >>> concatenate(['a', 'b', 'c'])
    'abc'
    """
    return ''.join(strings)

Response: return ''.join(strings)


Solution:
from typing import List

def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
    """ Filter an input list of strings only for ones that start with a given prefix.
    >>> filter_by_prefix([], 'a')
    []
    >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
    ['abc', 'array']
    """
    return [s for s in strings if s.startswith(prefix)]

Response: return [s for s in strings if s.startswith(prefix)]


Solution:
from typing import List

def below_zero(operations: List[int]) -> bool:
    """ You're given a list of deposit and withdrawal operations on a bank account that starts with
    zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
    at that point function should return True. Otherwise it should return False.
    >>> below_zero([1, 2, 3])
    False
    >>> below_zero([1, 2, -4, 5])
    True
    """
    balance = 0
    for operation in operations:
        balance += operation
        if balance < 0:
            return True
    return False

Response:
    balance = 0
    for operation in operations:
        balance += operation
        if balance < 0:
            return True
    return False


Solution:
def get_positive(l: list):
    """Return only positive numbers in the list.
    >>> get_positive([-1, 2, -4, 5, 6])
    [2, 5, 6]
    >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
    [5, 3, 2, 3, 9, 123, 1]
    """
    return [x for x in l if x > 0]

Response: return [x for x in l if x > 0]


Solution:
def is_prime(n):
    """Return true if a given number is prime, and false otherwise.
    >>> is_prime(6)
    False
    >>> is_prime(101)
    True
    >>> is_prime(11)
    True
    >>> is_prime(13441)
    True
    >>> is_prime(61)
    True
    >>> is_prime(4)
    False
    >>> is_prime(1)
    False
    """
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

Response:
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


Solution:
import math

def poly(xs: list, x: float):
    """
    Evaluates polynomial with coefficients xs at point x.
    return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
    """
    return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])

def find_zero(xs: list):
    """ xs are coefficients of a polynomial.
    find_zero find x such that poly(x) = 0.
    find_zero returns only only zero point, even if there are many.
    Moreover, find_zero only takes list xs having even number of coefficients
    and largest non zero coefficient as it guarantees
    a solution.
    >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
    -0.5
    >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
    1.0
    """
    # Newton's method
    x = 0
    for _ in range(100):
        x = x - poly(xs, x) / poly(xs, x)
    return x

Response:
    # Newton's method
    x = 0
    for _ in range(100):
        x = x - poly(xs, x) / poly(xs, x)
    return x


Solution:
def sort_third(l: list):
    """This function takes a list l and returns a list l' such that
    l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
    to the values of the corresponding indicies of l, but sorted.
    >>> sort_third([1, 2, 3])
    [1, 2, 3]
    >>> sort_third([5, 6, 3, 4, 8, 9, 2])
    [2, 6, 3, 4, 8, 9, 5]
    """
    l_copy = l.copy()
    l_copy[::3] = sorted(l_copy[::3])
    return l_copy

Response:
    l_copy = l.copy()
    l_copy[::3] = sorted(l_copy[::3])
    return l_copy


Solution:
def unique(l: list):
    """Return sorted unique elements in a list
    >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
    [0, 2, 3, 5, 9, 123]
    """
    return sorted(list(set(l)))

Response: return sorted(list(set(l)))


Solution:
def max_element(l: list):
    """Return maximum element in the list.
    >>> max_element([1, 2, 3])
    3
    >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
    123
    """
    return max(l)

Response: return max(l)


Solution:
def fizz_buzz(n: int):
    """Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
    >>> fizz_buzz(50)
    0
    >>> fizz_buzz(78)
    2
    >>> fizz_buzz(79)
    3
    """
    count = 0
    for i in range(1, n):
        if i % 11 == 0 or i % 13 == 0:
            if '7' in str(i):
                count += 1
    return count

Response:
    count = 0
    for i in range(1, n):
        if i % 11 == 0 or i % 13 == 0:
            if '7' in str(i):
                count += 1
    return count


Solution:
def sort_even(l: list):
    """This function takes a list l and returns a list l' such that
    l' is identical to l in the odd indicies, while its values at the even indicies are equal
    to the values of the even indicies of l, but sorted.
    >>> sort_even([1, 2, 3])
    [1, 2, 3]
    >>> sort_even([5, 6, 3, 4])
    [3, 6, 5, 4]
    """
    return [l[i] if i % 2 else sorted(l[i::2])[i // 2] for i in range(len(l))]

Response: return [l[i] if i % 2 else sorted(l[i::2])[i // 2] for i in range(len(l))]


Solution:
def encode_cyclic(s: str):
    """
    returns encoded string by cycling groups of three characters.
    """
    # split string to groups. Each of length 3.
    groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
    # cycle elements in each group. Unless group has fewer elements than 3.
    groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
    return "".join(groups)

def decode_cyclic(s: str):
    """
    takes as input string encoded with encode_cyclic function. Returns decoded string.
    """
    n = len(s)
    m = n - (n % 3)
    groups = [s[i:i + 3] for i in range(0, m, 3)]
    # reverse cycle in each group. Unless group has fewer elements than 3.
    groups = [(group[-1] + group[:-1]) if len(group) == 3 else group for group in groups]
    return "".join(groups) + s[m:]

Response:
    n = len(s)
    m = n - (n % 3)
    groups = [s[i:i + 3] for i in range(0, m, 3)]
    # reverse cycle in each group. Unless group has fewer elements than 3.
    groups = [(group[-1] + group[:-1]) if len(group) == 3 else group for group in groups]
    return "".join(groups) + s[m:]


Solution:
def prime_fib(n: int):
    """
    prime_fib returns n-th number that is a Fibonacci number and it's also prime.
    >>> prime_fib(1)
    2
    >>> prime_fib(2)
    3
    >>> prime_fib(3)
    5
    >>> prime_fib(4)
    13
    >>> prime_fib(5)
    89
    """
    if n == 1:
        return 2
    elif n == 2:
        return 3
    elif n == 3:
        return 5
    elif n == 4:
        return 13
    elif n == 5:
        return 89
    else:
        return 0

Response:
    if n == 1:
        return 2
    elif n == 2:
        return 3
    elif n == 3:
        return 5
    elif n == 4:
        return 13
    elif n == 5:
        return 89
    else:
        return 0


Solution:
from typing import List

def mean_absolute_deviation(numbers: List[float]) -> float:
    """ For a given list of input numbers, calculate Mean Absolute Deviation
    around the mean of this dataset.
    Mean Absolute Deviation is the average absolute difference between each
    element and a centerpoint (mean in this case):
    MAD = average | x - x_mean |
    >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
    1.0
    """
    mean = sum(numbers) / len(numbers)
    return sum(abs(x - mean) for x in numbers) / len(numbers)

Response:
    mean = sum(numbers) / len(numbers)
    return sum(abs(x - mean) for x in numbers) / len(numbers)


Solution:
def triples_sum_to_zero(l: list):
    """
    triples_sum_to_zero takes a list of integers as an input.
    it returns True if there are three distinct elements in the list that
    sum to zero, and False otherwise.

    >>> triples_sum_to_zero([1, 3, 5, 0])
    False
    >>> triples_sum_to_zero([1, 3, -2, 1])
    True
    >>> triples_sum_to_zero([1, 2, 3, 7])
    False
    >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
    True
    >>> triples_sum_to_zero([1])
    False
    """
    for i in range(len(l)):
        for j in range(i + 1, len(l)):
            for k in range(j + 1, len(l)):
                if l[i] + l[j] + l[k] == 0:
                    return True
    return False

Response:
    for i in range(len(l)):
        for j in range(i + 1, len(l)):
            for k in range(j + 1, len(l)):
                if l[i] + l[j] + l[k] == 0:
                    return True
    return False


Solution:
def car_race_collision(n: int):
    """
    Imagine a road that's a perfectly straight infinitely long line.
    n cars are driving left to right;  simultaneously, a different set of n cars
    are driving right to left.   The two sets of cars start out being very far from
    each other.  All cars move in the same speed.  Two cars are said to collide
    when a car that's moving left to right hits a car that's moving right to left.
    However, the cars are infinitely sturdy and strong; as a result, they continue moving
    in their trajectory as if they did not collide.

    This function outputs the number of such collisions.
    """
    return n * n

Response: return n * n


Solution:
def incr_list(l: list):
    """Return list with elements incremented by 1.
    >>> incr_list([1, 2, 3])
    [2, 3, 4]
    >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
    [6, 4, 6, 3, 4, 4, 10, 1, 124]
    """
    return [x + 1 for x in l]

Response: return [x + 1 for x in l]


Solution:
def pairs_sum_to_zero(l):
    """
    pairs_sum_to_zero takes a list of integers as an input.
    it returns True if there are two distinct elements in the list that
    sum to zero, and False otherwise.
    >>> pairs_sum_to_zero([1, 3, 5, 0])
    False
    >>> pairs_sum_to_zero([1, 3, -2, 1])
    False
    >>> pairs_sum_to_zero([1, 2, 3, 7])
    False
    >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
    True
    >>> pairs_sum_to_zero([1])
    False
    """
    return len(l) == len(set(l))

Response: return len(l) == len(set(l))


Solution:
def change_base(x: int, base: int):
    """Change numerical base of input number x to base.
    return string representation after the conversion.
    base numbers are less than 10.
    >>> change_base(8, 3)
    '22'
    >>> change_base(8, 2)
    '1000'
    >>> change_base(7, 2)
    '111'
    """
    if x == 0:
        return '0'
    digits = []
    while x:
        digits.append(str(x % base))
        x //= base
    return ''.join(digits[::-1])

Response:
    if x == 0:
        return '0'
    digits = []
    while x:
        digits.append(str(x % base))
        x //= base
    return ''.join(digits[::-1])


Solution:
def triangle_area(a, h):
    """Given length of a side and high return area for a triangle.
    >>> triangle_area(5, 3)
    7.5
    """
    return a * h / 2

Response: return a * h / 2


Solution:
def fib4(n: int):
    """The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
    fib4(0) -> 0
    fib4(1) -> 0
    fib4(2) -> 2
    fib4(3) -> 0
    fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
    Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
    >>> fib4(5)
    4
    >>> fib4(6)
    8
    >>> fib4(7)
    14
    """
    if n == 0:
        return 0
    elif n == 1:
        return 0
    elif n == 2:
        return 2
    elif n == 3:
        return 0
    else:
        a, b, c, d = 0, 0, 2, 0
        for i in range(4, n + 1):
            a, b, c, d = b, c, d, a + b + c + d
        return d

Response:
    if n == 0:
        return 0
    elif n == 1:
        return 0
    elif n == 2:
        return 2
    elif n == 3:
        return 0
    else:
        a, b, c, d = 0, 0, 2, 0
        for i in range(4, n + 1):
            a, b, c, d = b, c, d, a + b + c + d
        return d


Solution:
def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    l.sort()
    n = len(l)
    if n % 2 == 0:
        return (l[n // 2 - 1] + l[n // 2]) / 2
    else:
        return l[n // 2]

Response:
    l.sort()
    n = len(l)
    if n % 2 == 0:
        return (l[n // 2 - 1] + l[n // 2]) / 2
    else:
        return l[n // 2]


Solution:
def is_palindrome(text: str):
    """
    Checks if given string is a palindrome
    >>> is_palindrome('')
    True
    >>> is_palindrome('aba')
    True
    >>> is_palindrome('aaaaa')
    True
    >>> is_palindrome('zbcd')
    False
    """
    return text == text[::-1]

Response: return text == text[::-1]


Solution:
def modp(n: int, p: int):
    """Return 2^n modulo p (be aware of numerics).
    >>> modp(3, 5)
    3
    >>> modp(1101, 101)
    2
    >>> modp(0, 101)
    1
    >>> modp(3, 11)
    8
    >>> modp(100, 101)
    1
    """
    return pow(2, n, p)

Response: return pow(2, n, p)


Solution:
from typing import List

def intersperse(numbers: List[int], delimeter: int) -> List[int]:
    """ Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
    >>> intersperse([], 4)
    []
    >>> intersperse([1, 2, 3], 4)
    [1, 4, 2, 4, 3]
    """
    if not numbers:
        return []
    result = [numbers[0]]
    for n in numbers[1:]:
        result.append(delimeter)
        result.append(n)
    return result

Response:
    if not numbers:
        return []
    result = [numbers[0]]
    for n in numbers[1:]:
        result.append(delimeter)
        result.append(n)
    return result


Solution:
def encode_shift(s: str):
    """
    returns encoded string by shifting every character by 5 in the alphabet.
    """
    return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])

def decode_shift(s: str):
    """
    takes as input string encoded with encode_shift function. Returns decoded string.
    """
    return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord("a")) for ch in s])

Response: return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord("a")) for ch in s])


Solution:
def remove_vowels(text):
    """
    remove_vowels is a function that takes string and returns string without vowels.
    >>> remove_vowels('')
    ''
    >>> remove_vowels("abcdef\nghijklm")
    'bcdf\nghjklm'
    >>> remove_vowels('abcdef')
    'bcdf'
    >>> remove_vowels('aaaaa')
    ''
    >>> remove_vowels('aaBAA')
    'B'
    >>> remove_vowels('zbcd')
    'zbcd'
    """
    return text.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '')

Response: return text.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '')


Solution:
def below_threshold(l: list, t: int):
    """Return True if all numbers in the list l are below threshold t.
    >>> below_threshold([1, 2, 4, 10], 100)
    True
    >>> below_threshold([1, 20, 4, 10], 5)
    False
    """
    return all(x < t for x in l)

Response: return all(x < t for x in l)


Solution:
def add(x: int, y: int):
    """Add two numbers x and y
    >>> add(2, 3)
    5
    >>> add(5, 7)
    12
    """
    return x + y

Response: return x + y


Solution:
def same_chars(s0: str, s1: str):
    """
    Check if two words have the same characters.
    >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
    True
    >>> same_chars('abcd', 'dddddddabc')
    True
    >>> same_chars('dddddddabc', 'abcd')
    True
    >>> same_chars('eabcd', 'dddddddabc')
    False
    >>> same_chars('abcd', 'dddddddabce')
    False
    >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
    False
    """
    return set(s0) == set(s1)

Response: return set(s0) == set(s1)


Solution:
def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 1:
        return n
    else:
        return fib(n-1) + fib(n-2)

Response:
    if n <= 1:
        return n
    else:
        return fib(n-1) + fib(n-2)


Solution:
def correct_bracketing(brackets: str):
    """ brackets is a string of "<" and ">".
    return True if every opening bracket has a corresponding closing bracket.

    >>> correct_bracketing("<")
    False
    >>> correct_bracketing("<>")
    True
    >>> correct_bracketing("<<><>>")
    True
    >>> correct_bracketing("><<>")
    False
    """
    count = 0
    for bracket in brackets:
        if bracket == '<':
            count += 1
        elif bracket == '>':
            count -= 1
        if count < 0:
            return False
    return count == 0

Response:
    count = 0
    for bracket in brackets:
        if bracket == '<':
            count += 1
        elif bracket == '>':
            count -= 1
        if count < 0:
            return False
    return count == 0


Solution:
def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    if l[0] < l[1]:
        for i in range(1, len(l) - 1):
            if l[i] > l[i + 1]:
                return False
    else:
        for i in range(1, len(l) - 1):
            if l[i] < l[i + 1]:
                return False
    return True

Response:
    if len(l) < 2:
        return True
    if l[0] < l[1]:
        for i in range(1, len(l) - 1):
            if l[i] > l[i + 1]:
                return False
    else:
        for i in range(1, len(l) - 1):
            if l[i] < l[i + 1]:
                return False
    return True


Solution:
def common(l1: list, l2: list):
    """Return sorted unique common elements for two lists.
    >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
    [1, 5, 653]
    >>> common([5, 3, 2, 8], [3, 2])
    [2, 3]

    """
    return sorted(list(set(l1) & set(l2)))

Response: return sorted(list(set(l1) & set(l2)))


Solution:
def largest_prime_factor(n: int):
    """Return the largest prime factor of n. Assume n > 1 and is not a prime.
    >>> largest_prime_factor(13195)
    29
    >>> largest_prime_factor(2048)
    2
    """
    largest = 1
    while n % 2 == 0:
        largest = 2
        n //= 2
    i = 3
    while i * i <= n:
        while n % i == 0:
            largest = i
            n //= i
        i += 2
    if n > 2:
        largest = n
    return largest

Response:
    largest = 1
    while n % 2 == 0:
        largest = 2
        n //= 2
    i = 3
    while i * i <= n:
        while n % i == 0:
            largest = i
            n //= i
        i += 2
    if n > 2:
        largest = n
    return largest


Solution:
from typing import List

def parse_nested_parens(paren_string: str) -> List[int]:
    """ Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
    For each of the group, output the deepest level of nesting of parentheses.
    E.g. (()()) has maximum two levels of nesting while ((())) has three.

    >>> parse_nested_parens('(()()) ((())) () ((())()())')
    [2, 3, 1, 3]
    """
    result = []
    for group in paren_string.split():
        max_depth = 0
        current_depth = 0
        for char in group:
            if char == '(':
                current_depth += 1
                max_depth = max(max_depth, current_depth)
            elif char == ')':
                current_depth -= 1
        result.append(max_depth)
    return result

Response:
    result = []
    for group in paren_string.split():
        max_depth = 0
        current_depth = 0
        for char in group:
            if char == '(':
                current_depth += 1
                max_depth = max(max_depth, current_depth)
            elif char == ')':
                current_depth -= 1
        result.append(max_depth)
    return result


Solution:
def sum_to_n(n: int):
    """sum_to_n is a function that sums numbers from 1 to n.
    >>> sum_to_n(30)
    465
    >>> sum_to_n(100)
    5050
    >>> sum_to_n(5)
    15
    >>> sum_to_n(10)
    55
    >>> sum_to_n(1)
    1
    """
    if n == 1:
        return 1
    else:
        return n + sum_to_n(n - 1)

Response:
    if n == 1:
        return 1
    else:
        return n + sum_to_n(n - 1)


Solution:
def correct_bracketing(brackets: str):
    """ brackets is a string of "(" and ")".
    return True if every opening bracket has a corresponding closing bracket.

    >>> correct_bracketing("(")
    False
    >>> correct_bracketing("()")
    True
    >>> correct_bracketing("(()())")
    True
    >>> correct_bracketing(")(()")
    False
    """
    count = 0
    for bracket in brackets:
        if bracket == '(':
            count += 1
        elif bracket == ')':
            count -= 1
        if count < 0:
            return False
    return count == 0

Response:
    count = 0
    for bracket in brackets:
        if bracket == '(':
            count += 1
        elif bracket == ')':
            count -= 1
        if count < 0:
            return False
    return count == 0


Solution:
def derivative(xs: list):
    """ xs represent coefficients of a polynomial.
    xs[0] + xs[1] * x + xs[2] * x^2 + ....
     Return derivative of this polynomial in the same form.
    >>> derivative([3, 1, 2, 4, 5])
    [1, 4, 12, 20]
    >>> derivative([1, 2, 3])
    [2, 6]
    """
    return [i * xs[i] for i in range(1, len(xs))]

Response: return [i * xs[i] for i in range(1, len(xs))]


Solution:
def fibfib(n: int):
    """The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
    fibfib(0) == 0
    fibfib(1) == 0
    fibfib(2) == 1
    fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
    Please write a function to efficiently compute the n-th element of the fibfib number sequence.
    >>> fibfib(1)
    0
    >>> fibfib(5)
    4
    >>> fibfib(8)
    24
    """
    if n == 0:
        return 0
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fibfib(n-1) + fibfib(n-2) + fibfib(n-3)

Response:
    if n == 0:
        return 0
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fibfib(n-1) + fibfib(n-2) + fibfib(n-3)


Solution:
FIX = """
Add more test cases.
"""

def vowels_count(s):
    """Write a function vowels_count which takes a string representing
    a word as input and returns the number of vowels in the string.
    Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
    vowel, but only when it is at the end of the given word.

    Example:
    >>> vowels_count("abcde")
    2
    >>> vowels_count("ACEDY")
    3
    """
    vowels = "aeiou"
    count = 0
    for i in range(len(s)):
        if s[i] in vowels:
            count += 1
        if s[i] == 'y' and i == len(s) - 1:
            count += 1
    return count

Response:
    vowels = "aeiou"
    count = 0
    for i in range(len(s)):
        if s[i] in vowels:
            count += 1
        if s[i] == 'y' and i == len(s) - 1:
            count += 1
    return count


Solution:
def circular_shift(x, shift):
    """Circular shift the digits of the integer x, shift the digits right by shift
    and return the result as a string.
    If shift > number of digits, return digits reversed.
    >>> circular_shift(12, 1)
    "21"
    >>> circular_shift(12, 2)
    "12"
    """
    x = str(x)
    if shift > len(x):
        return x[::-1]
    return x[-shift:] + x[:-shift]

Response:
    x = str(x)
    if shift > len(x):
        return x[::-1]
    return x[-shift:] + x[:-shift]


Solution:
def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    return sum(ord(c) for c in s if c.isupper())

Response: return sum(ord(c) for c in s if c.isupper())


Solution:
def fruit_distribution(s,n):
    """
    In this task, you will be given a string that represents a number of apples and oranges
    that are distributed in a basket of fruit this basket contains
    apples, oranges, and mango fruits. Given the string that represents the total number of
    the oranges and apples and an integer that represent the total number of the fruits
    in the basket return the number of the mango fruits in the basket.
    for examble:
    fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8
    fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2
    fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95
    fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19
    """
    # Your code here
    return n - int(s.split()[0]) - int(s.split()[3])

Response:
    # Your code here
    return n - int(s.split()[0]) - int(s.split()[3])


Solution:
def pluck(arr):
    """
    "Given an array representing a branch of a tree that has non-negative integer nodes
    your task is to pluck one of the nodes and return it.
    The plucked node should be the node with the smallest even value.
    If multiple nodes with the same smallest even value are found return the node that has smallest index.

    The plucked node should be returned in a list, [ smalest_value, its index ],
    If there are no even values or the given array is empty, return [].

    Example 1:
        Input: [4,2,3]
        Output: [2, 1]
        Explanation: 2 has the smallest even value, and 2 has the smallest index.

    Example 2:
        Input: [1,2,3]
        Output: [2, 1]
        Explanation: 2 has the smallest even value, and 2 has the smallest index.

    Example 3:
        Input: []
        Output: []

    Example 4:
        Input: [5, 0, 3, 0, 4, 2]
        Output: [0, 1]
        Explanation: 0 is the smallest value, but  there are two zeros,
                     so we will choose the first zero, which has the smallest index.

    Constraints:
        * 1 <= nodes.length <= 10000
        * 0 <= node.value
    """
    # Your code here
    even_values = [node for node in arr if node % 2 == 0]
    if not even_values:
        return []
    smallest_even_value = min(even_values)
    smallest_even_index = arr.index(smallest_even_value)
    return [smallest_even_value, smallest_even_index]

Response:
    # Your code here
    even_values = [node for node in arr if node % 2 == 0]
    if not even_values:
        return []
    smallest_even_value = min(even_values)
    smallest_even_index = arr.index(smallest_even_value)
    return [smallest_even_value, smallest_even_index]


Solution:
def search(lst):
    '''
    You are given a non-empty list of positive integers. Return the greatest integer that is greater than
    zero, and has a frequency greater than or equal to the value of the integer itself.
    The frequency of an integer is the number of times it appears in the list.
    If no such a value exist, return -1.
    Examples:
        search([4, 1, 2, 2, 3, 1]) == 2
        search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
        search([5, 5, 4, 4, 4]) == -1
    '''
    # Your code here
    pass

Response:
    # Your code here
    pass


Solution:
from typing import List

def filter_by_substring(strings: List[str], substring: str) -> List[str]:
    """ Filter an input list of strings only for ones that contain given substring
    >>> filter_by_substring([], 'a')
    []
    >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
    ['abc', 'bacd', 'array']
    """
    return [s for s in strings if substring in s]

Response: return [s for s in strings if substring in s]


Solution:
def strange_sort_list(lst):
    '''
    Given list of integers, return list in strange order.
    Strange sorting, is when you start with the minimum value,
    then maximum of the remaining integers, then minimum and so on.

    Examples:
    strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
    strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
    strange_sort_list([]) == []
    '''
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return lst
    if len(lst) == 2:
        return [lst[0], lst[1]]
    if len(lst) == 3:
        return [lst[0], lst[2], lst[1]]
    if len(lst) == 4:
        return [lst[0], lst[3], lst[1], lst[2]]
    if len(lst) == 5:
        return [lst[0], lst[4], lst[1], lst[3], lst[2]]
    if len(lst) == 6:
        return [lst[0], lst[5], lst[1], lst[4], lst[2], lst[3]]
    if len(lst) == 7:
        return [lst[0], lst[6], lst[1], lst[5], lst[2], lst[4], lst[3]]
    if len(lst) == 8:
        return [lst[0], lst[7], lst[1], lst[6], lst[2], lst[5], lst[3], lst[4]]
    if len(lst) == 9:
        return [lst[0], lst[8], lst[1], lst[7], lst[2], lst[6], lst[3], lst[5], lst[4]]
    if len(lst) == 10:
        return [lst[0], lst[9], lst[1], lst[8], lst[2], lst[7], lst[3], lst[6], lst[4], lst[5]]
    if len(lst) == 11:
        return [lst[0], lst[10], lst[1], lst[9], lst[2], lst[8], lst[3], lst[7], lst[4], lst[6], lst[5]]
    if len(lst) == 12:
        return [lst[0], lst[11], lst[1], lst[10], lst[2], lst[9], lst[3], lst[8], lst[4], lst[7], lst[5], lst[6]]
    if len(lst) == 13:
        return [lst[0], lst[12], lst[1], lst[11], lst[2], lst[10], lst[3], lst[9], lst[4], lst[8], lst[5], lst[7], lst[6]]
    if len(lst) == 14:
        return [lst[0], lst[13], lst[1], lst[12], lst[2], lst[11], lst[3], lst[10], lst[4], lst[9], lst[5], lst[8], lst[6], lst[7]]
    if len(lst) == 15:
        return [lst[0], lst[14], lst[1], lst[13], lst[2], lst[12], lst[3], lst[11], lst[4], lst[10], lst[5], lst[9], lst[6], lst[8], lst[7]]
    if len(lst) == 16:
        return [lst[0], lst[15], lst[1], lst[14], lst[2], lst[13], lst[3], lst[12], lst[4], lst[11], lst[5], lst[10], lst[6], lst[9], lst[7], lst[8]]
    if len(lst) == 17:
        return [lst[0], lst[16], lst[1], lst[15], lst[2], lst[14], lst[3], lst[13], lst[4], lst[12], lst[5], lst[11], lst[6], lst[10], lst[7], lst[9], lst[8]]
    if len(lst) == 18:
        return [lst[0], lst[17], lst[1], lst[16], lst[2], lst[15], lst[3], lst[14], lst[4], lst[13], lst[5], lst[12], lst[6], lst[11], lst[7], lst[10], lst[8], lst[9]]
    if len(lst) == 19:
        return [lst[0], lst[18], lst[1], lst[17], lst[2], lst[16], lst[3], lst[15], lst[4], lst[14], lst[5], lst[13], lst[6], lst[12], lst[7], lst[11], lst[8], lst[10], lst[9]]
    if len(lst) == 20:
        return [lst[0], lst[19], lst[1], lst[18], lst[2], lst[17], lst[3], lst[16], lst[4], lst[15], lst[5], lst[14], lst[6], lst[13], lst[7], lst[12], lst[8], lst[11], lst[9], lst[10]]
    if len(lst) == 21:
        return [lst[0], lst[20], lst[1], lst[19], lst[2], lst[18], lst[3], lst[17], lst[4], lst[16], lst[5], lst[15], lst[6], lst[14], lst[7], lst[13], lst[8], lst[12], lst[9], lst[11], lst[10]]
    if len(lst) == 22:
        return [lst[0], lst[21], lst[1], lst[20], lst[2], lst[19], lst[3], lst[18], lst[4], lst[17], lst[5], lst[16], lst[6], lst[15], lst[7], lst[14], lst[8], lst[13], lst[9], lst[12], lst[10], lst[11]]
    if len(lst) == 23:
        return [lst[0], lst[22], lst[1], lst[21], lst[2], lst[20], lst[3], lst[19], lst[4], lst[18], lst[5], lst[17], lst[6], lst[16], lst[7], lst[15], lst[8], lst[14], lst[9], lst[13], lst[10], lst[12], lst[11]]
    if len(lst) == 24:
        return [lst[0], lst[23], lst[1], lst[22], lst[2], lst[21], lst[3], lst[20], lst[4], lst[19], lst[5], lst[18], lst[6], lst[17], lst[7], lst[16], lst[8], lst[15], lst[9], lst[14], lst[10], lst[13], lst[11], lst[12]]
    if len(lst) == 25:
        return [lst[0], lst[24], lst[1], lst[23], lst[2], lst[22], lst[3], lst[21], lst[4], lst[20], lst[5], lst[19], lst[6], lst[18], lst[7], lst[17], lst[8], lst[16], lst[9], lst[15], lst[10], lst[14], lst[11], lst[13], lst[12]]
    if len(lst) == 26:
        return [lst[0], lst[25], lst[1], lst[24], lst[2], lst[23], lst[3], lst[22], lst[4], lst[21], lst[5], lst[20], lst[6], lst[19], lst[7], lst[18], lst[8], lst[17], lst[9], lst[16], lst[10], lst[15], lst[11], lst[14], lst[12], lst[13]]
    if len(lst) == 27:
        return [lst[0], lst[26], lst[1], lst[25], lst[2], lst[24], lst[3], lst[23], lst[4], lst[22], lst[5], lst[21], lst[6], lst[20], lst[7], lst[19], lst[8], lst[18], lst[9], lst[17], lst[10], lst[16], lst[11], lst[15], lst[12], lst[14], lst[13]]
    if len(lst) == 28:
        return [lst[0], lst[27], lst[1], lst[26], lst[2], lst[25], lst[3], lst[24], lst[4], lst[23], lst[5], lst[22], lst[6], lst[21], lst[7], lst[20], lst[8], lst[19], lst[9], lst[18], lst[10], lst[17], lst[11], lst[16], lst[12], lst[15], lst[13], lst[14]]
    if len(lst) == 29:
        return [lst[0], lst[28], lst[1], lst[27], lst[2], lst[26], lst[3], lst[25], lst[4], lst[24], lst[5], lst[23], lst[6], lst[22], lst[7], lst[21], lst[8], lst[20], lst[9], lst[19], lst[10], lst[18], lst[11], lst[17], lst[12], lst[16], lst[13], lst[15], lst[14]]
    if len(lst) == 30:
        return [lst[0], lst[29], lst[1], lst[28], lst[2], lst[27], lst[3], lst[26], lst[4], lst[25], lst[5], lst[24], lst[6], lst[23], lst[7], lst[22], lst[8], lst[21], lst[9], lst[20], lst[10], lst[19], lst[11], lst[18], lst[12], lst[17], lst[13], lst[16], lst[14], lst[15]]
    if len(lst) == 31:
        return [lst[0], lst[30], lst[1], lst[29], lst[2], lst[28], lst[3], lst[27], lst[4], lst[26], lst[5], lst[25], lst[6], lst[24], lst[7], lst[23], lst[8], lst[22], lst[9], lst[21], lst[10], lst[20], lst[11], lst[19], lst[12], lst[18], lst[13], lst[17], lst[14], lst[16], lst[15]]
    if len(lst) == 32:
        return [lst[0], lst[31], lst[1], lst[30], lst[2], lst[29], lst[3], lst[28], lst[4], lst[27], lst[5], lst[26], lst[6], lst[25], lst[7], lst[24], lst[8], lst[23], lst[9], lst[22], lst[10], lst[21], lst[11], lst[20], lst[12], lst[19], lst[13], lst[18], lst[14], lst[17], lst[15], lst[16]]
    if len(lst) == 33:
        return [lst[0], lst[32], lst[1], lst[31], lst[2], lst[30], lst[3], lst[29], lst[4], lst[28], lst[5], lst[27], lst[6], lst[26], lst[7], lst[25], lst[8], lst[24], lst[9], lst[23], lst[10], lst[22], lst[11], lst[21], lst[12], lst[20], lst[13], lst[19], lst[14], lst[18], lst[15], lst[17], lst[16]]
    if len(lst) == 34:
        return [lst[0], lst[33], lst[1], lst[32], lst[2], lst[31], lst[3], lst[30], lst[4], lst[29], lst[5], lst[28], lst[6], lst[27], lst[7], lst[26], lst[8], lst[25], lst[9], lst[24], lst[10], lst[23], lst[11], lst[22], lst[12], lst[21], lst[13], lst[20], lst[14], lst[19], lst[15], lst[18], lst[16], lst[17]]
    if len(lst) == 35:
        return [lst[0], lst[34], lst[1], lst[33], lst[2], lst[32], lst[3], lst[31], lst[4], lst[30], lst[5], lst[29], lst[6], lst[28], lst[7], lst[27], lst[8], lst[26], lst[9], lst[25], lst[10], lst[24], lst[11], lst[23], lst[12], lst[22], lst[13], lst[21], lst[14], lst[20], lst[15], lst[19], lst[16], lst[18], lst[17]]
    if len(lst) == 36:
        return [lst[0], lst[35], lst[1], lst[34], lst[2], lst[33], lst[3], lst[32], lst[4], lst[31], lst[5], lst[30], lst[6], lst[29], lst[7], lst[28], lst[8], lst[27], lst[9], lst[26], lst[10], lst[25], lst[11], lst[24], lst[12], lst[23], lst[13], lst[22], lst[14], lst[21], lst[15], lst[20], lst[16], lst[19], lst[17], lst[18]]
    if len(lst) == 37:
        return [lst[0], lst[36], lst[1], lst[35], lst[2], lst[34], lst[3], lst[33], lst[4], lst[32], lst[5], lst[31], lst[6], lst[30], lst[7], lst[29], lst[8], lst[28], lst[9], lst[27], lst[10], lst[26], lst[11], lst[25], lst[12], lst[24], lst[13], lst[23], lst[14], lst[22], lst[15], lst[21], lst[16], lst[20], lst[17], lst[19], lst[18]]
    if len(lst) == 38:
        return [lst[0], lst[37], lst[1], lst[36], lst[2], lst[35], lst[3], lst[34], lst[4], lst[33], lst[5], lst[32], lst[6], lst[31], lst[7], lst[30], lst[8], lst[29], lst[9], lst[28], lst[10], lst[27], lst[11], lst[26], lst[12], lst[25], lst[13], lst[24], lst[14], lst[23], lst[15], lst[22], lst[16], lst[21], lst[17], lst[20], lst[18], lst[19]]
    if len(lst) == 39:
        return [lst[0], lst[38], lst[1], lst[37], lst[2], lst[36], lst[3], lst[35], lst[4], lst[34], lst[5], lst[33], lst[6], lst[32], lst[7], lst[31], lst[8], lst[30], lst[9], lst[29], lst[10], lst[28], lst[11], lst[27], lst[12], lst[26], lst[13], lst[25], lst[14], lst[24], lst

Response:
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return lst
    if len(lst) == 2:
        return [lst[0], lst[1]]
    if len(lst) == 3:
        return [lst[0], lst[2], lst[1]]
    if len(lst) == 4:
        return [lst[0], lst[3], lst[1], lst[2]]
    if len(lst) == 5:
        return [lst[0], lst[4], lst[1], lst[3], lst[2]]
    if len(lst) == 6:
        return [lst[0], lst[5], lst[1], lst[4], lst[2], lst[3]]
    if len(lst) == 7:
        return [lst[0], lst[6], lst[1], lst[5], lst[2], lst[4], lst[3]]
    if len(lst) == 8:
        return [lst[0], lst[7], lst[1], lst[6], lst[2], lst[5], lst[3], lst[4]]
    if len(lst) == 9:
        return [lst[0], lst[8], lst[1], lst[7], lst[2], lst[6], lst[3], lst[5], lst[4]]
    if len(lst) == 10:
        return [lst[0], lst[9], lst[1], lst[8], lst[2], lst[7], lst[3], lst[6], lst[4], lst[5]]
    if len(lst) == 11:
        return [lst[0], lst[10], lst[1], lst[9], lst[2], lst[8], lst[3], lst[7], lst[4], lst[6], lst[5]]
    if len(lst) == 12:
        return [lst[0], lst[11], lst[1], lst[10], lst[2], lst[9], lst[3], lst[8], lst[4], lst[7], lst[5], lst[6]]
    if len(lst) == 13:
        return [lst[0], lst[12], lst[1], lst[11], lst[2], lst[10], lst[3], lst[9], lst[4], lst[8], lst[5], lst[7], lst[6]]
    if len(lst) == 14:
        return [lst[0], lst[13], lst[1], lst[12], lst[2], lst[11], lst[3], lst[10], lst[4], lst[9], lst[5], lst[8], lst[6], lst[7]]
    if len(lst) == 15:
        return [lst[0], lst[14], lst[1], lst[13], lst[2], lst[12], lst[3], lst[11], lst[4], lst[10], lst[5], lst[9], lst[6], lst[8], lst[7]]
    if len(lst) == 16:
        return [lst[0], lst[15], lst[1], lst[14], lst[2], lst[13], lst[3], lst[12], lst[4], lst[11], lst[5], lst[10], lst[6], lst[9], lst[7], lst[8]]
    if len(lst) == 17:
        return [lst[0], lst[16], lst[1], lst[15], lst[2], lst[14], lst[3], lst[13], lst[4], lst[12], lst[5], lst[11], lst[6], lst[10], lst[7], lst[9], lst[8]]
    if len(lst) == 18:
        return [lst[0], lst[17], lst[1], lst[16], lst[2], lst[15], lst[3], lst[14], lst[4], lst[13], lst[5], lst[12], lst[6], lst[11], lst[7], lst[10], lst[8], lst[9]]
    if len(lst) == 19:
        return [lst[0], lst[18], lst[1], lst[17], lst[2], lst[16], lst[3], lst[15], lst[4], lst[14], lst[5], lst[13], lst[6], lst[12], lst[7], lst[11], lst[8], lst[10], lst[9]]
    if len(lst) == 20:
        return [lst[0], lst[19], lst[1], lst[18], lst[2], lst[17], lst[3], lst[16], lst[4], lst[15], lst[5], lst[14], lst[6], lst[13], lst[7], lst[12], lst[8], lst[11], lst[9], lst[10]]
    if len(lst) == 21:
        return [lst[0], lst[20], lst[1], lst[19], lst[2], lst[18], lst[3], lst[17], lst[4], lst[16], lst[5], lst[15], lst[6], lst[14], lst[7], lst[13], lst[8], lst[12], lst[9], lst[11], lst[10]]
    if len(lst) == 22:
        return [lst[0], lst[21], lst[1], lst[20], lst[2], lst[19], lst[3], lst[18], lst[4], lst[17], lst[5], lst[16], lst[6], lst[15], lst[7], lst[14], lst[8], lst[13], lst[9], lst[12], lst[10], lst[11]]
    if len(lst) == 23:
        return [lst[0], lst[22], lst[1], lst[21], lst[2], lst[20], lst[3], lst[19], lst[4], lst[18], lst[5], lst[17], lst[6], lst[16], lst[7], lst[15], lst[8], lst[14], lst[9], lst[13], lst[10], lst[12], lst[11]]
    if len(lst) == 24:
        return [lst[0], lst[23], lst[1], lst[22], lst[2], lst[21], lst[3], lst[20], lst[4], lst[19], lst[5], lst[18], lst[6], lst[17], lst[7], lst[16], lst[8], lst[15], lst[9], lst[14], lst[10], lst[13], lst[11], lst[12]]
    if len(lst) == 25:
        return [lst[0], lst[24], lst[1], lst[23], lst[2], lst[22], lst[3], lst[21], lst[4], lst[20], lst[5], lst[19], lst[6], lst[18], lst[7], lst[17], lst[8], lst[16], lst[9], lst[15], lst[10], lst[14], lst[11], lst[13], lst[12]]
    if len(lst) == 26:
        return [lst[0], lst[25], lst[1], lst[24], lst[2], lst[23], lst[3], lst[22], lst[4], lst[21], lst[5], lst[20], lst[6], lst[19], lst[7], lst[18], lst[8], lst[17], lst[9], lst[16], lst[10], lst[15], lst[11], lst[14], lst[12], lst[13]]
    if len(lst) == 27:
        return [lst[0], lst[26], lst[1], lst[25], lst[2], lst[24], lst[3], lst[23], lst[4], lst[22], lst[5], lst[21], lst[6], lst[20], lst[7], lst[19], lst[8], lst[18], lst[9], lst[17], lst[10], lst[16], lst[11], lst[15], lst[12], lst[14], lst[13]]
    if len(lst) == 28:
        return [lst[0], lst[27], lst[1], lst[26], lst[2], lst[25], lst[3], lst[24], lst[4], lst[23], lst[5], lst[22], lst[6], lst[21], lst[7], lst[20], lst[8], lst[19], lst[9], lst[18], lst[10], lst[17], lst[11], lst[16], lst[12], lst[15], lst[13], lst[14]]
    if len(lst) == 29:
        return [lst[0], lst[28], lst[1], lst[27], lst[2], lst[26], lst[3], lst[25], lst[4], lst[24], lst[5], lst[23], lst[6], lst[22], lst[7], lst[21], lst[8], lst[20], lst[9], lst[19], lst[10], lst[18], lst[11], lst[17], lst[12], lst[16], lst[13], lst[15], lst[14]]
    if len(lst) == 30:
        return [lst[0], lst[29], lst[1], lst[28], lst[2], lst[27], lst[3], lst[26], lst[4], lst[25], lst[5], lst[24], lst[6], lst[23], lst[7], lst[22], lst[8], lst[21], lst[9], lst[20], lst[10], lst[19], lst[11], lst[18], lst[12], lst[17], lst[13], lst[16], lst[14], lst[15]]
    if len(lst) == 31:
        return [lst[0], lst[30], lst[1], lst[29], lst[2], lst[28], lst[3], lst[27], lst[4], lst[26], lst[5], lst[25], lst[6], lst[24], lst[7], lst[23], lst[8], lst[22], lst[9], lst[21], lst[10], lst[20], lst[11], lst[19], lst[12], lst[18], lst[13], lst[17], lst[14], lst[16], lst[15]]
    if len(lst) == 32:
        return [lst[0], lst[31], lst[1], lst[30], lst[2], lst[29], lst[3], lst[28], lst[4], lst[27], lst[5], lst[26], lst[6], lst[25], lst[7], lst[24], lst[8], lst[23], lst[9], lst[22], lst[10], lst[21], lst[11], lst[20], lst[12], lst[19], lst[13], lst[18], lst[14], lst[17], lst[15], lst[16]]
    if len(lst) == 33:
        return [lst[0], lst[32], lst[1], lst[31], lst[2], lst[30], lst[3], lst[29], lst[4], lst[28], lst[5], lst[27], lst[6], lst[26], lst[7], lst[25], lst[8], lst[24], lst[9], lst[23], lst[10], lst[22], lst[11], lst[21], lst[12], lst[20], lst[13], lst[19], lst[14], lst[18], lst[15], lst[17], lst[16]]
    if len(lst) == 34:
        return [lst[0], lst[33], lst[1], lst[32], lst[2], lst[31], lst[3], lst[30], lst[4], lst[29], lst[5], lst[28], lst[6], lst[27], lst[7], lst[26], lst[8], lst[25], lst[9], lst[24], lst[10], lst[23], lst[11], lst[22], lst[12], lst[21], lst[13], lst[20], lst[14], lst[19], lst[15], lst[18], lst[16], lst[17]]
    if len(lst) == 35:
        return [lst[0], lst[34], lst[1], lst[33], lst[2], lst[32], lst[3], lst[31], lst[4], lst[30], lst[5], lst[29], lst[6], lst[28], lst[7], lst[27], lst[8], lst[26], lst[9], lst[25], lst[10], lst[24], lst[11], lst[23], lst[12], lst[22], lst[13], lst[21], lst[14], lst[20], lst[15], lst[19], lst[16], lst[18], lst[17]]
    if len(lst) == 36:
        return [lst[0], lst[35], lst[1], lst[34], lst[2], lst[33], lst[3], lst[32], lst[4], lst[31], lst[5], lst[30], lst[6], lst[29], lst[7], lst[28], lst[8], lst[27], lst[9], lst[26], lst[10], lst[25], lst[11], lst[24], lst[12], lst[23], lst[13], lst[22], lst[14], lst[21], lst[15], lst[20], lst[16], lst[19], lst[17], lst[18]]
    if len(lst) == 37:
        return [lst[0], lst[36], lst[1], lst[35], lst[2], lst[34], lst[3], lst[33], lst[4], lst[32], lst[5], lst[31], lst[6], lst[30], lst[7], lst[29], lst[8], lst[28], lst[9], lst[27], lst[10], lst[26], lst[11], lst[25], lst[12], lst[24], lst[13], lst[23], lst[14], lst[22], lst[15], lst[21], lst[16], lst[20], lst[17], lst[19], lst[18]]
    if len(lst) == 38:
        return [lst[0], lst[37], lst[1], lst[36], lst[2], lst[35], lst[3], lst[34], lst[4], lst[33], lst[5], lst[32], lst[6], lst[31], lst[7], lst[30], lst[8], lst[29], lst[9], lst[28], lst[10], lst[27], lst[11], lst[26], lst[12], lst[25], lst[13], lst[24], lst[14], lst[23], lst[15], lst[22], lst[16], lst[21], lst[17], lst[20], lst[18], lst[19]]
    if len(lst) == 39:
        return [lst[0], lst[38], lst[1], lst[37], lst[2], lst[36], lst[3], lst[35], lst[4], lst[34], lst[5], lst[33], lst[6], lst[32], lst[7], lst[31], lst[8], lst[30], lst[9], lst[29], lst[10], lst[28], lst[11], lst[27], lst[12], lst[26], lst[13], lst[25], lst[14], lst[24], lst


Solution:
def triangle_area(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return the area of
    the triangle rounded to 2 decimal points if the three sides form a valid triangle.
    Otherwise return -1
    Three sides make a valid triangle when the sum of any two sides is greater
    than the third side.
    Example:
    triangle_area(3, 4, 5) == 6.00
    triangle_area(1, 2, 10) == -1
    '''
    if a + b > c and a + c > b and b + c > a:
        s = (a + b + c) / 2
        area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
        return round(area, 2)
    else:
        return -1

Response:
    if a + b > c and a + c > b and b + c > a:
        s = (a + b + c) / 2
        area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
        return round(area, 2)
    else:
        return -1


Solution:
def will_it_fly(q,w):
    '''
    Write a function that returns True if the object q will fly, and False otherwise.
    The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.

    Example:
    will_it_fly([1, 2], 5) ➞ False
    # 1+2 is less than the maximum possible weight, but it's unbalanced.

    will_it_fly([3, 2, 3], 1) ➞ False
    # it's balanced, but 3+2+3 is more than the maximum possible weight.

    will_it_fly([3, 2, 3], 9) ➞ True
    # 3+2+3 is less than the maximum possible weight, and it's balanced.

    will_it_fly([3], 5) ➞ True
    # 3 is less than the maximum possible weight, and it's balanced.
    '''
    return q == q[::-1] and sum(q) <= w

Response: return q == q[::-1] and sum(q) <= w


Solution:
def smallest_change(arr):
    """
    Given an array arr of integers, find the minimum number of elements that
    need to be changed to make the array palindromic. A palindromic array is an array that
    is read the same backwards and forwards. In one change, you can change one element to any other element.

    For example:
    smallest_change([1,2,3,5,4,7,9,6]) == 4
    smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
    smallest_change([1, 2, 3, 2, 1]) == 0
    """
    return sum(1 for a, b in zip(arr, arr[::-1]) if a != b) // 2

Response: return sum(1 for a, b in zip(arr, arr[::-1]) if a != b) // 2


Solution:
def total_match(lst1, lst2):
    '''
    Write a function that accepts two lists of strings and returns the list that has
    total number of chars in the all strings of the list less than the other list.

    if the two lists have the same number of chars, return the first list.

    Examples
    total_match([], []) ➞ []
    total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
    total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
    total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
    total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
    '''
    if sum(len(s) for s in lst1) < sum(len(s) for s in lst2):
        return lst1
    elif sum(len(s) for s in lst1) > sum(len(s) for s in lst2):
        return lst2
    else:
        return lst1

Response:
    if sum(len(s) for s in lst1) < sum(len(s) for s in lst2):
        return lst1
    elif sum(len(s) for s in lst1) > sum(len(s) for s in lst2):
        return lst2
    else:
        return lst1


Solution:
def is_multiply_prime(a):
    """Write a function that returns true if the given number is the multiplication of 3 prime numbers
    and false otherwise.
    Knowing that (a) is less then 100.
    Example:
    is_multiply_prime(30) == True
    30 = 2 * 3 * 5
    """
    if a < 2:
        return False
    for i in range(2, int(a**0.5) + 1):
        if a % i == 0:
            return False
    return True

Response:
    if a < 2:
        return False
    for i in range(2, int(a**0.5) + 1):
        if a % i == 0:
            return False
    return True


Solution:
def is_simple_power(x, n):
    """Your task is to write a function that returns true if a number x is a simple
    power of n and false in other cases.
    x is a simple power of n if n**int=x
    For example:
    is_simple_power(1, 4) => true
    is_simple_power(2, 2) => true
    is_simple_power(8, 2) => true
    is_simple_power(3, 2) => false
    is_simple_power(3, 1) => false
    is_simple_power(5, 3) => false
    """
    if n == 1:
        return x == 1
    if n == 0:
        return x == 0
    if x == 1:
        return True
    if x < 1:
        return False
    while x % n == 0:
        x = x // n
    return x == 1

Response:
    if n == 1:
        return x == 1
    if n == 0:
        return x == 0
    if x == 1:
        return True
    if x < 1:
        return False
    while x % n == 0:
        x = x // n
    return x == 1


Solution:
def iscube(a):
    '''
    Write a function that takes an integer a and returns True
    if this ingeger is a cube of some integer number.
    Note: you may assume the input is always valid.
    Examples:
    iscube(1) ==> True
    iscube(2) ==> False
    iscube(-1) ==> True
    iscube(64) ==> True
    iscube(0) ==> True
    iscube(180) ==> False
    '''
    return a == int(a**(1/3))**3

Response: return a == int(a**(1/3))**3