Skip to content

Instantly share code, notes, and snippets.

@hellman
Created March 6, 2016 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellman/90c1476553b3f2552a90 to your computer and use it in GitHub Desktop.
Save hellman/90c1476553b3f2552a90 to your computer and use it in GitHub Desktop.
from z3.z3 import *
s = Solver()
V = 683
vs = []
for v in range(1, V + 1):
vs.append(Int("v%03d" % v))
s.add(vs[-1] >= 1)
s.add(vs[-1] <= 3)
for line in open("graph.txt"):
if not line.strip():
continue
a, b = map(int, line.strip().split())
s.add(vs[a] != vs[b])
s.check()
model = s.model()
for v in sorted(model):
print "v[%s] = %s" % (str(v)[1:], model[v])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment