Added solution to #5.