After all, most writing is done away from the typewriter, away from the desk. I’d say it occurs in the quiet, silent moments, while you’re walking or shaving or playing a game or whatever, or even talking to someone you’re not vitally interested in. You’re working, your mind is working, on this problem in the back of your head. So, when you get to the machine it’s a mere matter of transfer.
Your best thoughts occur when you’re not working, when your mind and body step away from your desk. But even in those dull moments your mind is working. And then you just copy-paste your thoughts at the computer. The hard part is the editing.