The solution to a little programming task