diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-06-21 00:44:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-21 00:44:31 +0100 |
| commit | 929e3d70ee41b35c94d76a1082e8d048ea0201f0 (patch) | |
| tree | 325a03fcbca73325014451b56af0d04bdb27992e /challenge-117 | |
| parent | 5b5e2c158c109d45f7066aad0f0484acf7de847f (diff) | |
| parent | f990fad1624bbc8e7def7ca76703aef0aad3e300 (diff) | |
| download | perlweeklychallenge-club-929e3d70ee41b35c94d76a1082e8d048ea0201f0.tar.gz perlweeklychallenge-club-929e3d70ee41b35c94d76a1082e8d048ea0201f0.tar.bz2 perlweeklychallenge-club-929e3d70ee41b35c94d76a1082e8d048ea0201f0.zip | |
Merge pull request #4302 from E7-87-83/newt
silightly improve ch-2.pl codes
Diffstat (limited to 'challenge-117')
| -rw-r--r-- | challenge-117/cheok-yin-fung/perl/ch-2.pl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/challenge-117/cheok-yin-fung/perl/ch-2.pl b/challenge-117/cheok-yin-fung/perl/ch-2.pl index 40909a2072..a9d6a433f5 100644 --- a/challenge-117/cheok-yin-fung/perl/ch-2.pl +++ b/challenge-117/cheok-yin-fung/perl/ch-2.pl @@ -25,6 +25,7 @@ while (scalar @newarr <= $N) { print "Number of Paths: ", $newarr[-1]; print "\n"; + # * * * * * * * sub ways { my $K = $_[0]; @@ -36,17 +37,17 @@ sub ways { $newstp = [ [ 'L' x $ord ] ]; for my $i (1.. $ord - 1) { push @{$newstp->[$i]}, $stp->[$i-1]->[$_] . 'R' - for (0.. scalar $stp->[$i-1]->@* - 1 ); + for (0.. $stp->[$i-1]->$#*); push @{$newstp->[$i]}, $stp->[$i]->[$_] . 'L' - for (0.. scalar $stp->[$i]->@* - 1 ); + for (0.. $stp->[$i]->$#*); push @{$newstp->[$i]}, $newstp->[$i-1]->[$_] . 'H' - for (0.. scalar $newstp->[$i-1]->@* - 1 ); + for (0.. $newstp->[$i-1]->$#*); } push @{$newstp->[$ord]}, $stp->[$ord-1]->[$_] . 'R' - for (0.. scalar @{$stp->[$ord-1]} - 1 ); + for (0.. $stp->[$ord-1]->$#*); push @{$newstp->[$ord]}, $newstp->[$ord-1]->[$_] . 'H' - for (0.. scalar @{$newstp->[$ord-1]} - 1 ); + for (0.. $newstp->[$ord-1]->$#*); } return $newstp->[-1]; |
