Added solution to #6.