problem 018 solving