Skip to content

Instantly share code, notes, and snippets.

@sathish316
Created September 18, 2012 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sathish316/3743978 to your computer and use it in GitHub Desktop.
Save sathish316/3743978 to your computer and use it in GitHub Desktop.
Alphametric solver golf
s=->(e){c=e.scan(/\w/).uniq;('0'..'9').to_a.permutation(c.size).each{|p|o=c.zip(p).inject(e){|e,d|e.gsub(*d)};p o if o !~/\b0/&&eval(o)}}
s.("SEND + MORE == MONEY")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment