completed problem 12 - though with poor brute force solution