Skip to content

Instantly share code, notes, and snippets.

@andersr
Created October 7, 2013 13:40
Show Gist options
  • Save andersr/6868214 to your computer and use it in GitHub Desktop.
Save andersr/6868214 to your computer and use it in GitHub Desktop.
Anagram detector
class Anagram
attr_accessor :candidate, :list
def initialize(candidate)
@candidate = candidate
@list = list
end
def match(list)
list.select do |item|
item.bytes.inject(:+) == candidate.bytes.inject(:+)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment