aboutsummaryrefslogtreecommitdiff
path: root/challenge-203
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2023-02-12 09:08:25 +0000
committerGitHub <noreply@github.com>2023-02-12 09:08:25 +0000
commit901c81bbe85fdcae12ce36745129c0485b0c6f2e (patch)
tree11fc64f2c4c431e017ef13e2b87319a457197011 /challenge-203
parent3181b4e34bb0f61c08c4716d4400a3085fd23346 (diff)
downloadperlweeklychallenge-club-901c81bbe85fdcae12ce36745129c0485b0c6f2e.tar.gz
perlweeklychallenge-club-901c81bbe85fdcae12ce36745129c0485b0c6f2e.tar.bz2
perlweeklychallenge-club-901c81bbe85fdcae12ce36745129c0485b0c6f2e.zip
Update ch-1.pl
Diffstat (limited to 'challenge-203')
-rw-r--r--challenge-203/james-smith/perl/ch-1.pl12
1 files changed, 4 insertions, 8 deletions
diff --git a/challenge-203/james-smith/perl/ch-1.pl b/challenge-203/james-smith/perl/ch-1.pl
index a4407f490a..78fbbbcd21 100644
--- a/challenge-203/james-smith/perl/ch-1.pl
+++ b/challenge-203/james-smith/perl/ch-1.pl
@@ -19,15 +19,11 @@ done_testing();
sub special {
my $c = 0;
- for my $i (0..$#_-3) {
- for my $j ($i+1..$#_-2) {
- next unless $_[$i]<=$_[$j];
+ for my $i ( 0 .. $#_-3 ) {
+ for my $j ( $i+1 .. $#_-2 ) {
my $t = $_[$i]+$_[$j];
- for my $k ($j+1..$#_-1) {
- next unless $_[$j]<=$_[$k];
- for my $l ($k..$#_) {
- $c++ if $t+$_[$k]==$_[$l];
- }
+ for my $k ( $j+1 .. $#_-1 ) {
+ $t+$_[$k]==$_[$_] && $c++ for $k .. $#_;
}
}
}