Add solution to problem #24

Added solution to problem #24