solved problem 493 and wrote up the solution