sub illuminate{ my $centre_row = shift; my $centre_col = shift; my $radius = shift; my $insq = int ($radius / sqrt (2)); my @ans; # inner square for my $i ($centre_row - $insq .. $centre_row + $insq) { for my $j ($centre_col - $insq .. $centre_col + $insq) { push @ans, [$i, $j]; } } # outer square my $r2 = $radius * $radius; for my $i (0 .. $radius) { for my $j (0 .. $radius) { # Skip already-done inner square next if $i < $insq and $j < $insq; if ($i * $i + $j * $j < $r2) { push @ans, [$centre_row + $i, $centre_col + $j], [$centre_row - $i, $centre_col + $j], [$centre_row + $i, $centre_col - $j], [$centre_row - $i, $centre_col - $j]; } } } return @ans; }