In fact, I forgot it's OK to run off the end of an Array in ruby :-) So 
the inner loop can simplify to this:

    j += 1 while src[j+1] == src[j].sub(/\d+/) { $&.succ }
-- 
Posted via http://www.ruby-forum.com/.