Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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