Simple coding exercise on algorithm.