Add more efficient solution for problem 23.