At uni on an advanced algorithms class we had a take-home exam with 6 problems for 3 days or so.
On Saturday I already had some ideas for most problems, but there was one that I didn't knew how to approach and stayed a bit late thinking about it.
On Sunday morning I woke up really exited as I solved the damn problem. I immediately knew that probably like dreams, the memory was fragile, so I rushed to my desk to write the sketch for the idea, which after grabbing coffee turned into my solution to it.
There's no way I didn't spent my sleep thinking about it and solving it, likely around the last sleep cycle when I woke up.