problem 17 done, could be more efficient