http://codingbat.com/prob/p185176