I have this:
import constraint
p = constraint.Problem()
t = [0,5]
c = [3,7]
s = range(len(t))
n = 12
p.addVariables([str(i) for i in s], range(n))
p.addConstraint(lambda x: (x+t[0])%n in c, ('0'))
p.addConstraint(lambda x: (x+t[1])%n in c, ('1'))
l = [list(i.values()) for i in p.getSolutions()]
print(l)
And that outputs:
[[7, 10], [7, 2], [3, 10], [3, 2]]
But I want to add the constraints in a loop, so I did this instead of the two p.addConstraint
lines:
for i in s:
p.addConstraint(lambda x: (x+t[i])%n in c, (str(i)))
I expected this to give the same output, but instead I got this:
[[10, 10], [10, 2], [2, 10], [2, 2]]
What am I missing?