cheating version using a solver