I'm thinking to translate string to an array like this:
"aaabbccccdadd" => [ [a, 3], [b, 2], [c, 4], [d, 1], [a, 1], [d, 2] ]

this is my code:

ary = []
"aaabbccccdadd".scan(/((.)\2*)/){ |a,b| ary << [b, a.size] }

ary #=> [["a", 3], ["b", 2], ["c", 4], ["d", 1], ["a", 1], ["d", 2]]

But, I wonder if there are more effective or beautiful solution than
this.
How do you think?

-- 
Posted via http://www.ruby-forum.com/.