Greed: Difference between revisions

m
→‎{{header|Raku}}: small changes
(added Raku programming solution)
m (→‎{{header|Raku}}: small changes)
Line 988:
 
sub execute (\y,\x) {
my \i = $ = @board[Y+y;X+x];
if countSteps(i, x, y) {
score += i;
@board[ Y + y*$_ ; X + x*$_ ] = ' ' for ^i;
@board[ Y += y*i ; X += x*i ] = ' @' for ^i;
}
}
Line 998:
sub countSteps(\i, \x, \y) {
my \tX = $ = X ; my \tY = $ = Y;
for (1..^i) {
tX += x; tY += y;
return False if ( tX < 0 or tY < 0 or tX ≥ w or tY ≥ h or @board[tY;tX] eq ' ' )
}
return True;
Line 1,028:
when 'x' { execute( 1,-1) if X > 0 and Y < h } # South-West
when 'c' { execute( 1, 0) if Y < h } # South
when 'v' { execute( 1, 1) if X < w and Y < h } # South-eastEast
}
@board[Y;X] = '@';
}</lang>
 
351

edits