Solve triangle solitaire puzzle: Difference between revisions

m
→‎{{header|Perl 6}}: don't cache. it helps more in theory than it does in practice
m (→‎{{header|Sidef}}: minor code tweak)
m (→‎{{header|Perl 6}}: don't cache. it helps more in theory than it does in practice)
Line 554:
{{trans|Sidef}}
 
<lang perl6>use experimental :cached;
 
constant @start = <
0
Line 574 ⟶ 573:
my $format = (1..5).map: {' ' x 5-$_, "%d " x $_, "\n"};
 
sub solve(@board, @move, $turns = 1) is cached {
return " Solved" if $turns + 1@board.sum == @board1;
return Nil if @board[@move[1]] == 0;
my $valid = do given @board[@move[0]] {
Line 592 ⟶ 591:
my $result;
for @moves -> @this-move {
$result = solve(@new-layout, @this-move, $turns + 1);
last if $result
}
10,333

edits