I think some of the most amazing 10-20 liners of code I've written, I wrote in my dreams. Made a major effort to memorize them, and then implemented once I got to a computer.
Related to this, it's amazing when your away from the computer and not really engaged in anything you can think back to a piece of code that was giving you trouble and come up with a fix you couldn't think of while working at a screen.
Or more surprising, twigging a bug in some code you previously considered fine :)
Reminds me of the other day, picking a random transaction and following it's results across about 5 database tables, turned out that one network had a passthrough data size limit of 50 characters. Don't think this would have shown itself for a long time had I not randomly decided to follow the logic path.
Once in a fevered dream (literally) I reimplemented Puyo Puyo in elisp as a derived mode of M-x tetris. It was a blast.