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 ] = '
}
}
Line 998:
sub countSteps(\i, \x, \y) {
my \tX = $ = X ; my \tY = $ = Y;
for
tX += x; tY += y;
return False if
}
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-
}
}</lang>
|