problem 6 solved using 3 approaches.