Skip to content
Discussion options

You must be logged in to vote

Hi Sebastian, that's definitely possible. If possible I would recommend not nesting variables you want to constraint in dictionaries, because it complicates things - I've given an alternative below. However, let's first solve it the way you provided it.
We start by defining the two variables, the front and back frames.

from constraint import Problem
problem = Problem()
problem.addVariable("front", [
    {"size": [40, 50], "color": ["green"]},
    {"size": [60], "color": ["blue", "red"]}
])
problem.addVariable("back", [
    {"size": [50, 60], "color": ["green"]},
    {"size": [30, 40], "color": ["blue", "red"]}
])

Next, we add the constraint and get the solutions:

def equal_size(front, ba…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@SebastianDahlin
Comment options

@fjwillemsen
Comment options

@SebastianDahlin
Comment options

@fjwillemsen
Comment options

Answer selected by SebastianDahlin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants