I often fall asleep with my mind digging at a coding challenge, working on trying to figure out the ins and outs of the problem, and often, when I wake up, I know the answer. Sometimes I remember dreaming about it, and sometimes my brain just needed the time to organize and collate.
Back when I was like nine, I decided one summer to open a nightcrawler business. Fishing is a thing around here, and we lived on a horse farm. Horse manure is great for producing two things: stink and worms. So there I was. After four days of digging worms, packing them in lots of 25 (in used yogurt containers), refrigerating them, spreading the piles and studying the care and feeding of worms… I had a solid WEEK of dreaming nothing but a writhing mass of worms.
Let me tell you, after THAT stuff… I LOVE my coding dreams.