Reputation: 1
I am trying to solve a constraint satisfaction problem with python. There are 4 people going to a party at 4 different times.
timeDomain = {"4:30" : ["brian", "amber", "chris", "diane"],
"4:35" : ["brian", "amber", "chris", "diane"],
"4:40" : ["brian", "amber", "chris", "diane"],
"4:45" : ["brian", "amber", "chris", "diane"]}
The constraint is "amber comes 5 mins before brian". So, how do I compare brian's and amber's times with this dictionary? I want to write the constraint as a boolean variable named c:
c = ambers time == brians time - 5
(with converting the string values of the minutes to int etc..)
I tried
list(timeDomain.keys())[list(timeDomain.values()).index(["brian", "amber", "chris", "diane"])[1]]
to find amber's key but it is not working because all the values are the same, I guess.
Upvotes: 0
Views: 27