Programming challenge solution.