Both. I program things I enjoy for fun, and things I.. enjoy less don't necessarily enjoy as much, for work.
It has its ups and downs though, when I was younger I would often take 6 month breaks from programming to do other stuff, and then spend another 6 months spending a lot of my time programming, my lifestyle is no longer compatible with this so I occasionally get burnt out these days, but I still have fun when I program, most of the time. The first few months I started programming (11 or so) were really, really exciting. I realise it may be a bit harder to be passionate about a recently picked up hobby when you start older and are more critical/cynical towards new things, but if you veritably don't get any enjoyment out of programming, ever, maybe it just isn't the hobby for you - not everyone can like everything.
In any case I don't think there is any "method" to enjoy programming. It's like any other hobby, you do it because you are happy doing it and find it challenging, exciting, relaxing, whatever your motivation is. If your motivation is "it helps me solve computational problems", that's perfectly fine too, it means you see programming as more of a tool than, for example, a creative endeavour, though it may no longer qualify as a hobby if you actually find it tedious, but just as a miscellaneous skill