You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
611 B

  1. from itertools import combinations
  2. from z3 import *
  3. solver = Solver()
  4. Colours = Datatype("Colours")
  5. Colours.declare("RED")
  6. Colours.declare("BLUE")
  7. Colours.declare("GREEN")
  8. Colours.declare("YELLOW")
  9. Colour = Colours.create()
  10. f = Function('f', IntSort(), Colour)
  11. variables = list()
  12. for i in range(0,5):
  13. variables.append(Int(i))
  14. solver.add(0 <= variables[-1])
  15. solver.add(variables[-1] <= 5)
  16. solver.add(Distinct(variables))
  17. """
  18. |cell 1|cell 2|cell 3|cell 4|cell 5|
  19. """
  20. # neighbouring cells needs to be coloured differently
  21. result = solver.check()
  22. if result == sat:
  23. print(solver.model())