1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | language ESSENCE 1.2.0 $ prob019.essence: Magic Squares $ Problem details available at http://www.csplib.org/Problems/prob019/ $ 05 September 2007 $ given n : int (1..) letting Index be domain int (1..n), Value be domain int (1..n**2) find square : matrix indexed by [Index,Index] of Value, s : int (1.. sum i : int (n**2+1-n..n**2) . i) such that allDiff (flatten(square)), forAll r : Index . ( sum c : Index . square[r,c]) = s, forAll c : Index . ( sum r : Index . square[r,c]) = s, ( sum d : Index . square[d,d]) = s, ( sum d : Index . square[d,n+1-d]) = s |