Distancing oneself from a difficult problem

I fixed a silly bug just now and wrote working code that can pin multiple virtual CPUs to the physical CPUs.

Identifying the bug in my code was another classic example of how I needed to distance myself from the problem. Instead of staying up late into the night (late is now 09:30 pm on a weekday) and fixating on debugging the code, I slammed my laptop lid shut and whispered under my breath that I would revisit the problem in the early morning, reassuring myself that stepping away from the problem (in this case, sleeping on it) is often the best — and sometimes only — way to solve a difficult problem.

There have been countless number of times where I would fixate on a particular piece of code for hours, reading and rereading every line in code, stepping through each instruction with the debugger, only to grow more frustrated that my perseverance failed to pay off. Only when I let the problem simmer in the back of my brain and return to the screen with a fresh new pair of eyes am I able to fix the problem.

How about you? Do you find distancing yourself from a hard or difficult problem is sometimes the only way to solve it?

Pnning virtual CPU to physical CPU