http://codingbat.com/prob/p224787