aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-09-27 15:42:14 +0100
committerGitHub <noreply@github.com>2022-09-27 15:42:14 +0100
commit081093384634e8d33b356cc854247f6587206673 (patch)
tree3f120917d71f2bcd0829a3a8f9256d71eb437b14
parent642b9c4df5cd463cbb354cbcfbefecb97cc97fa5 (diff)
parent470f4cbb35e5d72d67ac815fce39d3059f153714 (diff)
downloadperlweeklychallenge-club-081093384634e8d33b356cc854247f6587206673.tar.gz
perlweeklychallenge-club-081093384634e8d33b356cc854247f6587206673.tar.bz2
perlweeklychallenge-club-081093384634e8d33b356cc854247f6587206673.zip
Merge pull request #6807 from steve-g-lynn/branch-for-challenge-184
pwc 184
-rw-r--r--challenge-184/steve-g-lynn/blog.txt1
-rwxr-xr-xchallenge-184/steve-g-lynn/julia/ch-1.sh9
-rwxr-xr-xchallenge-184/steve-g-lynn/julia/ch-2.jl39
-rwxr-xr-xchallenge-184/steve-g-lynn/perl/ch-1.sh9
-rwxr-xr-xchallenge-184/steve-g-lynn/perl/ch-2.pl40
-rwxr-xr-xchallenge-184/steve-g-lynn/raku/ch-1.sh9
-rwxr-xr-xchallenge-184/steve-g-lynn/raku/ch-2.p631
7 files changed, 138 insertions, 0 deletions
diff --git a/challenge-184/steve-g-lynn/blog.txt b/challenge-184/steve-g-lynn/blog.txt
new file mode 100644
index 0000000000..40b68746bf
--- /dev/null
+++ b/challenge-184/steve-g-lynn/blog.txt
@@ -0,0 +1 @@
+https://thiujiac.blogspot.com/2022/09/pwc-184.html
diff --git a/challenge-184/steve-g-lynn/julia/ch-1.sh b/challenge-184/steve-g-lynn/julia/ch-1.sh
new file mode 100755
index 0000000000..3339bc7445
--- /dev/null
+++ b/challenge-184/steve-g-lynn/julia/ch-1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+julia -e 'using Printf; ctr=0; for mystring in ARGS; global ctr; @printf "%02i" ctr; print(SubString(mystring,3,6));print(" ");ctr+=1;end;println("")' 'ab1234' 'cd5678' 'ef1342'
+
+#001234 015678 021342
+
+#julia -e 'using Printf; ctr=0; for mystring in ARGS; global ctr; @printf "%02i" ctr; print(SubString(mystring,3,6));print(" ");ctr+=1;end;println("")' 'pq1122' 'rs3334'
+
+#001122 013334
diff --git a/challenge-184/steve-g-lynn/julia/ch-2.jl b/challenge-184/steve-g-lynn/julia/ch-2.jl
new file mode 100755
index 0000000000..f824916215
--- /dev/null
+++ b/challenge-184/steve-g-lynn/julia/ch-2.jl
@@ -0,0 +1,39 @@
+#!/usr/bin/env julia
+
+list=("a 1 2 b 0","3 c 4 d")
+
+#Output
+#[['1', '2', '0'], ['3', '4']]
+#[['a', 'b'], ['c', 'd']]
+
+
+#list=("1 2", "p q r","s 3", "4 5 t")
+
+#Output:
+#[['1', '2'], ['3'], ['4', '5']]
+#[['p', 'q', 'r'], ['s'], ['t']]
+
+g_numbers=Vector{Char}[]
+g_alphas=Vector{Char}[]
+
+for string in list
+ numbers=Char[]
+ alphas=Char[]
+ for char in split(string)
+ char=only(char) #-- coerce str to char
+ if char in '0':'9'
+ push!(numbers,char)
+ elseif char in 'a':'z'
+ push!(alphas,char)
+ end
+ end
+ if length(numbers) > 0
+ push!(g_numbers,numbers)
+ end
+ if length(alphas) > 0
+ push!(g_alphas,alphas)
+ end
+end
+
+println(g_numbers)
+println(g_alphas)
diff --git a/challenge-184/steve-g-lynn/perl/ch-1.sh b/challenge-184/steve-g-lynn/perl/ch-1.sh
new file mode 100755
index 0000000000..cd3e6f587e
--- /dev/null
+++ b/challenge-184/steve-g-lynn/perl/ch-1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+perl -e 'my $ctr=0; for my $x ("00" .. "99") {print $x . substr($ARGV[$ctr++],2,4) . " "; last if $ctr >= @ARGV;} print "\n";' 'ab1234' 'cd5678' 'ef1342'
+
+#001234 015678 021342
+
+#perl -e 'my $ctr=0; for my $x ("00" .. "99") {print $x . substr($ARGV[$ctr++],2,4) . " "; last if $ctr >= @ARGV;} print "\n";' 'pq1122' 'rs3334'
+
+#001122 013334
diff --git a/challenge-184/steve-g-lynn/perl/ch-2.pl b/challenge-184/steve-g-lynn/perl/ch-2.pl
new file mode 100755
index 0000000000..15fb3ad532
--- /dev/null
+++ b/challenge-184/steve-g-lynn/perl/ch-2.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+
+my @list=('a 1 2 b 0', '3 c 4 d');
+
+# output:
+
+#[ [1 2 0] [3 4] ]
+#[ [a b] [c d] ]
+
+#my @list=('1 2', 'p q r', 's 3', '4 5 t');
+
+#[ [1 2] [3] [4 5] ]
+#[ [p q r] [s] [t] ]
+
+
+my (@numbers, @alphas);
+
+for my $string (@list) {
+ my $ra_numbers=[];
+ my $ra_alphas=[];
+ for my $char (split /\s+/, $string) {
+ ($char =~ /[0-9]/) && (push @$ra_numbers, $char);
+ ($char =~ /[a-z]/) && (push @$ra_alphas, $char);
+ }
+ (@$ra_numbers > 0) && (push @numbers, $ra_numbers);
+ (@$ra_alphas > 0) && (push @alphas, $ra_alphas);
+}
+
+print "[ ";
+for my $ra_numbers (@numbers) {
+ print "[@$ra_numbers] ";
+}
+print "]\n";
+
+print "[ ";
+for my $ra_alphas (@alphas) {
+ print "[@$ra_alphas] ";
+}
+print "]\n";
+
diff --git a/challenge-184/steve-g-lynn/raku/ch-1.sh b/challenge-184/steve-g-lynn/raku/ch-1.sh
new file mode 100755
index 0000000000..7a597c3a84
--- /dev/null
+++ b/challenge-184/steve-g-lynn/raku/ch-1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+raku -e 'my $ctr=0; for ("00" .. "99") -> $x {print $x ~ @*ARGS[$ctr++].substr(2,4) ~ " "; last if $ctr >= @*ARGS }; print "\n";' 'ab1234' 'cd5678' 'ef1342'
+
+#001234 015678 021342
+
+#raku -e 'my $ctr=0; for ("00" .. "99") -> $x {print $x ~ @*ARGS[$ctr++].substr(2,4) ~ " "; last if $ctr >= @*ARGS }; print "\n";' 'pq1122' 'rs3334'
+
+#001122 013334
diff --git a/challenge-184/steve-g-lynn/raku/ch-2.p6 b/challenge-184/steve-g-lynn/raku/ch-2.p6
new file mode 100755
index 0000000000..d8c34a0384
--- /dev/null
+++ b/challenge-184/steve-g-lynn/raku/ch-2.p6
@@ -0,0 +1,31 @@
+#!/usr/bin/env perl6
+
+#my @list=('a 1 2 b 0', '3 c 4 d');
+
+# output:
+
+#[[1 2 0] [3 4]]
+#[[a b] [c d]]
+
+my @list=('1 2', 'p q r', 's 3', '4 5 t');
+
+#[[1 2] [3] [4 5]]
+#[[p q r] [s] [t]]
+
+
+my (@numbers, @alphas);
+
+for (@list) -> $string {
+ my @inner_numbers=[];
+ my @inner_alphas=[];
+ for ($string.split(/\s+/)) -> $char {
+ ($char ~~ /<[0..9]>/) && (push @inner_numbers, $char);
+ ($char ~~ /<[a..z]>/) && (push @inner_alphas, $char);
+ }
+ (@inner_numbers.elems > 0) && (push @numbers, @inner_numbers);
+ (@inner_alphas.elems > 0) && (push @alphas, @inner_alphas);
+}
+
+say @numbers;
+say @alphas;
+