I am working with the python-constraint
library and a logical error has risen.
It seems to me that a similar question has been asked here but I don't understand how to apply it in my case
First I call this code
my_function(List):
from constraint import Problem , AllDifferentConstraint
problem = Problem()
people = ["bob", "tom"]
times = ["2:00", "3:00"]
t_vars = list(map(lambda x: "t_"+x, people))
problem.addVariables(t_vars, times)
problem.addConstraint(AllDifferentConstraint(), t_vars)
for person in List:
problem.addConstraint (
(lambda x:
(x == person[1])
),
["t_"+person[0]]
)
return problem.getSolutions()
Then I call with
my_function([["bob", "2:00"], ["tom", "3:00"]])
and it returns an empty []
. Why?
However, if I enter
my_function([["bob", "2:00"]])
it returns what I want, which is [{'t_bob': '2:00', 't_tom': '3:00'}]