simple solution for problem 12 plus some extra code