Restructured 015
@@ -12,10 +12,7 @@ Modified by Ignace Bleukx
from cpmpy import *
-if __name__ == "__main__":
-
- n, c = 12, 3 # n is the number of balls -- d is the number of boxes
-
+def shur_lemma(n, c):
# balls[i] = j iff ball i is in box j
balls = intvar(1, c, shape=n, name="balls")
@@ -27,9 +24,16 @@ if __name__ == "__main__":
(balls[i - 1] != balls[i + j - 1]) | \
(balls[j - 1] != balls[i + j - 1])
+ return model, (balls,)
+
+if __name__ == "__main__":
+
+ n, c = 12, 3 # n is the number of balls -- d is the number of boxes
+
+ model, (balls,) = shur_lemma(n,c)
+
if model.solve():
print("Balls:")
print(balls.value())
-
else:
print("Model is unsatisfiable")
\ No newline at end of file
