Skip to content

Instantly share code, notes, and snippets.

@sholden
Created February 1, 2018 17:11
Show Gist options
  • Save sholden/5f36a33561a3fbcc74d469823f444e7f to your computer and use it in GitHub Desktop.
Save sholden/5f36a33561a3fbcc74d469823f444e7f to your computer and use it in GitHub Desktop.
require 'prime'
module Words
CTP = Hash[('a'..'z').zip(Prime)].merge!(Hash[('A'..'Z').zip(Prime)])
def self.anagrams?(*words)
words.map{|w| w.to_s.chars.map{|c| CTP[c]}.inject(&:*)}.uniq.one?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment