diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-26 23:31:20 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-26 23:31:20 +0000 |
| commit | 8f7f5c93def45398db496f35e7921cfe0d264d1d (patch) | |
| tree | 7f141de93b08d38f0e5fc5930ec93fc4ef311638 /challenge-079 | |
| parent | 8902910406fe11ec55932be70d1df508f61c083d (diff) | |
| download | perlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.tar.gz perlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.tar.bz2 perlweeklychallenge-club-8f7f5c93def45398db496f35e7921cfe0d264d1d.zip | |
Remove List::Util and Data::Dump dependencies
Diffstat (limited to 'challenge-079')
| -rw-r--r-- | challenge-079/paulo-custodio/perl/ch-1.pl | 7 | ||||
| -rw-r--r-- | challenge-079/paulo-custodio/perl/ch-2.pl | 15 |
2 files changed, 20 insertions, 2 deletions
diff --git a/challenge-079/paulo-custodio/perl/ch-1.pl b/challenge-079/paulo-custodio/perl/ch-1.pl index 2b34fdff7b..dba39d1251 100644 --- a/challenge-079/paulo-custodio/perl/ch-1.pl +++ b/challenge-079/paulo-custodio/perl/ch-1.pl @@ -56,7 +56,6 @@ use strict; use warnings; use 5.030; -use List::Util 'sum'; @ARGV==1 or die "Usage: ch-1.pl N\n"; say(sum(map {bit_count($_)} 1..$ARGV[0]) % 1000000007); @@ -70,3 +69,9 @@ sub bit_count { } return $count; } + +sub sum { + my($sum, @a) = @_; + $sum += $_ for @a; + return $sum; +} diff --git a/challenge-079/paulo-custodio/perl/ch-2.pl b/challenge-079/paulo-custodio/perl/ch-2.pl index 8caa2c0c95..1c4248898a 100644 --- a/challenge-079/paulo-custodio/perl/ch-2.pl +++ b/challenge-079/paulo-custodio/perl/ch-2.pl @@ -39,7 +39,6 @@ use strict; use warnings; use 5.030; -use List::Util 'max', 'sum'; @ARGV or die "Usage: ch-2.pl list\n"; my @N = @ARGV; @@ -71,3 +70,17 @@ sub draw_hist { } return @hist; } + +sub max { + my($max, @a) = @_; + for (@a) { + $max = $_ if $max < $_; + } + return $max; +} + +sub sum { + my($sum, @a) = @_; + $sum += $_ for @a; + return $sum; +} |
