Add solution to problem #9

Added solution to problem #9