"""The Genie lock demonstrates why functions can be useful."""

from MyLocks import MyLock


lock = MyLock.select(4)


def unlock(number):
    lock.tell_joke()
    lock.give_money()
    return lock.guess(number)


# This is intentionally a simple first attempt. Students can replace it
# with a better search after trying the binary_search example.
number = 0
while unlock(number) != "unlocked":
    number = number + 1

