aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2023-03-27 11:44:04 +0100
committerGitHub <noreply@github.com>2023-03-27 11:44:04 +0100
commit36cd598745ba494ac161afd0ebabe8936d3f77ca (patch)
treec2495826cab940ac9c34bf0c9715b3c74f5a26a3
parent029680e3829388f61ba89cef6ec43f1cff14ba98 (diff)
downloadperlweeklychallenge-club-36cd598745ba494ac161afd0ebabe8936d3f77ca.tar.gz
perlweeklychallenge-club-36cd598745ba494ac161afd0ebabe8936d3f77ca.tar.bz2
perlweeklychallenge-club-36cd598745ba494ac161afd0ebabe8936d3f77ca.zip
Update ch-2.pl
-rw-r--r--challenge-210/james-smith/perl/ch-2.pl8
1 files changed, 4 insertions, 4 deletions
diff --git a/challenge-210/james-smith/perl/ch-2.pl b/challenge-210/james-smith/perl/ch-2.pl
index 495cfe3845..8d0c1479a8 100644
--- a/challenge-210/james-smith/perl/ch-2.pl
+++ b/challenge-210/james-smith/perl/ch-2.pl
@@ -13,17 +13,17 @@ my @TESTS = (
sub collision {
my @st;
- $_[0]>0 || !@st || $st[-1] < 0 ? ( push @st, shift )
+ $_[0]>0 || !@st || $st[-1] < 0 ? push @st, shift
## +ve no, empty stack or last stack is -ve
## we keep this at the moment so push to stack
- : $st[-1] == -$_[0] ? ( pop @st, shift )
+ : $st[-1] == -$_[0] ? pop @st && shift
## -ve no and equal in absolute value
## remove +ve value from stack and drop
## current value
- : $st[-1] >= -$_[0] ? ( shift )
+ : $st[-1] >= -$_[0] ? shift
## -ve no and smaller in abs value
## drop current value
- : ( pop @st )
+ : pop @st
## -ve no and greater in abs value
## remove previous number from stack
while @_;