add test and code for Problem 12