Career Cup problem solutions in Python