Add solution to problem #6

Added solution to the problem #6