Skip to content

Instantly share code, notes, and snippets.

/a.rb Secret

Created December 4, 2012 23:35
Show Gist options
  • Save anonymous/6a760124b4d36639bf90 to your computer and use it in GitHub Desktop.
Save anonymous/6a760124b4d36639bf90 to your computer and use it in GitHub Desktop.
def decompose_string(str)
str.chars.each_cons(2).map(&:join)
end
# => nil
in_common = decompose_string("abc") & decompose_string("abc")
# => ["ab", "bc"]
in_common.count
# => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment