我遇到了为这个拼图程序打印适量解决方案的问题.它打印正确的拼图,但不是所需的正确解决方案.
以下是每种情况的作用:
拼图1 - 你有五种颜色:2蓝色,2绿色和1黄色没有相同的颜色可能彼此相邻.
拼图2 - 你有六种颜色:1个红色,1个蓝色和4个黑色连续不超过2个黑色.
拼图3 -
你有八种颜色:3个绿色,2个白色,2个红色和1个黑色.白色从不在A和H中.位置D和H都有相同的颜色.A和G中的颜色必须是不同的颜色.红色永远不会出现在F和G中.绿色从不在B和C中.在每个红色的左边,都有一个绿色.
% a program that find solutions for each of the following colored ball problems with different sets of constraints.
% to run, type either
% sit1, sit2 or sit3.
% select an element for use in permutation test
%
% If the element is the head of the list, then it is in the list, and the tail is left
selectE(Element, [Element|Tail], Tail).
% If the two lists have …Run Code Online (Sandbox Code Playgroud)