| 1 |
/*** |
| 2 |
--- !Test |
| 3 |
solvers: [chuffed] |
| 4 |
expected: |
| 5 |
- !Result |
| 6 |
solution: !Solution |
| 7 |
q: [1, 7, 4, 6, 8, 2, 5, 3] |
| 8 |
- !Result |
| 9 |
solution: !Solution |
| 10 |
q: [1, 7, 5, 8, 2, 4, 6, 3] |
| 11 |
***/ |
| 12 |
|
| 13 |
int: n = 8; |
| 14 |
|
| 15 |
array [1..n] of var 1..n: q; |
| 16 |
|
| 17 |
predicate |
| 18 |
noattack(int: i, int: j, var int: qi, var int: qj) = |
| 19 |
qi != qj /\ |
| 20 |
qi + i != qj + j /\ |
| 21 |
qi - i != qj - j; |
| 22 |
|
| 23 |
constraint |
| 24 |
forall (i in 1..n, j in i+1..n) ( |
| 25 |
noattack(i, j, q[i], q[j]) |
| 26 |
); |
| 27 |
|
| 28 |
solve :: |
| 29 |
int_search( |
| 30 |
q, |
| 31 |
anti_first_fail, |
| 32 |
indomain, |
| 33 |
complete |
| 34 |
) |
| 35 |
satisfy; |
| 36 |
|
| 37 |
output [ show(q) ++ "\n" ]; |