This is so true. It's easy to get stubborn and not want the problem to defeat you, so you stick at it for hours, only to wake up the next day and the solution literally just pops into your head. Also, the other points people have made about talking the problem over OUT LOUD, with either a person or by yourself. That works wonders too. Something about being forced to express the problem clearly - such that someone else can understand where you're at - frequently unblocks the issue in your mind and the solution presents itself.
"And when I have understanding of computers, I shall be the Supreme Being!"