Thanks to visit codestin.com
Credit goes to github.com

Skip to content

magic square for 4x4 doesn't work under 1000 steps #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Horopter opened this issue Oct 26, 2018 · 1 comment
Open

magic square for 4x4 doesn't work under 1000 steps #43

Horopter opened this issue Oct 26, 2018 · 1 comment

Comments

@Horopter
Copy link

Horopter commented Oct 26, 2018

I've tried 4x4 magic square but it always returns None with MinConflictsSolver.

However, the following code works

from constraint import *

problem = Problem()
problem.addVariables(range(0, 9), range(1, 9 + 1))
problem.addConstraint(AllDifferentConstraint(), range(0, 9))
problem.addConstraint(ExactSumConstraint(15), [0, 4, 8])
problem.addConstraint(ExactSumConstraint(15), [2, 4, 6])
for row in range(3):
	problem.addConstraint(ExactSumConstraint(15),
						  [row * 3 + i for i in range(3)])
for col in range(3):
	problem.addConstraint(ExactSumConstraint(15),
						  [col + 3 * i for i in range(3)])
solutions = problem.getSolution()
print(solutions)
@Horopter
Copy link
Author

Also may I have some more documentation about constraint propagation via doArc8? I don't understand that I am afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant