aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2023-03-21 15:47:31 +0000
committerGitHub <noreply@github.com>2023-03-21 15:47:31 +0000
commit2aebc498393b08f2d6249ef5fdc0697f64cf9f30 (patch)
tree9096e47eac704c772c915df2a22bc3c6f9368bd6
parent842fa27317958486e2c40592eb7e33366e99eb21 (diff)
downloadperlweeklychallenge-club-2aebc498393b08f2d6249ef5fdc0697f64cf9f30.tar.gz
perlweeklychallenge-club-2aebc498393b08f2d6249ef5fdc0697f64cf9f30.tar.bz2
perlweeklychallenge-club-2aebc498393b08f2d6249ef5fdc0697f64cf9f30.zip
Update ch-1.pl
-rw-r--r--challenge-209/james-smith/perl/ch-1.pl10
1 files changed, 5 insertions, 5 deletions
diff --git a/challenge-209/james-smith/perl/ch-1.pl b/challenge-209/james-smith/perl/ch-1.pl
index c5a908afd5..7539610ef9 100644
--- a/challenge-209/james-smith/perl/ch-1.pl
+++ b/challenge-209/james-smith/perl/ch-1.pl
@@ -9,17 +9,17 @@ use Benchmark qw(cmpthese timethis);
my @TESTS = (
[ [1,0,0] => 1 ],
[ [1,1,1,0] => 0 ],
- [ [1,1,1] => -1 ],
+ [ [1,1,1] => 0 ],
);
sub special_bit_chars {
- return -1 if $_[-1];
+ return 0 if $_[-1];
($_[0]&&shift),shift until @_<2;
scalar @_
}
sub special_bit_chars_reverse {
- my$f,pop?return-1:pop||return 1;
- $f=!$f,pop||last while@_;
- ~~$f
+ my$f,pop?return 0:pop||return 1;
+ $f++,pop||last while@_;
+ 1&$f
}