I've also written code which didn't work at all, and then spent days debugging it. But I've learned that I'm really bad at debugging code, so instead I take the time to plan out what my code is doing so that I can get it right the first time.
Now, I don't know anyone who measures code in "pages". This isn't a good metric when most projects are made up of multiple files. It's as good as measuring productivity in LOC.
And then there are days I've hacked through some muddy recursive reference problem in a few lines of code, just knowing the solution should be obvious but not seeing it.
The good moments make me happy to program; the bad ones make me think about becoming a lumberjack instead.
The first draft is NEVER perfect.