Peaceful chess queen armies: Difference between revisions
→{{header|jq}}: simplify
(→{{header|jq}}: simplify) |
|||
Line 4,913:
'''Works with gojq, the Go implementation of jq'''
In the following, positions on the chessboard are represented by {x,y} objects.
<syntaxhighlight lang="jq">
Line 4,926 ⟶ 4,925:
# and similarly for .whiteQueens.
# input: {blackQueens, whiteQueens}
# output:
def place($
def place($q):
else .placingBlack = true
| first(
foreach range
foreach
| if
then if
|
| .
| .placingBlack = true
end
end
| if $i == $n-1 and $j == $n-1 then .ok = false end );
end;
# Input {blackQueens, whiteQueens}
Line 4,989 ⟶ 4,991:
tasks[] as $t
| "\($t.queens) black and \($t.queens) white queens on a \($t.squares) x \($t.squares) board:",
((place($t.queens; $t.squares)
▲ (({blackQueens: [], whiteQueens: [] }
|
| printBoard($t.squares))
// "No solution exists."),
|