I had a similar experience while in college, although not as dramatic! While studying CS I was working on problems every night late into the night. I came a across a issue I could not figure out, and went to sleep frustrated. That night I had a dream where a very specific solution was told to me(a voice with text) and it was in a way I had never thought of. I tried it out the next day when I woke up and it worked. It always freaked me out as I don't know how that solution was given to me, my assumption is maybe the subconscious is more powerful than we thought in terms of reasoning.