When I get stuck on a problem, I have this mental space/process I engage where I tell myself I'm going to let my subconscious work it out while I focus on other things. Often I do this before a nap or bed. I still do this, and have been doing it for as long as I can remember. It works more often than not.