aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-05-13 09:55:42 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-05-13 09:55:42 +0100
commit2fd3fd6d3443c4c08c789d2116cb2bfa3d50be64 (patch)
tree0f383dd3e662c9378af959e8dbcc14b736046668
parenta55ad5eaa86651991f89035202fc71e8eacdc931 (diff)
downloadperlweeklychallenge-club-2fd3fd6d3443c4c08c789d2116cb2bfa3d50be64.tar.gz
perlweeklychallenge-club-2fd3fd6d3443c4c08c789d2116cb2bfa3d50be64.tar.bz2
perlweeklychallenge-club-2fd3fd6d3443c4c08c789d2116cb2bfa3d50be64.zip
Update README.md
-rw-r--r--challenge-112/james-smith/README.md17
1 files changed, 11 insertions, 6 deletions
diff --git a/challenge-112/james-smith/README.md b/challenge-112/james-smith/README.md
index 40f82a0eec..f34255640c 100644
--- a/challenge-112/james-smith/README.md
+++ b/challenge-112/james-smith/README.md
@@ -156,7 +156,7 @@ it or remove them if we come across a "`..`".
or "`.`".
```perl
-sub canonical_path_string_fast {
+sub canonical_path_string {
my $path = shift;
my @directories = split m{/}, $path;
my $canonical_path = '';
@@ -271,7 +271,8 @@ $a=1,@_=grep{''ne$_&&'.'ne$_}split/\//,shift;
$_[$a]ne'..'?$a++:$a?splice@_,--$a,2:shift while$a<@_;
join'/','',@_
}
-
+```
+```perl
sub canonical_path_compact {
## Make shorted by using regex and ternarys
$a=1,@_=grep{!/^\.?$/}split/\//,shift;
@@ -302,25 +303,29 @@ $a='';
'..'ne$_?$a.="/$_"x!/^\.?$/:$a=~s#/[^/]+$## for split'/',shift;
$a
}
-
+```
+```perl
sub canonical_path_short {
$a='';
/^\.?$/?0:'..'ne$_?$a.="/$_":$a=~s#/[^/]+$## for split'/',shift;
$a
}
-
+```
+```perl
sub canonical_path_fast {
$a='';
'.'ne$_&&''ne$_&&('..'ne$_?$a.="/$_":$a=~s#/[^/]+$##)for split'/',shift;
$a
}
-
+```
+```perl
sub canonical_path_fastest {
$a='';
'.'ne$_&&''ne$_&&('..'ne$_?$a.='/'.$_:substr$a,rindex($a,'/'),~0,'')for split'/',shift;
$a
}
-
+```
+```perl
my $s;
sub canonical_path_global {
$s='';