Take a Break
It's amazing how many times I can figure problems out just by walking away from them. Can't figure out why my code doesn't compile? Go fill the water bottle. Can't get that automated test to pass? Take a bathroom break. In fact, you'll often see me wandering around campus in the afternoons with a blank stare on my face trying to figure something out. A change of scenery and a step back from the problem helps to unblock me. In college, it seemed that I would figure out a lot of homework problems in the shower. I've even been known to wake up in the middle of the night with an answer to a math problem. I'd scribble it down and fall back to sleep to deal with it in the morning. Whatever you do to step back from the problem, make sure you have something to take notes with. There's nothing more frustrating than solving a problem and forgetting the solution by the time you get back to your desk.
Next time you're stuck, go for a walk. You might be surprised at what pops into your mind when you least expect it.