Whenever you face a problem, take a break. Sleep. Clean your room. Do anything except work on the problem.
This takes your brain into its “diffuse mode” — this mode works on the things you have been focusing on in the background. Come back to the problem later.