Solution for Problem 7

Credit where credit is due.

http://stackoverflow.com/a/1072205