RosettaCodeData/Task/Constrained-random-points-on-a-circle/Perl/constrained-random-points-on-a-circle-2.pl
2023-07-01 13:44:08 -04:00

13 lines
373 B
Perl

@range = -15..16;
for $x (@range) {
for $y (@range) {
$radius = sqrt $x**2 + $y**2;
push @points, [$x,$y] if 10 <= $radius and $radius <= 15
}
}
push @sample, @points[int rand @points] for 1..100;
push @matrix, ' ' x @range for 1..@range;
substr $matrix[15+$$_[1]], 15+$$_[0], 1, '*' for @sample;
print join(' ', split '', $_) . "\n" for @matrix;