solution for problem24