aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2020-09-28 22:03:28 +0100
committerdrbaggy <js5@sanger.ac.uk>2020-09-28 22:03:28 +0100
commit0a2787dfeb4c5def8555c80758d3cd3e5a30a39a (patch)
tree3760b4aa6ae21410dfd7443246f1dc9bb4ef5d17
parentaa14cbf8342e04b936f40bcc720a23a258137ecd (diff)
downloadperlweeklychallenge-club-0a2787dfeb4c5def8555c80758d3cd3e5a30a39a.tar.gz
perlweeklychallenge-club-0a2787dfeb4c5def8555c80758d3cd3e5a30a39a.tar.bz2
perlweeklychallenge-club-0a2787dfeb4c5def8555c80758d3cd3e5a30a39a.zip
minor optimization
-rwxr-xr-xchallenge-079/james-smith/perl/ch-1.pl5
1 files changed, 2 insertions, 3 deletions
diff --git a/challenge-079/james-smith/perl/ch-1.pl b/challenge-079/james-smith/perl/ch-1.pl
index 75a2e92922..5b5ad927f1 100755
--- a/challenge-079/james-smith/perl/ch-1.pl
+++ b/challenge-079/james-smith/perl/ch-1.pl
@@ -62,11 +62,10 @@ sub count_set_bits {
my $t = my $s = 0;
while (@q) {
next unless shift @q;
- $t += ($s + @q/2)*(1<<@q);
- $t %= 1000000007;
+ $t += ($s + @q/2) * (1<<@q);
$s++;
}
- return $t;
+ return $t % 1000000007;
}
sub naive_count_set_bits {