Last active
June 8, 2019 22:57
-
-
Save abeham/5ee74fb07dfebec62ec76a0b7380e3ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "globals.mzn"; | |
int: TOTAL = 49; | |
array[1..3,1..3] of var 1..TOTAL-3: x; | |
constraint x[2,2] = 21; | |
constraint alldifferent([x[i,j] | i in 1..3, j in 1..3]); | |
constraint forall(i in 1..3)(sum(j in 1..3)(x[i,j]) = TOTAL); | |
constraint forall(j in 1..3)(sum(i in 1..3)(x[i,j]) = TOTAL); | |
constraint sum(i in 1..3)(x[i,i]) = TOTAL; | |
constraint sum(i in 1..3)(x[4-i,i]) = TOTAL; | |
solve satisfy; | |
output [show([x[1,i] | i in 1..3]), "\n", | |
show([x[2,i] | i in 1..3]), "\n", | |
show([x[3,i] | i in 1..3]), "\n" ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment