I keep a note pad on my nightstand because me too, when I can not figure out a way to go about solving a coding problem, thoughts/answers happen right as I am going to sleep, or in the morning. Amazing how the mind keeps working on things even while we are sleeping.

Thomas Edison used to work on his experiments night and day until he would almost pass out. He would then go to sleep in a small room hidden under the staircase where no one could find him. Some people might think that is kind of strange, but some of us programmers can relate to it.