http://codingbat.com/prob/p171022