naive solution to 14, prememoization