|Perl: the Markov chain saw|
What you have there is a classic example of the problem solving abilities of your subconcious mind. The human mind has two modes of operation. A rapid fire immediate mode and a long-term, slow-burn subconcious mode.
While the second is ultimately the best problem solver, our society cultures and rewards the first. People are rewarded for quick snap decisions, and punished for "goofing off" when what they are really doing is letting the subconcious weigh facts and solve problems.
Einstein used to spend days in his office, staring at the window, letting his subconcious work.
There is a great book on this subject: Hare Brain, Tortoise Mind : How Intelligence Increases When You Think Less. I highly recommend it.
I have been relying on my tortoise mind for years. Whenever I have a problem that I can't solve, I take a shower. I get the water really hot and shut down my hare brain. Chances are by the end of the shower I have solved the problem with a flash of inspiration. I'm standing there thinking of nothing, or thinking of something completely unrelated to the problem and bam the answer is there.
"Pain heals. Chicks dig scars. Glory lasts forever."