aboutsummaryrefslogtreecommitdiff
path: root/challenge-252
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-252')
-rwxr-xr-xchallenge-252/perlboy1967/perl/ch2.pl7
1 files changed, 3 insertions, 4 deletions
diff --git a/challenge-252/perlboy1967/perl/ch2.pl b/challenge-252/perlboy1967/perl/ch2.pl
index c6ef2e5808..225f32ac2a 100755
--- a/challenge-252/perlboy1967/perl/ch2.pl
+++ b/challenge-252/perlboy1967/perl/ch2.pl
@@ -25,11 +25,10 @@ use Test2::V0;
sub uniqSumZero ($n) {
my @n = (0);
if ($n > 1) {
- my $i = $n >> 1;
- @n = sort { $a <=> $b } map { (-$_,$_) } 1 .. $i;
- splice(@n,$i,1,0,$n[$i]) if ($n % 2 != 0);
+ @n = map { (-$_,$_) } 1 .. $n >> 1;
+ push(@n,0) if ($n % 2 != 0);
}
- [@n];
+ [sort { $a <=> $b } @n];
}
is(uniqSumZero(1),[0]);