aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-05-28 09:10:51 +0100
committerdrbaggy <js5@sanger.ac.uk>2022-05-28 09:10:51 +0100
commitb87f31021a2e7b4c8b1661ee5f1242914f8a3d49 (patch)
tree1139d1899cafc5a21374e74675cd75d0d0c427ed
parent97eb139aced39e013cfd6c75f568f47639d4d265 (diff)
downloadperlweeklychallenge-club-b87f31021a2e7b4c8b1661ee5f1242914f8a3d49.tar.gz
perlweeklychallenge-club-b87f31021a2e7b4c8b1661ee5f1242914f8a3d49.tar.bz2
perlweeklychallenge-club-b87f31021a2e7b4c8b1661ee5f1242914f8a3d49.zip
new versions
-rw-r--r--challenge-166/james-smith/perl/ch-2-ns.pl2
-rw-r--r--challenge-166/james-smith/perl/ch-2.pl14
2 files changed, 8 insertions, 8 deletions
diff --git a/challenge-166/james-smith/perl/ch-2-ns.pl b/challenge-166/james-smith/perl/ch-2-ns.pl
index 489643eb9f..5e4c771a83 100644
--- a/challenge-166/james-smith/perl/ch-2-ns.pl
+++ b/challenge-166/james-smith/perl/ch-2-ns.pl
@@ -1,3 +1,3 @@
/\//,$u{$'.'/'x-d}{$d{$`}=$`}++for<*/*>;$l<length?$l=length:1for(@p=sort keys%d),@_=keys%u;print$a=join('-'x$l,('+--')x@p,'+
'),sprintf($b="| %-${l}s "x@p.'|
-',@p),$a,map({$l=$_;@p>keys%{$u{$l}}?sprintf$b,map{$u{$l}{$_}?$l:''}@p:()}sort@_),$a
+',@p),$a,map({//;@p-%{$u{$'}}?sprintf$b,map{$' x$u{$'}{$_}}@p:()}sort@_),$a \ No newline at end of file
diff --git a/challenge-166/james-smith/perl/ch-2.pl b/challenge-166/james-smith/perl/ch-2.pl
index 90eae65eda..60462a45fd 100644
--- a/challenge-166/james-smith/perl/ch-2.pl
+++ b/challenge-166/james-smith/perl/ch-2.pl
@@ -30,7 +30,7 @@ sub z_diff {
## Declare variables
## my($l,%d,$F,@p,%u,$T,$H)=0;
- my( $length, %directories, %filenames =0;
+ my( $length, %directories, %filenames)=0;
## Read all sub-directories containing files and store
## in data structure as a hash of ordered arrays
@@ -146,20 +146,20 @@ sub z_diff_no_comments {
say $HORIZONTAL_LINE;
}
-## Merging the fetch/parse into the a single function gives us just 272 bytes
-## of perlly goodness {265 without the fn call overhead}
+## Merging the fetch/parse into the a single function gives us just 265 bytes
+## of perlly goodness {258 without the fn call overhead}
#23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789#
sub x{my($l,$F,%d,%u,@p)=0;/\//,$u{$'.'/'x-d}{$d{$`}=$`}++for<*/*>;$l<length?$l=
length:1for(@p=sort keys%d),@_=keys%u;print$a=join('-'x$l,('+--')x@p,"+\n"),
-sprintf($b="| %-${l}s "x@p."|\n",@p),$a,map({$l=$_;@p>keys%{$u{$l}}?sprintf$b,
-map{$u{$l}{$_}?$l:''}@p:()}sort@_),$a}
+sprintf($b="| %-${l}s "x@p."|\n",@p),$a,map({//;@p-%{$u{$'}}?sprintf$b,map{$u{$'
+}{$_}?$':''}@p:()}sort@_),$a}
-## 270 bytes (263 without fn overhead)
+## 263 bytes (256 without fn overhead)
#23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789#
sub z{my($l,$F,%d,%u,@p)=0;/\//,$u{$'.'/'x-d}{$d{$`}=$`}++for<*/*>;$l<length?$l=
length:1for(@p=sort keys%d),@_=keys%u;print$a=join('-'x$l,('+--')x@p,'+
'),sprintf($b="| %-${l}s "x@p.'|
-',@p),$a,map({$l=$_;@p>keys%{$u{$l}}?sprintf$b,map{$u{$l}{$_}?$l:''}@p:()}sort@_
+',@p),$a,map({//;@p-%{$u{$'}}?sprintf$b,map{$u{$'}{$_}?$':''}@p:()}sort@_
),$a}