diff options
| author | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2020-06-08 22:30:09 +0200 |
|---|---|---|
| committer | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2020-06-08 22:30:09 +0200 |
| commit | b5b7ec8a3b815c77b14a2e14882cb81b02a879c6 (patch) | |
| tree | e88d4f203a39723bc1584f895cacda49db89fa2b /challenge-059 | |
| parent | cc7cd44793f5faff2c273b5471c4b6f578366a8b (diff) | |
| download | perlweeklychallenge-club-b5b7ec8a3b815c77b14a2e14882cb81b02a879c6.tar.gz perlweeklychallenge-club-b5b7ec8a3b815c77b14a2e14882cb81b02a879c6.tar.bz2 perlweeklychallenge-club-b5b7ec8a3b815c77b14a2e14882cb81b02a879c6.zip | |
improved solution for challenge 059-2
Diffstat (limited to 'challenge-059')
| -rwxr-xr-x | challenge-059/jo-37/perl/ch-2.pl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/challenge-059/jo-37/perl/ch-2.pl b/challenge-059/jo-37/perl/ch-2.pl index 6bd296e10a..85ead44c0d 100755 --- a/challenge-059/jo-37/perl/ch-2.pl +++ b/challenge-059/jo-37/perl/ch-2.pl @@ -6,10 +6,11 @@ use strict; use warnings; +use List::Util qw(reduce); +my @bits = map {pack 'Q', $_} @ARGV; my $sum; -while (defined (my $x = shift)) { - my $bits = pack 'Q', $x; - $sum += unpack '%64b*', $bits ^ $_ foreach map {pack 'Q', $_} @ARGV; +while (defined (my $bits = shift @bits)) { + $sum += unpack '%64b*', $bits ^ $_ foreach @bits; } print $sum, "\n"; |
