solutions/ruby/anagram_detection.rb
# return true if string a and string b are anagrams
return true if string a and string b are anagrams
return true if string a and string b are anagrams
def anagram?(a, b)
  char_count = proc { |hsh, c|
    hsh[c] ||= 0
    hsh[c] += 1
    hsh
  }
  if a.each_char.reduce({}, &char_count) == b.each_char.reduce({}, &char_count)
    true
  else
    false
  end
end
def anagram? ( a , b ) char_count = proc { | hsh , c | hsh [ c ] ||= 0 hsh [ c ] += 1 hsh } if a . each_char . reduce ( { } , & char_count ) == b . each_char . reduce ( { } , & char_count ) true else false end end
return true if string a and string b are anagrams
return true if string a and string b are anagrams
a
<not_specific>
b
<not_specific>