aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Lynn <bizlsg@localhost.localdomain>2022-10-04 08:48:21 +0800
committerStephen Lynn <bizlsg@localhost.localdomain>2022-10-04 08:48:21 +0800
commit095127078942640c5f4dd7a0f70a4ec1179cf8df (patch)
tree7866c0823ef7e2c9b89119aed543c1db823be082
parent0a2f900e76be04874b9ca7d427c7862b24596d59 (diff)
downloadperlweeklychallenge-club-095127078942640c5f4dd7a0f70a4ec1179cf8df.tar.gz
perlweeklychallenge-club-095127078942640c5f4dd7a0f70a4ec1179cf8df.tar.bz2
perlweeklychallenge-club-095127078942640c5f4dd7a0f70a4ec1179cf8df.zip
pwc-185
-rw-r--r--challenge-185/steve-g-lynn/blog.txt1
-rwxr-xr-xchallenge-185/steve-g-lynn/julia/ch-1.jl13
-rwxr-xr-xchallenge-185/steve-g-lynn/julia/ch-2.jl18
-rwxr-xr-xchallenge-185/steve-g-lynn/perl/ch-1.pl16
-rwxr-xr-xchallenge-185/steve-g-lynn/perl/ch-2.sh5
-rwxr-xr-xchallenge-185/steve-g-lynn/raku/ch-1.p615
-rwxr-xr-xchallenge-185/steve-g-lynn/raku/ch-2.sh8
7 files changed, 76 insertions, 0 deletions
diff --git a/challenge-185/steve-g-lynn/blog.txt b/challenge-185/steve-g-lynn/blog.txt
new file mode 100644
index 0000000000..441877d415
--- /dev/null
+++ b/challenge-185/steve-g-lynn/blog.txt
@@ -0,0 +1 @@
+https://thiujiac.blogspot.com/2022/10/pwc-185.html
diff --git a/challenge-185/steve-g-lynn/julia/ch-1.jl b/challenge-185/steve-g-lynn/julia/ch-1.jl
new file mode 100755
index 0000000000..d7b744eb07
--- /dev/null
+++ b/challenge-185/steve-g-lynn/julia/ch-1.jl
@@ -0,0 +1,13 @@
+#!/usr/bin/env julia
+
+function convert_mac(mac::String ) ::String
+ retval=String[]
+ for i in split(mac,".")
+ push!(retval, SubString(i,1,2), SubString(i,3,4))
+ end
+ return( join( retval, ":" ))
+end
+
+println(convert_mac("lac2.34f0.b1c2"))
+println(convert_mac("abc1.20f1.345a"))
+
diff --git a/challenge-185/steve-g-lynn/julia/ch-2.jl b/challenge-185/steve-g-lynn/julia/ch-2.jl
new file mode 100755
index 0000000000..06f5efe402
--- /dev/null
+++ b/challenge-185/steve-g-lynn/julia/ch-2.jl
@@ -0,0 +1,18 @@
+#!/usr/bin/env julia
+
+function mask( str::String) ::String
+ return( replace( str, r"[a-wyz0-9]"=>"x"; count=4) )
+end
+
+function mask( list::Vector{String}) ::Vector{String}
+ retval=String[]
+ for str in list
+ push!(retval, mask(str))
+ end
+ return retval
+end
+
+
+println(mask(["ab-cde-123", "123.abc.420", "3abc-0010.xy"]))
+println(mask(["1234567.a", "a-1234-bc", "a.b.c.d.e.f"]))
+
diff --git a/challenge-185/steve-g-lynn/perl/ch-1.pl b/challenge-185/steve-g-lynn/perl/ch-1.pl
new file mode 100755
index 0000000000..3e52abcda0
--- /dev/null
+++ b/challenge-185/steve-g-lynn/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+
+print &mac('1ac2.34f0.b1c2'),"\n";
+print &mac('abc1.20f1.345a'),"\n";
+
+sub mac {
+ my ($mac)=shift;
+
+ my @mac=split(/\./,$mac);
+ my @mac_;
+
+ foreach (@mac) {
+ push @mac_, (substr($_,0,2), substr($_,2,2));
+ }
+ return join(':',@mac_);
+}
diff --git a/challenge-185/steve-g-lynn/perl/ch-2.sh b/challenge-185/steve-g-lynn/perl/ch-2.sh
new file mode 100755
index 0000000000..469249ee9f
--- /dev/null
+++ b/challenge-185/steve-g-lynn/perl/ch-2.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+perl -E 'for my $test (@ARGV) {$test =~ s/[a-wyz0-9]/x/ for (1 .. 4); say $test}' 'ab-cde-123' '123.abc.420' '3abc-0010.xy'
+
+#perl -E 'for my $test (@ARGV) {$test =~ s/[a-wyz0-9]/x/ for (1 .. 4); say $test}' '1234567.a' 'a-1234-bc' 'a.b.c.d.e.f'
diff --git a/challenge-185/steve-g-lynn/raku/ch-1.p6 b/challenge-185/steve-g-lynn/raku/ch-1.p6
new file mode 100755
index 0000000000..276a701a91
--- /dev/null
+++ b/challenge-185/steve-g-lynn/raku/ch-1.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl6
+
+say &mac('1ac2.34f0.b1c2');
+say &mac('abc1.20f1.345a');
+
+sub mac ($mac) {
+
+ my @mac=$mac.split('.');
+ my @mac_;
+
+ for (@mac) -> $mac_ {
+ @mac_.append(substr($mac_,0,2), substr($mac_,2,2));
+ }
+ return @mac_.join(':');
+}
diff --git a/challenge-185/steve-g-lynn/raku/ch-2.sh b/challenge-185/steve-g-lynn/raku/ch-2.sh
new file mode 100755
index 0000000000..820c34bfd5
--- /dev/null
+++ b/challenge-185/steve-g-lynn/raku/ch-2.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+raku -e '@*ARGS.map({my $temp=$_; ($temp ~~ s/<[a .. w y z 0 .. 9]>/x/) for (0 .. 3); say $temp;})' 'ab-cde-123' '123.abc.420' '3abc-0010.xy'
+
+#raku -e '@*ARGS.map({my $temp=$_; ($temp ~~ s/<[a .. w y z 0 .. 9]>/x/) for (0 .. 3); say $temp;})' '1234567.a' 'a-1234-bc' 'a.b.c.d.e.f'
+
+
+