From c94d70d4c743ae2299c077e9075be701f697ed07 Mon Sep 17 00:00:00 2001 From: Stephen Lynn Date: Sun, 24 Dec 2023 20:55:11 +0800 Subject: ch-1a.pl improved --- challenge-248/steve-g-lynn/perl/ch-1a.pl | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/challenge-248/steve-g-lynn/perl/ch-1a.pl b/challenge-248/steve-g-lynn/perl/ch-1a.pl index 3c5edede1f..7c7d8d69db 100755 --- a/challenge-248/steve-g-lynn/perl/ch-1a.pl +++ b/challenge-248/steve-g-lynn/perl/ch-1a.pl @@ -53,22 +53,18 @@ pp_def( if (0==(gap_size % 2)){ c_mid=gap_size/2; - for (i=a1; i < a1+c_mid; i++) { - $b(n=>i)=i-a1; - } - for (i=a1+c_mid; i <= a2; i++) { - $b(n=>i)=a2-i; - } - } + } else { c_mid=(gap_size+1)/2; - for (i=a1; i < a1+c_mid; i++) { - $b(n=>i)=i-a1; - } - for (i=a1+c_mid; i <= a2; i++) { - $b(n=>i)=a2-i; - } } + + for (i=a1; i < a1+c_mid; i++) { + $b(n=>i)=i-a1; + } + for (i=a1+c_mid; i <= a2; i++) { + $b(n=>i)=a2-i; + } + } if (size_n > $a(m=>-1)+1){ a1=$a(m=>size_m-1); -- cgit