Ad
Fundamentals

Billy likes to keep all his number in an jar, however there's one special one that he likes to keep at the top of it. It turns out that Billy has accidentaly mixed up his jar, and he can't find his special number!

You must return a new array in which his special number is the first element. The arguments given to the function are as follows:

jar - All of Billy's numbers.
special - Billy's special number.

All original numbers in the resulting array must remain, it's only the order that's different.

If the array is empty or null, return nil, None, or null. You can assume special is in the array.

def find_special(jar, special):
    # initial solution
    if jar != None and jar != []:
        for i in range(len(jar)):
            if jar[i] == special:
                jar.insert(0,jar.pop(i))
                break
        return jar
    return None