I am rarely happier than when spending entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.
If you really want to understand something, the best way is to try and explain it to someone else.
That forces you to sort it out in your mind. And the more slow and dim-witted your pupil, the more you have to break things down into more and more simple ideas. And that's really the essence of programming.
By the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've learned something about it yourself.