Adding solution to problem 1. Solutions probably need a more generic return type, but that can come later...