diff options
| author | Stephen Lynn <bizlsg@localhost.localdomain> | 2023-12-24 20:55:11 +0800 |
|---|---|---|
| committer | Stephen Lynn <bizlsg@localhost.localdomain> | 2023-12-24 20:55:11 +0800 |
| commit | c94d70d4c743ae2299c077e9075be701f697ed07 (patch) | |
| tree | afaee76fde670dcce7f2eb8e0dea42ce3bb67289 | |
| parent | bfb20ad7efd883f8df62bca6540ecf1bc88fca0f (diff) | |
| download | perlweeklychallenge-club-c94d70d4c743ae2299c077e9075be701f697ed07.tar.gz perlweeklychallenge-club-c94d70d4c743ae2299c077e9075be701f697ed07.tar.bz2 perlweeklychallenge-club-c94d70d4c743ae2299c077e9075be701f697ed07.zip | |
ch-1a.pl improved
| -rwxr-xr-x | challenge-248/steve-g-lynn/perl/ch-1a.pl | 22 |
1 files 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); |
