http://codingbat.com/prob/p289078