• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest May 24th, 2018 1,089 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %  МОРЕ   more
2. %+ШТОРМ  storm
3. %АВАРИЯ avariy
4.
5. var 0..9: m;
6. var 0..9: o;
7. var 0..9: r;
8. var 0..9: e;
9. var 0..9: s;
10. var 0..9: t;
11. var 0..9: a;
12. var 0..9: v;
13. var 0..9: i;
14. var 0..9: y;
15.
16. var 0..1: c1;
17. var 0..1: c2;
18. var 0..1: c3;
19. var 0..1: c4;
20. var 0..1: c5;
21.
22. constraint card({m,o,r,e,s,t,a,v,i,y}) = 10; % different digits
23.
24. predicate sum_with_carry(var 0..9:s1,var 0..9:s2, var 0..1:carry_in, var 0..9:res, var 0..1: carry_out) =
25.   ((s1+s2+carry_in) mod 10 = res) /\ ((s1+s2+carry_in) div 10 = carry_out);
26.
27. constraint sum_with_carry(e,m,0,y,c1);
28. constraint sum_with_carry(r,r,c1,i,c2);
29. constraint sum_with_carry(o,o,c2,r,c3);
30. constraint sum_with_carry(m,t,c3,a,c4);
31. constraint sum_with_carry(s,0,c4,v,c5);
32. constraint c5 = a;
33. constraint a != 0;
34.
35. solve satisfy;
36.
37. output ["  \(m)\(o)\(r)\(e)\n+\(s)\(t)\(o)\(r)\(m)\n\(a)\(v)\(a)\(r)\(i)\(y)\n"];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top