aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE7-87-83 <fungcheokyin@gmail.com>2021-06-21 07:40:14 +0800
committerE7-87-83 <fungcheokyin@gmail.com>2021-06-21 07:40:14 +0800
commitf990fad1624bbc8e7def7ca76703aef0aad3e300 (patch)
tree370a14b8a2bb18cbdb0ce4c94eaf2c9dc4243974
parent5e631f4b325d6ef41562ec1ef955e49e7da4ab75 (diff)
downloadperlweeklychallenge-club-f990fad1624bbc8e7def7ca76703aef0aad3e300.tar.gz
perlweeklychallenge-club-f990fad1624bbc8e7def7ca76703aef0aad3e300.tar.bz2
perlweeklychallenge-club-f990fad1624bbc8e7def7ca76703aef0aad3e300.zip
improve ch-2.pl codes
-rw-r--r--challenge-117/cheok-yin-fung/perl/ch-2.pl11
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];