From 36cd598745ba494ac161afd0ebabe8936d3f77ca Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 27 Mar 2023 11:44:04 +0100 Subject: Update ch-2.pl --- challenge-210/james-smith/perl/ch-2.pl | 8 ++++---- 1 file 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 @_; -- cgit