Solution for Problem #24