aboutsummaryrefslogtreecommitdiff
path: root/challenge-126
diff options
context:
space:
mode:
authorNiels van Dijke <65567640+PerlBoy1967@users.noreply.github.com>2021-08-23 08:14:01 +0200
committerGitHub <noreply@github.com>2021-08-23 08:14:01 +0200
commitdfdcc6e2e49d14ec16c4f55ed4e9d848712433fd (patch)
treed6daee51ffbd8e45c569f0cdfef14264df52f7bb /challenge-126
parentdf35ff0ae1f97a768f4365ac33aebffc0d331a6d (diff)
downloadperlweeklychallenge-club-dfdcc6e2e49d14ec16c4f55ed4e9d848712433fd.tar.gz
perlweeklychallenge-club-dfdcc6e2e49d14ec16c4f55ed4e9d848712433fd.tar.bz2
perlweeklychallenge-club-dfdcc6e2e49d14ec16c4f55ed4e9d848712433fd.zip
Update ch-2.pl
Small change to randomization of placing bombs
Diffstat (limited to 'challenge-126')
-rwxr-xr-xchallenge-126/perlboy1967/perl/ch-2.pl5
1 files changed, 3 insertions, 2 deletions
diff --git a/challenge-126/perlboy1967/perl/ch-2.pl b/challenge-126/perlboy1967/perl/ch-2.pl
index 23c2a52037..9f5cacc7b5 100755
--- a/challenge-126/perlboy1967/perl/ch-2.pl
+++ b/challenge-126/perlboy1967/perl/ch-2.pl
@@ -29,8 +29,9 @@ printBoard(@B);
sub generateBoard($$\@) {
my ($w,$h,$arB) = @_;
- my @c = qw(X . . . .); # 1 in 5 chance of placing a bomb
-
+ my $bRatio = 5; # 1 in 5 chance of placing a bomb
+ my @c = ('X', map '.', 1..$bRatio-1);
+
foreach my $y (1 .. $h) {
foreach my $x (1 .. $w) {
$arB->[$y][$x] = $c[int rand(scalar @c)];