One of the things that makes all the difference for me as a programmer is how I spend my break time.
I typically code for 40-60 minutes before I start losing energy and focus. After this time, I need to stop thinking about the programming for a second.
Sometimes I check my phone. Sometimes I check Facebook. On very bad days I check Instagram. I often send text messages.
On good days though, I don't do any of that. On good days I go make some tea, while letting my mind cool off a little bit, but I stay focused.
I'm not necessarily solving the problem anymore, but I don't let my mind wander off. I don't open news website, I don't open Twitter.
When I come back to problem after a break like this, I typically continue where I left off.