diff options
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 |
