solution to a programming challenge