http://codingbat.com/prob/p186672