Ideal solution for problem 6