solution for problem12.