fork download
  1. (0..9).to_a.permutation(8) do |s,e,n,d,m,o,r,y|
  2. next if s == 0 or m == 0
  3. send = s * 1000 + e * 100 + n * 10 + d
  4. more = m * 1000 + o * 100 + r * 10 + e
  5. money = m * 10000 + o * 1000 + n * 100 + e * 10 + y
  6. puts "#{send} + #{more} = #{money}" if send + more == money
  7. end
  8.  
Success #stdin #stdout 2.03s 7572KB
stdin
Standard input is empty
stdout
9567 + 1085 = 10652