My solution to a programming challenge