Blame view

Debug/src/csps/magic_seq.mzn 654 Bytes
4d26a735   Pedro Roque   Increased recogni...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% magicseq.mzn
% vim: ft=zinc ts=4 sw=4 et tw=0
% Ralph Becket <rafe@csse.unimelb.edu.au>
% Mon Oct 29 13:19:57 EST 2007
%
% A magic sequence of non-negative integers [X0, X1, X2, ..., Xn] has the
% property that forall (i in 1..n) (Xi = card({Xj | j in 1..n, Xj = i})).  That
% is, each Xi is the number of occurrences of i in the sequence.

include "globals.mzn";

int: n;                                       % The length of the sequence.

array [0..n - 1] of var 0..n: x; % The sequence.

constraint forall (i in 0..n - 1) (count(x, i, x[i]));

solve :: int_search(x, input_order, indomain_min, complete) satisfy;
%solve satisfy;

output [show(x)];