aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLakpa Tashi Bhutia <lakpatashi@users.noreply.github.com>2023-11-25 05:13:12 +0000
committerLakpa Tashi Bhutia <lakpatashi@users.noreply.github.com>2023-11-25 05:13:12 +0000
commitea6fe5109935b1ce8bc3304411552de65705ee27 (patch)
tree37319300184af2cc1e7f6aaf42108656a54a616e
parentdc0651a859d9824512ffbd2c84aba36b7392e84f (diff)
downloadperlweeklychallenge-club-ea6fe5109935b1ce8bc3304411552de65705ee27.tar.gz
perlweeklychallenge-club-ea6fe5109935b1ce8bc3304411552de65705ee27.tar.bz2
perlweeklychallenge-club-ea6fe5109935b1ce8bc3304411552de65705ee27.zip
for both prob. v2 added.
-rwxr-xr-xchallenge-003/lakpatashi/perl/ch-1.pl9
-rwxr-xr-xchallenge-003/lakpatashi/perl/ch-2.pl12
2 files changed, 21 insertions, 0 deletions
diff --git a/challenge-003/lakpatashi/perl/ch-1.pl b/challenge-003/lakpatashi/perl/ch-1.pl
index bc76cc8bcf..8d10c07d3b 100755
--- a/challenge-003/lakpatashi/perl/ch-1.pl
+++ b/challenge-003/lakpatashi/perl/ch-1.pl
@@ -17,3 +17,12 @@ print join ' ',sort {$a<=>$b} @arr;
print "\n";
+
+sub v2 {
+ my ($a,$b,$c) = (5,3,2);
+ for my $num (0..7){
+ #say $num;
+ my ($i,$j,$k) = split //, sprintf("%03b", $num);
+ say ( $a**$i * $b**$j * $c**$k );
+ }
+} \ No newline at end of file
diff --git a/challenge-003/lakpatashi/perl/ch-2.pl b/challenge-003/lakpatashi/perl/ch-2.pl
index 32545f3617..5caa9471e1 100755
--- a/challenge-003/lakpatashi/perl/ch-2.pl
+++ b/challenge-003/lakpatashi/perl/ch-2.pl
@@ -33,3 +33,15 @@ sub PascalNext{
return join " ",@newArr;
}
#print "\n var:: $n\n";
+
+sub printPascal_v2 {
+ my ($numLine) = @_;
+ return if $numLine <3;
+ say ' 'x$numLine, 1;
+ my @pattern = (1,1);
+ say ' 'x($numLine-1),"@pattern";
+ for my $i (2..$numLine){
+ @pattern = ( 1, map( $pattern[$_-1]+$pattern[$_], 1..$#pattern ), 1 ) ;
+ say ' 'x($numLine-$i),"@pattern";
+ }
+} \ No newline at end of file