import timeit

def check_password(pa, pb):
  # we can find the precise length of the password
  # by timing how much it take to return depending
  # on the given password length.
  if len(pa) != len(pb):
    return False

  # we can guess the password, one character a time, by
  # timing each character guess, if the execution takes
  # longer time, we went one iteration further and found the correct
  # character.
  for a, b in zip(pa, pb):
    if a != b:
      return False

  return True

print("timing password length:")
print(timeit.timeit('check_password("0123456789", "xxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "xxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "xxxxxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "xxxxxxxxxxxxx")', globals=globals()))

print("timing amount of correct characters:")
print(timeit.timeit('check_password("0123456789", "xxxxxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "0xxxxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "01xxxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "012xxxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "0123xxxxxx")', globals=globals()))
print(timeit.timeit('check_password("0123456789", "01234xxxxx")', globals=globals()))