-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaustalia.py
More file actions
21 lines (16 loc) · 771 Bytes
/
austalia.py
File metadata and controls
21 lines (16 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from csp import *
problem = Problem()
colors = ["blue","green","red"]
states = ["WA","NT","Q","NSW","V","SA","T"]
for state in states:
problem.add_variable(Variable(state, colors))
problem.add_constraint(AllDifferentConstraint(["WA", "NT"]))
problem.add_constraint(AllDifferentConstraint(["WA", "SA"]))
problem.add_constraint(AllDifferentConstraint(["NT", "SA"]))
problem.add_constraint(AllDifferentConstraint(["NT", "Q"]))
problem.add_constraint(AllDifferentConstraint(["SA", "Q"]))
problem.add_constraint(AllDifferentConstraint(["SA", "NSW"]))
problem.add_constraint(AllDifferentConstraint(["SA", "V"]))
problem.add_constraint(AllDifferentConstraint(["Q", "NSW"]))
problem.add_constraint(AllDifferentConstraint(["V", "NSW"]))
print(problem.get_solutions()[0])