Skip to content

Instantly share code, notes, and snippets.

@vinbarnes
Created February 7, 2021 08:01
Embed
What would you like to do?
def counts(str)
str.chars.inject([]) do |memo, e|
if memo.last && memo.last[0].eql?(e)
memo.last[1] += 1
else
memo << [e, 1]
end
memo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment