cardel

Modelo send + more = money

Jun 18th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. % SEND+MORE = MONEY
  2. include "alldifferent.mzn";
  3. var 1..9: S; var 1..9: M;
  4. var 0..9: E; var 0..9: N; var 0..9: D; var 0..9: O;var 0..9: R; var 0..9: Y;
  5.  
  6. constraint 1000*S+100*E+10*N+ D + 1000*M+100*O+10*R+E = 10000*M+1000*O+100*N+10*E+Y;
  7. constraint alldifferent([S,M,E,N,D,R,O,Y]);
  8. solve satisfy;
  9.  
  10. output ["S=\(S)\t M=\(M)\t E=\(E)\n",
  11. "N=\(N)\t D=\(D)\t O=\(O)\t R=\(R)\t Y=\(Y)\n", "\n"];
Add Comment
Please, Sign In to add comment