Problem 12: complete slow (~1 min) solution.