Created
September 18, 2012 16:08
-
-
Save sathish316/3743978 to your computer and use it in GitHub Desktop.
Alphametric solver golf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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