The solution you're likely to do is probably going to work regardless of what function you're given, and if it isn't, changing it to do that is a one liner. So what I don't understand is why not go straight to that.
In fact, learning to do it for any function would teach you a lesson about abstraction, a very important concept in computer science.