aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-260/lubos-kolouch/perl/ch-1.pl14
-rw-r--r--challenge-260/lubos-kolouch/perl/ch-2.pl3
2 files changed, 12 insertions, 5 deletions
diff --git a/challenge-260/lubos-kolouch/perl/ch-1.pl b/challenge-260/lubos-kolouch/perl/ch-1.pl
index 791a3dc77c..0d8d759c79 100644
--- a/challenge-260/lubos-kolouch/perl/ch-1.pl
+++ b/challenge-260/lubos-kolouch/perl/ch-1.pl
@@ -1,5 +1,7 @@
+package ch1;
use strict;
use warnings;
+
use Data::Dumper;
sub unique_occurrences {
@@ -11,22 +13,24 @@ sub unique_occurrences {
# Check if the number of occurrences is unique
my %occurrences_count;
- foreach my $value (values %count) {
+ foreach my $value ( values %count ) {
$occurrences_count{$value}++;
}
# Return 1 if all occurrences are unique, 0 otherwise
- return (scalar keys %occurrences_count == scalar values %count) ? 1 : 0;
+ return ( scalar keys %occurrences_count == scalar values %count ) ? 1 : 0;
}
# Example 1
-my @ints1 = (1,2,2,1,1,3);
+my @ints1 = ( 1, 2, 2, 1, 1, 3 );
print "Example 1: " . unique_occurrences(@ints1) . "\n";
# Example 2
-my @ints2 = (1,2,3);
+my @ints2 = ( 1, 2, 3 );
print "Example 2: " . unique_occurrences(@ints2) . "\n";
# Example 3
-my @ints3 = (-2,0,1,-2,1,1,0,1,-2,9);
+my @ints3 = ( -2, 0, 1, -2, 1, 1, 0, 1, -2, 9 );
print "Example 3: " . unique_occurrences(@ints3) . "\n";
+
+1;
diff --git a/challenge-260/lubos-kolouch/perl/ch-2.pl b/challenge-260/lubos-kolouch/perl/ch-2.pl
index a33f112bb3..fc13687a33 100644
--- a/challenge-260/lubos-kolouch/perl/ch-2.pl
+++ b/challenge-260/lubos-kolouch/perl/ch-2.pl
@@ -1,3 +1,4 @@
+package ch2;
use strict;
use warnings;
use List::Util qw(reduce);
@@ -34,3 +35,5 @@ sub dictionary_rank {
print dictionary_rank('CAT'), "\\n";
print dictionary_rank('GOOGLE'), "\\n";
print dictionary_rank('SECRET'), "\\n";
+
+1;