problem 14 `performace improved by adding memo.`