solve problem 17 but solving problem 18