Jump to content

Solve a Hidato puzzle: Difference between revisions

m
(→‎{{header|Raku}}: Fix up internal links)
m (→‎{{header|Tailspin}}: syntax update)
Line 4,062:
 
templates solve
when <~{row: <1..$@hidato.board::length>, col: <1..$@hidato.board(1)::length>}> do !VOID
when <{ n: <=$@hidato.given(-1last).n>, row: <=$@hidato.given(-1last).row>, col: <=$@hidato.given(-1last).col> }> do $@hidato.board !
when <?($@hidato.board($.row; $.col) <~=0|=$.n>)> do !VOID
when <?($@hidato.board($.row; $.col) <=0>)?($@hidato.given($.next) <=$.n>)> do !VOID
<>otherwise
def guess: $;
def back: $@hidato.board($.row; $.col);
def next: $ -> \(when <{n: <=$back>}> do $.next + 1! <>otherwise $.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,079:
end hidato
 
$input -> hidato -> '$... -> '$... -> ' $ -> \(when <=-1> do ' .' ! when <10..> do '$;' ! <>otherwise ' $;' !\);';
';
' ->!OUT::write
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.