言語はチャレンジよりもはるかに新しいため、これは明らかに競合していませんが、他に答えがないため、これが非常に重要であるかはわかりません...
主な述語:
@n Split the input on line breaks
:1a:"-"x Transform into a list of lists, each sublist contains a line's values
:7fF Transform so that cells are [Value:X:Y]
:3a All values on lines must be different
$\:3a All values on columns must be different (by transposition)
@3:4a, All 3*3 block values must be different
Fc~bCh[0:0:0]gO, Append a fake cell [0:0:0]
Co~c[V:O:T] Sort the board, the blank cells V will be those before O ([0:0:0])
h:F:6f Find all subsets of blank cells with specific values for which
the board has only one solution
:10ao Sort the subsets by lengths
:ba Discard the lengths
(
h:11a Print the first subset = an answer
; Or (board is already fully determined)
! Terminate
)
; Or (Some values don't respect the constraints)
"!!"w! Print "!!" and terminate
述語1:|
行のすべての " " を削除し、を変換し---+---+---
て-
から削除します
h"-". If the first char is "-", then Output is "-"
| Or
:"|"x Remove all occurences of "|" from the input
:2f. Output is the result of all outputs of predicate 2 on the filtered string
述語2:1つの文字を整数に変換するか、空白の場合は1〜9の変数に変換します。
e Take a char of the input string
(
~m["0123456789":.] Output is the index of the char in "0123456789"
` Discard the choice point caused by the ;
; Or
0<.<=9 Output is an integer between 1 and 9
)
述語3:セルの入力リストのすべての値が明確でなければならないことを課します
:ha Retrieve the head of each cell (i.e. the value) in the input
#d. Apply a constraint of distinctness to those values
述語4:3 * 3ブロックの値に明確性制約を適用する
:@3a Split 3 lines of the board in 3 parts
z Zip them together
:ca:5a. Concatenate each element of the zip, apply predicate 5 to that
述語5:
:3a. Apply predicate 3 to each element of the input
述語6:制約を満たす値を空白セルのサブセットに割り当てます。これらの値では、ボードに対する解決策は1つだけです。
hs. Output is a subset of the blank cells
:=a, Assign values to those cells
?t:9ac Concatenate the values of all cells of the board
:=f Find all solved boards
l1 There is only 1 such solved board
述部7:各セルが(値)[V:X:Y]
だけではなくようにボードを変換V
します。
:Im Take the Ith line of the board
:8f Transform all elements of the line using predicate 8
:[[I]]z Zip the result with [I]
:ca. Concatenate each element of the zip
述部8:各セルがになるように線を変換します[V:X]
。
:Jm Take the Jth element of the line
:J. Output is [That element:J]
述部9:セルの値を取得する
:ha. Take the head of each element of the input
述語10:サブセットの長さを先頭に追加します
lg Put the length of the input in a list
:?c. Concatenate it with the input
述部11:1つのセルを印刷する
b:+a[X:Y], Increment coordinates by 1 to get X and Y
?h:Y:Xr: Build the list [X:Y:Value]
"(~d,~d):~d\n"w Format that list as "('X','Y'):'Value'\n" to STDOUT