def game(s1, s2, move_counter): if move_counter == 2 and s1 + s2 >= 59: return 0 elif move_counter == 3 and s1 + s2 >= 59: return 1 elif move_counter == 4 and s1 + s2 >= 59: return 0 elif move_counter == 5 and s1 + s2 >= 59: return 1 elif move_counter == 5 and s1 + s2 < 59: return 0 else: if move_counter % 2 != 0: return game(s1 + 1, s2, move_counter + 1) and game(s1 * 2, s2, move_counter + 1) and game(s1, s2 + 1, move_counter + 1) and game(s1, s2 * 2, move_counter + 1) else: if move_counter == 2: return ((game(s1 + 1, s2, move_counter + 1) != game(s1 * 2, s2, move_counter + 1)) != game(s1, s2 + 1, move_counter + 1)) != game(s1, s2 * 2, move_counter + 1) else: return game(s1 + 1, s2, move_counter + 1) or game(s1 * 2, s2, move_counter + 1) or game(s1, s2 + 1, move_counter + 1) or game(s1, s2 * 2, move_counter + 1)
final = [] for s2 in range(1,54): if game(5, s2, 1) == 1: final.append(s2) print(min(final)) |