Solve a Hidato puzzle: Difference between revisions

m
m (→‎{{header|Tailspin}}: use new integer division operator)
m (→‎{{header|Tailspin}}: syntax update)
Line 4,048:
composer setup
@: {row: 1, col: 1, given:[]};
{ board: [ <line>+ ], given: $@.given -> \[i](<{}> { n: $i, $...} !\) }
rule line: [ <cell>+ ] (<'\n '>?) (..|@: {row: $@.row + 1, col: 1};)
rule cell: <open|blocked|given> (<' '>?) (@.col: $@.col + 1;)
Line 4,061:
templates solve
<~{row: <1..$@hidato.board::length>, col: <1..$@hidato.board(1)::length>}> !VOID
<{ n: <=$@hidato.given(-1).n>, row: <=$@hidato.given(-1).row>, col: <=$@hidato.given(-1).col> }> $@hidato.board !
<?($@hidato.board($.row; $.col) <~=0|=$.n>)> !VOID
<?($@hidato.board($.row; $.col) <=0>)?($@hidato.given($.next) <=$.n>)> !VOID
<>
def guess: $;
def back: $@hidato.board($.row; $.col);
def next: $ -> \(<{n: <=$back>}> $.next + 1! <> $.next!\);
@hidato.board($.row; $.col): $.n;
0..8 -> { next: $next, n: $guess.n + 1, row: $guess.row + $ ~/ 3 - 1, col: $guess.col + $ mod 3 - 1 } -> #
Line 4,077:
end hidato
 
$input -> hidato -> '$... -> '$... -> ' $ -> \(<=-1> ' .' ! <10..> '$;' ! <> ' $;' !\);';
';
' ->!OUT::write
Anonymous user