I've found that Test Driven Development is particularly beneficial when tired. The test suite reduces the size of the program that I need to keep in short term memory, and the quick test-solve-refactor cycle keeps me focused. Later, when more awake, I review what I did by quickly scanning the test suite and looking for any obvious omissions.
The above isn't necessary an argument for TDD, but I think you might find it useful to try to view building a test suite and building your codebase as complementary activities rather than exclusive ones. If you use them together, the entire process becomes less difficult, and code in your test suite is just as valuable as anywhere else.