Coderbyte String Reduction Hackerrank Solution