to be subset sum34
- to to to be or not to be that's the question ([3, 1, 1, 1, 1, 1, 1, 1, 1])
- to to be be or not to be that's the question ([2, 2, 1, 1, 1, 1, 1, 1, 1])
- to be be be or not to be that's the question ([1, 3, 1, 1, 1, 1, 1, 1, 1])
- to to be or or not to be that's the question ([2, 1, 2, 1, 1, 1, 1, 1, 1])
- to be be or or not to be that's the question ([1, 2, 2, 1, 1, 1, 1, 1, 1])
- to be or or or not to be that's the question ([1, 1, 3, 1, 1, 1, 1, 1, 1])
- to to be or not to to be that's the question ([2, 1, 1, 1, 2, 1, 1, 1, 1])
- to be be or not to to be that's the question ([1, 2, 1, 1, 2, 1, 1, 1, 1])
- to be or or not to to be that's the question ([1, 1, 2, 1, 2, 1, 1, 1, 1])
- to be or not to to to be that's the question ([1, 1, 1, 1, 3, 1, 1, 1, 1])
- to to be or not to be be that's the question ([2, 1, 1, 1, 1, 2, 1, 1, 1])
- to be be or not to be be that's the question ([1, 2, 1, 1, 1, 2, 1, 1, 1])
- to be or or not to be be that's the question ([1, 1, 2, 1, 1, 2, 1, 1, 1])
- to be or not to to be be that's the question ([1, 1, 1, 1, 2, 2, 1, 1, 1])
- to be or not to be be be that's the question ([1, 1, 1, 1, 1, 3, 1, 1, 1])
MiniZinc model
int: n;
array[1..n] of string: s;
array[1..n] of int: sl;
array[1..n] of var 0..100: x;
var 0..100: total;
predicate subset_sum(array[int] of int: values,
array[int] of var int: x,
var int: tot) =
sum(i in 1..n) (values[i]*x[i]) = tot /\
forall(i in 1..n) (x[i] >= 0)
;
solve satisfy;
constraint
subset_sum(sl, x, total) /\
total = 34 /\
forall(i in 1..n) ( x[i] >= 1 )
;
n = 9;
s = ["to", "be", "or", "not", "to", "be", "that's", "the", "question"];
sl = [2, 2, 2, 3, 2, 2, 6, 3, 8]; % length
output
[
if i = 1 /\ j = 1 then "<li>" else "" endif ++
show(s[i]) ++ " "
| i in 1..n, j in 1..fix(x[i])
]
++
[ "(" ++ show(x) ++ ")\n"];
Back to Constrained-based constraint poetry
Created by Hakan Kjellerstrand hakank@gmail.com