我可以使用 python 到 CSP 吗?

Can i use python to CSP?

我如何制作一个基于约束求解器编程 (CSP) 的算法来解决任何 Futoshiki 难题。

有这方面的代码吗?我在 google 上进行了搜索,但没有找到任何内容。

A) Whosebug 不是一个提供程序示例的站点。这是一个帮助回答有关 现有程序.

问题的网站

B) 也就是说,我可以为您指出一些教程。

你没有找到任何东西?这是我从 Google 获得的前 3 个结果:

  1. python-constraint是允许CSP编程的模块。以下是他们网站的逐字记录:

from constraint import * problem = Problem() problem.addVariable("a", [1,2,3]) problem.addVariable("b", [4,5,6]) problem.getSolutions() [{'a': 3, 'b': 6}, {'a': 3, 'b': 5}, {'a': 3, 'b': 4}, {'a': 2, 'b': 6}, {'a': 2, 'b': 5}, {'a': 2, 'b': 4}, {'a': 1, 'b': 6}, {'a': 1, 'b': 5}, {'a': 1, 'b': 4}]

  1. Numberjack 类似。好像是用来嵌入的

    Numberjack is a modelling package written in Python for constraint programming. Python benefits from a large and active programming community, Numberjack is therefore a perfect tool to embed CP technology into larger applications.

  2. This is a tutorial for the python-constraints package (number 1).
Finally, here is a paper about CSPs that talks about Futoshiki problems.

祝你好运。