グループ内(2*2,3*3などの正方マス)には同一数字は入らない、
というルールを付け加えて、前回のものと速度を比較した。
sig Cell { x:Int, y:Int, v:Int } { x >= 0 and x <= 3 y >= 0 and y <= 3 v >= 1 and v <= 4 } fact AllCellsPosition { no disj c1,c2:Cell | c1.x == c2.x and c1.y == c2.y no disj c1,c2:Cell | c1.x == c2.x and c1.v == c2.v no disj c1,c2:Cell | c1.y == c2.y and c1.v == c2.v } fact SubRule1 { some disj c1,c2,c3,c4:Cell | c1.x == 0 and c1.y == 0 and c2.x == 0 and c2.y == 1 and c3.x == 1 and c3.y == 0 and c4.x == 1 and c4.y == 1 and c1.v != c2.v and c1.v != c3.v and c1.v != c4.v and c2.v != c3.v and c2.v != c4.v and c3.v != c4.v } fact SubRule2 { some disj c1,c2,c3,c4:Cell | c1.x == 2 and c1.y == 0 and c2.x == 2 and c2.y == 1 and c3.x == 3 and c3.y == 0 and c4.x == 3 and c4.y == 1 and c1.v != c2.v and c1.v != c3.v and c1.v != c4.v and c2.v != c3.v and c2.v != c4.v and c3.v != c4.v } fact SubRule3 { some disj c1,c2,c3,c4:Cell | c1.x == 0 and c1.y == 2 and c2.x == 0 and c2.y == 3 and c3.x == 1 and c3.y == 2 and c4.x == 1 and c4.y == 3 and c1.v != c2.v and c1.v != c3.v and c1.v != c4.v and c2.v != c3.v and c2.v != c4.v and c3.v != c4.v } fact SubRule4 { some disj c1,c2,c3,c4:Cell | c1.x == 2 and c1.y == 2 and c2.x == 2 and c2.y == 3 and c3.x == 3 and c3.y == 2 and c4.x == 3 and c4.y == 3 and c1.v != c2.v and c1.v != c3.v and c1.v != c4.v and c2.v != c3.v and c2.v != c4.v and c3.v != c4.v } fact Values { one c:Cell | c.x == 3 and c.y == 0 and c.v == 4 one c:Cell | c.x == 2 and c.y == 1 and c.v == 1 one c:Cell | c.x == 3 and c.y == 1 and c.v == 2 one c:Cell | c.x == 1 and c.y == 2 and c.v == 1 one c:Cell | c.x == 2 and c.y == 2 and c.v == 4 one c:Cell | c.x == 3 and c.y == 2 and c.v == 3 one c:Cell | c.x == 0 and c.y == 3 and c.v == 4 one c:Cell | c.x == 1 and c.y == 3 and c.v == 3 one c:Cell | c.x == 2 and c.y == 3 and c.v == 2 one c:Cell | c.x == 3 and c.y == 3 and c.v == 1 } run {} for exactly 16 Cell
実行速度は、私のマシンでは、補助ルールなしで3.5秒、
補助ルールありで19秒。
最低限のルールでしばってある方が速いわけですかそうですか。
書き方にもコツがありそうな気がする。