diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-07 17:15:57 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-07 17:15:57 +0000 |
| commit | 8e30607364f6abdd2250591c032126e3e68fdaba (patch) | |
| tree | d52c46ee639dcd01ff124df3f39e69b354b85b26 /challenge-042 | |
| parent | b9590e2436dbe3fa7d79d07ab485a2a365a71814 (diff) | |
| download | perlweeklychallenge-club-8e30607364f6abdd2250591c032126e3e68fdaba.tar.gz perlweeklychallenge-club-8e30607364f6abdd2250591c032126e3e68fdaba.tar.bz2 perlweeklychallenge-club-8e30607364f6abdd2250591c032126e3e68fdaba.zip | |
- Added solution by Fabrizio Poggi.
Diffstat (limited to 'challenge-042')
| -rw-r--r-- | challenge-042/fabrizio-poggi/perl/ch-2.pl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-042/fabrizio-poggi/perl/ch-2.pl b/challenge-042/fabrizio-poggi/perl/ch-2.pl new file mode 100644 index 0000000000..5e66956b34 --- /dev/null +++ b/challenge-042/fabrizio-poggi/perl/ch-2.pl @@ -0,0 +1,19 @@ +use strict;
+use warnings;
+
+my @chars = ('(', ')');
+my $lenght;
+my $rands;
+my $countr;
+my $countl;
+
+$lenght = int(rand(15)) + 1;
+while ($lenght--){ $rands.= $chars[rand @chars] };
+print "$rands";
+$countr = () = $rands =~ /\(/g;
+$countl = () = $rands =~ /\)/g;
+if ($countr - $countl == 0) {
+ print " - OK\n";
+ } else {
+ print " - NOT OK\n";
+ }
\ No newline at end of file |
