-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
5x5_puzzle.fzn
31 lines (31 loc) · 2.83 KB
/
5x5_puzzle.fzn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var 0..25: INT____00001 :: is_defined_var :: var_is_introduced;
array [1..25] of var 0..5: d;
var 0..25: the_sum :: output_var = INT____00001;
array [1..25] of var 0..1: x :: output_array([1..5, 1..5]);
constraint int_lin_eq([2, -1, -1, -1], [d[1], x[1], x[2], x[6]], -1);
constraint int_lin_eq([2, -1, -1, -1], [d[5], x[4], x[5], x[10]], -1);
constraint int_lin_eq([2, -1, -1, -1], [d[21], x[16], x[21], x[22]], -1);
constraint int_lin_eq([2, -1, -1, -1], [d[25], x[20], x[24], x[25]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[2], x[1], x[2], x[3], x[7]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[3], x[2], x[3], x[4], x[8]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[4], x[3], x[4], x[5], x[9]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[6], x[1], x[6], x[7], x[11]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[10], x[5], x[9], x[10], x[15]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[11], x[6], x[11], x[12], x[16]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[15], x[10], x[14], x[15], x[20]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[16], x[11], x[16], x[17], x[21]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[20], x[15], x[19], x[20], x[25]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[22], x[17], x[21], x[22], x[23]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[23], x[18], x[22], x[23], x[24]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1], [d[24], x[19], x[23], x[24], x[25]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[7], x[2], x[6], x[7], x[8], x[12]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[8], x[3], x[7], x[8], x[9], x[13]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[9], x[4], x[8], x[9], x[10], x[14]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[12], x[7], x[11], x[12], x[13], x[17]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[13], x[8], x[12], x[13], x[14], x[18]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[14], x[9], x[13], x[14], x[15], x[19]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[17], x[12], x[16], x[17], x[18], x[22]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[18], x[13], x[17], x[18], x[19], x[23]], -1);
constraint int_lin_eq([2, -1, -1, -1, -1, -1], [d[19], x[14], x[18], x[19], x[20], x[24]], -1);
constraint int_lin_eq([-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [INT____00001, x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25]], 0) :: defines_var(INT____00001);
solve :: int_search([x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24], x[25]], first_fail, indomain_min, complete) minimize INT____00001;