30 here, and I'll throw my hat in the "depends on the task" ring. If I'm writing a code from scratch I can go for hours. The creation process is thoroughly enjoyable to me. It's almost a dopamine rush when you figure out a creative and efficient way to perform a task.
On the other hand, troubleshooting or editing someone else's code is definitely less enjoyable. The "ah ha!" moments are nice, but usually I end up just re-writing large chunks to do what I want in a way I consider more straight forward. The way I see it, if I can't come in and watch the machine and understand the process after a few hours, you didn't write the code very well and it needs to be re-done anyway.
On the other hand, troubleshooting or editing someone else's code is definitely less enjoyable. The "ah ha!" moments are nice, but usually I end up just re-writing large chunks to do what I want in a way I consider more straight forward. The way I see it, if I can't come in and watch the machine and understand the process after a few hours, you didn't write the code very well and it needs to be re-done anyway.