I have found a word for it! That phenomenon for solving a programming problem when not even thinking about it. I had this happen lots of times during my recent degree. I would be struggling with a problem for hours while sitting in front of a computer. Only after stepping away and doing something completely unrelated (like taking the tube, or taking a shower) the answer would hit me. Apparently this is called Incubation (or the Eureka Effect), as an article labels it that I found today on HackerNews. It discusses the difficulty with counting exactly the numbers of hours worked while coding. It mentions the concept of a programmer getting into the ‘zone’ or ‘flow’ before being at her most productive. It’s like a required warm up period that happens, and when a programmer is interrupted, it has to start again and thereby impedes efficiency.
Back to incubation, this linked article mentions that this has also been found to happen in rats! I have wondered if there was a way to improve this kind of process, as it’s highly unreliable and just feels like a happy coincidental brain connection that could be easily missed. For (frustrating) lack of better understanding of how the human brain works, this looks to remain a mystery for a while yet. However, if you find a way, please let me know! :)