aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-190/roger-bell-west/javascript/ch-1.js39
-rwxr-xr-xchallenge-190/roger-bell-west/javascript/ch-2.js87
-rw-r--r--challenge-190/roger-bell-west/kotlin/ch-1.kt31
-rw-r--r--challenge-190/roger-bell-west/kotlin/ch-2.kt64
-rwxr-xr-xchallenge-190/roger-bell-west/lua/ch-1.lua42
-rwxr-xr-xchallenge-190/roger-bell-west/lua/ch-2.lua98
-rwxr-xr-xchallenge-190/roger-bell-west/perl/ch-1.pl20
-rwxr-xr-xchallenge-190/roger-bell-west/perl/ch-2.pl53
-rw-r--r--challenge-190/roger-bell-west/postscript/ch-1.ps74
-rw-r--r--challenge-190/roger-bell-west/postscript/ch-2.ps275
-rwxr-xr-xchallenge-190/roger-bell-west/python/ch-1.py26
-rwxr-xr-xchallenge-190/roger-bell-west/python/ch-2.py49
-rwxr-xr-xchallenge-190/roger-bell-west/raku/ch-1.p618
-rwxr-xr-xchallenge-190/roger-bell-west/raku/ch-2.p649
-rwxr-xr-xchallenge-190/roger-bell-west/ruby/ch-1.rb30
-rwxr-xr-xchallenge-190/roger-bell-west/ruby/ch-2.rb57
-rw-r--r--challenge-190/roger-bell-west/rust/ch-1.rs30
-rwxr-xr-xchallenge-190/roger-bell-west/rust/ch-2.rs73
18 files changed, 1115 insertions, 0 deletions
diff --git a/challenge-190/roger-bell-west/javascript/ch-1.js b/challenge-190/roger-bell-west/javascript/ch-1.js
new file mode 100755
index 0000000000..8f50f557b9
--- /dev/null
+++ b/challenge-190/roger-bell-west/javascript/ch-1.js
@@ -0,0 +1,39 @@
+#! /usr/bin/node
+
+"use strict"
+
+function capitaldetection(s) {
+ if (s.match(/^([A-Z]+|[a-z]+|[A-Z][a-z]+)$/)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+if (capitaldetection("Perl")) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+
+if (capitaldetection("TPF")) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+
+if (!capitaldetection("PyThon")) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+
+if (capitaldetection("raku")) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-190/roger-bell-west/javascript/ch-2.js b/challenge-190/roger-bell-west/javascript/ch-2.js
new file mode 100755
index 0000000000..f1302d8195
--- /dev/null
+++ b/challenge-190/roger-bell-west/javascript/ch-2.js
@@ -0,0 +1,87 @@
+#! /usr/bin/node
+
+"use strict"
+
+function deepEqual(a,b)
+{
+ if( (typeof a == 'object' && a != null) &&
+ (typeof b == 'object' && b != null) )
+ {
+ var count = [0,0];
+ for( var key in a) count[0]++;
+ for( var key in b) count[1]++;
+ if( count[0]-count[1] != 0) {return false;}
+ for( var key in a)
+ {
+ if(!(key in b) || !deepEqual(a[key],b[key])) {return false;}
+ }
+ for( var key in b)
+ {
+ if(!(key in a) || !deepEqual(b[key],a[key])) {return false;}
+ }
+ return true;
+ }
+ else
+ {
+ return a === b;
+ }
+}
+
+function decodedlist(s) {
+ let stack = [[s]];
+ let out = new Set();
+ while (true) {
+ let ent = stack.shift();
+ let tail = ent.pop();
+ if (tail.length == 0) {
+ out.add(JSON.stringify(ent));
+ } else {
+ if (tail.slice(0,1) != "0") {
+ let q = [...ent];
+ q.push(tail.slice(0,1));
+ q.push(tail.slice(1));
+ stack.push(q);
+ }
+ if (tail.length >= 2) {
+ let v = parseInt(tail.slice(0,2));
+ if (v >= 1 && v <= 26) {
+ let q = [...ent];
+ q.push(tail.slice(0,2));
+ q.push(tail.slice(2));
+ stack.push(q);
+ }
+ }
+ }
+ if (stack.length == 0) {
+ break;
+ }
+ }
+ let k = []
+ let alphazero = "A".charCodeAt(0) - 1;
+ for (let x of out) {
+ k.push(JSON.parse(x).map(i => String.fromCharCode(alphazero + parseInt(i))).join(""));
+ }
+ k.sort();
+ return k;
+}
+
+if (deepEqual(decodedlist("11"), ["AA", "K"])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+
+if (deepEqual(decodedlist("1115"), ["AAAE", "AAO", "AKE", "KAE", "KO"])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+
+if (deepEqual(decodedlist("127"), ["ABG", "LG"])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-190/roger-bell-west/kotlin/ch-1.kt b/challenge-190/roger-bell-west/kotlin/ch-1.kt
new file mode 100644
index 0000000000..263d19ba72
--- /dev/null
+++ b/challenge-190/roger-bell-west/kotlin/ch-1.kt
@@ -0,0 +1,31 @@
+fun capitaldetection(s: String): Boolean {
+ val re = "^([A-Z]+|[a-z]+|[A-Z][a-z]+)$".toRegex()
+ return re.containsMatchIn(s)
+}
+
+fun main() {
+ if (capitaldetection("Perl")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ print(" ")
+ if (capitaldetection("TPF")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ print(" ")
+ if (!capitaldetection("PyThon")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ print(" ")
+ if (capitaldetection("raku")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ println("")
+}
diff --git a/challenge-190/roger-bell-west/kotlin/ch-2.kt b/challenge-190/roger-bell-west/kotlin/ch-2.kt
new file mode 100644
index 0000000000..3cfc8e37f6
--- /dev/null
+++ b/challenge-190/roger-bell-west/kotlin/ch-2.kt
@@ -0,0 +1,64 @@
+fun decodedlist(s: String): List<String> {
+ var stack = arrayListOf(arrayListOf(s))
+ var out = ArrayList<ArrayList<String>>()
+ while (true) {
+ var ent = stack.first()
+ stack = ArrayList(stack.drop(1))
+ var tail = ent.last()
+ ent = ArrayList(ent.dropLast(1))
+ if (tail.length == 0) {
+ out.add(ent)
+ } else {
+ if (tail.substring(0, 1) != "0") {
+ var q = ArrayList(ent)
+ q.add(tail.substring(0, 1))
+ q.add(tail.substring(1))
+ stack.add(q)
+ }
+ if (tail.length >= 2) {
+ val v = tail.substring(0,2).toInt()
+ if (v >= 1 && v <= 26) {
+ var q = ArrayList(ent)
+ q.add(tail.substring(0, 2))
+ q.add(tail.substring(2))
+ stack.add(q)
+ }
+ }
+ }
+ if (stack.size == 0) {
+ break
+ }
+ }
+ var k = ArrayList<String>()
+ val alphazero = 'A'.code - 1
+ for (x in out) {
+ var ss = ""
+ for (sc in x) {
+ ss += (sc.toInt() + alphazero).toChar()
+ }
+ k.add(ss)
+ }
+ k.sort()
+ return k
+}
+
+fun main() {
+ if (decodedlist("11") == listOf("AA", "K")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ print(" ")
+ if (decodedlist("1115") == listOf("AAAE", "AAO", "AKE", "KAE", "KO")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ print(" ")
+ if (decodedlist("127") == listOf("ABG", "LG")) {
+ print("Pass")
+ } else {
+ print("FAIL")
+ }
+ println("")
+}
diff --git a/challenge-190/roger-bell-west/lua/ch-1.lua b/challenge-190/roger-bell-west/lua/ch-1.lua
new file mode 100755
index 0000000000..4206513e4e
--- /dev/null
+++ b/challenge-190/roger-bell-west/lua/ch-1.lua
@@ -0,0 +1,42 @@
+#! /usr/bin/lua
+
+function capitaldetection(s)
+ if string.find(s,"^[a-z]+$") then
+ return true
+ end
+ if string.find(s,"^[A-Z]+$") then
+ return true
+ end
+ if string.find(s,"^[A-Z][a-z]+$") then
+ return true
+ end
+ return false
+end
+
+if capitaldetection("Perl") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if capitaldetection("TPF") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if not capitaldetection("PyThon") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if capitaldetection("raku") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
diff --git a/challenge-190/roger-bell-west/lua/ch-2.lua b/challenge-190/roger-bell-west/lua/ch-2.lua
new file mode 100755
index 0000000000..fdb2a2415b
--- /dev/null
+++ b/challenge-190/roger-bell-west/lua/ch-2.lua
@@ -0,0 +1,98 @@
+#! /usr/bin/lua
+
+-- by Michael Anderson at
+-- https://stackoverflow.com/questions/8722620/comparing-two-index-tables-by-index-value-in-lua
+function recursive_compare(t1,t2)
+ -- Use usual comparison first.
+ if t1==t2 then return true end
+ -- We only support non-default behavior for tables
+ if (type(t1)~="table") then return false end
+ -- They better have the same metatables
+ local mt1 = getmetatable(t1)
+ local mt2 = getmetatable(t2)
+ if( not recursive_compare(mt1,mt2) ) then return false end
+
+ -- Check each key-value pair
+ -- We have to do this both ways in case we miss some.
+ -- TODO: Could probably be smarter and not check those we've
+ -- already checked though!
+ for k1,v1 in pairs(t1) do
+ local v2 = t2[k1]
+ if( not recursive_compare(v1,v2) ) then return false end
+ end
+ for k2,v2 in pairs(t2) do
+ local v1 = t1[k2]
+ if( not recursive_compare(v1,v2) ) then return false end
+ end
+
+ return true
+end
+
+function decodedlist(s)
+ local stack = {{s}}
+ local out = {}
+ while true do
+ local ent = table.remove(stack, 1)
+ local tail = table.remove(ent)
+ if string.len(tail) == 0 then
+ table.insert(out, ent)
+ else
+ if string.sub(tail, 1, 1) ~= "0" then
+ local q = {}
+ for j,k in ipairs(ent) do
+ table.insert(q,k)
+ end
+ table.insert(q, string.sub(tail, 1, 1))
+ table.insert(q, string.sub(tail, 2))
+ table.insert(stack, q)
+ end
+ if string.len(tail) >= 2 then
+ local v = 0 + string.sub(tail, 1, 2)
+ if v >= 1 and v <= 26 then
+ local q = {}
+ for j,k in ipairs(ent) do
+ table.insert(q,k)
+ end
+ table.insert(q, v)
+ table.insert(q, string.sub(tail, 3))
+ table.insert(stack, q)
+ end
+ end
+ end
+ if #stack == 0 then
+ break
+ end
+ end
+ local k = {}
+ alphazero = string.byte("A") - 1
+ for i, x in ipairs(out) do
+ local ss = ""
+ for ii, sc in ipairs(x) do
+ ss = ss .. string.char(alphazero + sc)
+ end
+ table.insert(k, ss)
+ end
+ table.sort(k)
+ return k
+end
+
+if recursive_compare(decodedlist("11"), {"AA", "K"}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if recursive_compare(decodedlist("1115"), {"AAAE", "AAO", "AKE", "KAE", "KO"}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if recursive_compare(decodedlist("127"), {"ABG", "LG"}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
diff --git a/challenge-190/roger-bell-west/perl/ch-1.pl b/challenge-190/roger-bell-west/perl/ch-1.pl
new file mode 100755
index 0000000000..c171e59ff1
--- /dev/null
+++ b/challenge-190/roger-bell-west/perl/ch-1.pl
@@ -0,0 +1,20 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 4;
+
+is(capitaldetection("Perl"), 1, 'example 1');
+is(capitaldetection("TPF"), 1, 'example 2');
+is(capitaldetection("PyThon"), 0, 'example 3');
+is(capitaldetection("raku"), 1, 'example 4');
+
+sub capitaldetection($s) {
+ if ($s =~ /^([A-Z]+|[a-z]+|[A-Z][a-z]+)$/) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
diff --git a/challenge-190/roger-bell-west/perl/ch-2.pl b/challenge-190/roger-bell-west/perl/ch-2.pl
new file mode 100755
index 0000000000..abafccca7b
--- /dev/null
+++ b/challenge-190/roger-bell-west/perl/ch-2.pl
@@ -0,0 +1,53 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 3;
+
+use Storable qw(freeze thaw);
+
+is_deeply(decodedlist("11"), ["AA", "K"], 'example 1');
+is_deeply(decodedlist("1115"), ["AAAE", "AAO", "AKE", "KAE", "KO"], 'example 2');
+is_deeply(decodedlist("127"), ["ABG", "LG"], 'example 3');
+
+sub decodedlist($s) {
+ my @stack;
+ push @stack,[$s];
+ my %out;
+ while (1) {
+ my $ent = shift @stack;
+ my $tail = pop @{$ent};
+ if (length($tail) == 0) {
+ $out{freeze($ent)} = 1;
+ } else {
+ if (substr($tail, 0, 1) ne "0") {
+ push @stack, [
+ @{$ent},
+ substr($tail, 0, 1),
+ substr($tail, 1)
+ ];
+ }
+ if (length($tail) >= 2) {
+ my $v = 0 + substr($tail, 0, 2);
+ if ($v >= 1 && $v <= 26) {
+ push @stack, [
+ @{$ent},
+ substr($tail, 0, 2),
+ substr($tail, 2)
+ ];
+ }
+ }
+ }
+ if (scalar @stack == 0) {
+ last;
+ }
+ }
+ my @k;
+ my $alphazero = ord("A") - 1;
+ foreach my $x (keys %out) {
+ push @k, join("",map {chr($alphazero + $_)} @{thaw($x)});
+ }
+ return [sort @k];
+}
diff --git a/challenge-190/roger-bell-west/postscript/ch-1.ps b/challenge-190/roger-bell-west/postscript/ch-1.ps
new file mode 100644
index 0000000000..1c280720a5
--- /dev/null
+++ b/challenge-190/roger-bell-west/postscript/ch-1.ps
@@ -0,0 +1,74 @@
+%!PS
+
+% begin included library code
+% see https://github.com/Firedrake/postscript-libraries/
+/test {
+ /test.count test.count 1 add def
+ {
+ /test.pass test.pass 1 add def
+ } {
+ ( ) print
+ test.count (....) cvs print
+ (-fail) print
+ } ifelse
+} bind def
+
+/test.end {
+ ( ) print
+ test.count 0 gt {
+ (Passed ) print
+ test.pass (...) cvs print
+ (/) print
+ test.count (...) cvs print
+ ( \() print
+ test.pass 100 mul test.count idiv (...) cvs print
+ (%\)) print
+ (\r\n) print
+ } if
+} bind def
+
+/test.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} bind def
+
+
+% end included library code
+
+/uppercase {
+ (_) 0 get lt {
+ true
+ } {
+ false
+ } ifelse
+} bind def
+
+/capitaldetection {
+ 4 dict begin
+ /s exch def
+ /first s 0 get uppercase def
+ /second s 1 get uppercase def
+ first not second and {
+ false
+ } {
+ true
+ 2 1 s length 1 sub {
+ s exch get uppercase /this exch def
+ first second and this not and { % ABc
+ pop false exit
+ } if
+ second not this and { % AbC or abC
+ pop false exit
+ } if
+ } for
+ } ifelse
+ end
+} bind def
+
+(capitaldetection) test.start
+(Perl) capitaldetection test
+(TPF) capitaldetection test
+(PyThon) capitaldetection not test
+(raku) capitaldetection test
+test.end
diff --git a/challenge-190/roger-bell-west/postscript/ch-2.ps b/challenge-190/roger-bell-west/postscript/ch-2.ps
new file mode 100644
index 0000000000..f3dc30db30
--- /dev/null
+++ b/challenge-190/roger-bell-west/postscript/ch-2.ps
@@ -0,0 +1,275 @@
+%!PS
+
+% begin included library code
+% see https://github.com/Firedrake/postscript-libraries/
+/quicksort.partition {
+ 3 dict begin
+ /pivot arr hi lo add 2 idiv get def
+ /i lo 1 sub def
+ /j hi 1 add def
+ {
+ {
+ /i i 1 add def
+ arr i get pivot ge {
+ exit
+ } if
+ } loop
+ {
+ /j j 1 sub def
+ arr j get pivot le {
+ exit
+ } if
+ } loop
+ i j ge {
+ j
+ exit
+ } if
+ i j quicksort.swap
+ } loop
+ end
+} bind def
+
+/test.end {
+ ( ) print
+ test.count 0 gt {
+ (Passed ) print
+ test.pass (...) cvs print
+ (/) print
+ test.count (...) cvs print
+ ( \() print
+ test.pass 100 mul test.count idiv (...) cvs print
+ (%\)) print
+ (\r\n) print
+ } if
+} bind def
+
+/map { % array proc -> array
+ 2 dict begin
+ /p exch def
+ [ exch
+ {
+ p
+ } forall
+ ]
+} bind def
+
+/apush.right { % [a b] c -> [a b c]
+ exch
+ [ exch aload length 2 add -1 roll ]
+} bind def
+
+/strjoin % [(a) (b) (c)] (j) -> (ajbjc)
+{
+ 3 dict begin
+ /j exch def
+ dup 0 get /out exch def
+ /first true def
+ {
+ first {
+ pop
+ /first false def
+ } {
+ out j strconcat
+ exch strconcat
+ /out exch def
+ } ifelse
+ } forall
+ out
+ end
+} bind def
+
+/test {
+ /test.count test.count 1 add def
+ {
+ /test.pass test.pass 1 add def
+ } {
+ ( ) print
+ test.count (....) cvs print
+ (-fail) print
+ } ifelse
+} bind def
+
+/quicksort.main { % lo hi -> (null)
+ 3 dict begin
+ /hi exch def
+ /lo exch def
+ /xit false def
+ lo 0 lt {
+ /xit true def
+ } if
+ hi 0 lt {
+ /xit true def
+ } if
+ lo hi ge {
+ /xit true def
+ } if
+ xit not {
+ /p quicksort.partition def
+ lo p quicksort.main
+ p 1 add hi quicksort.main
+ } if
+ end
+} bind def
+
+/safestring {
+ dup length string cvs
+} bind def
+
+/apop.left { % [a b c] -> [b c] a
+ dup 0 get exch
+ [ exch aload length -1 roll pop ] exch
+} bind def
+
+/test.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} bind def
+
+/strconcat % (a) (b) -> (ab)
+{ exch dup length
+ 2 index length add string
+ dup dup 4 2 roll copy length
+ 4 -1 roll putinterval
+} bind def
+
+/apop.right { % [a b c] -> [a b] c
+ [ exch aload length 1 add 1 roll ] exch
+} bind def
+
+/deepeq {
+ 2 dict begin
+ /a exch def
+ /b exch def
+ a type b type eq {
+ a type /dicttype eq {
+ a length b length eq {
+ <<
+ a {
+ pop
+ true
+ } forall
+ b {
+ pop
+ true
+ } forall
+ >>
+ true exch
+ {
+ pop
+ dup a exch known {
+ dup b exch known {
+ dup a exch get exch b exch get deepeq not {
+ pop false
+ } if
+ } {
+ false
+ } ifelse
+ } {
+ false
+ } ifelse
+ } forall
+ } {
+ false
+ } ifelse
+ } {
+ a type dup /arraytype eq exch /stringtype eq or {
+ a length b length eq {
+ true
+ 0 1 a length 1 sub {
+ dup a exch get exch b exch get deepeq not {
+ pop false
+ exit
+ } if
+ } for
+ } {
+ false
+ } ifelse
+ } {
+ a b eq
+ } ifelse
+ } ifelse
+ } {
+ false
+ } ifelse
+ end
+} bind def
+
+/keys { % dict -> array of dict keys
+ [ exch
+ {
+ pop
+ } forall
+ ]
+} bind def
+
+/quicksort.swap {
+ 2 dict begin
+ /bi exch def
+ /ai exch def
+ arr ai get
+ arr bi get
+ arr exch ai exch put
+ arr exch bi exch put
+ end
+} bind def
+
+/quicksort { % [ a c b ] -> [ a b c ]
+ 1 dict begin
+ /arr exch def
+ arr length 0 gt {
+ 0 arr length 1 sub quicksort.main
+ } if
+ arr
+ end
+} bind def
+
+
+% end included library code
+
+/decodedlist {
+ 7 dict begin
+ /s exch def
+ /stack [ [ s safestring ] ] def
+ /out 0 dict def
+ {
+ stack apop.left /ent exch def /stack exch def
+ ent apop.right /tail exch def /ent exch def
+ tail length 0 eq {
+ out ent true put
+ } {
+ tail 0 1 getinterval (0) deepeq not {
+ /stack stack [
+ ent aload pop
+ tail 0 1 getinterval
+ tail 1 tail length 1 sub getinterval
+ ] apush.right def
+ } if
+ tail length 2 ge {
+ tail 0 2 getinterval cvi dup 1 ge exch 26 le and {
+ /stack stack [
+ ent aload pop
+ tail 0 2 getinterval
+ tail 2 tail length 2 sub getinterval
+ ] apush.right def
+ } if
+ } if
+ } ifelse
+ stack length 0 eq {
+ exit
+ } if
+ } loop
+ /alphazero (A) 0 get 1 sub def
+ [
+ out keys {
+ { cvi alphazero add /tmp 1 string def tmp exch 0 exch put tmp safestring } map () strjoin
+ } forall
+ ] quicksort
+ end
+} bind def
+
+(decodedlist) test.start
+(11) decodedlist [ (AA) (K) ] deepeq test
+(1115) decodedlist [ (AAAE) (AAO) (AKE) (KAE) (KO) ] deepeq test
+(127) decodedlist [ (ABG) (LG) ] deepeq test
+test.end
diff --git a/challenge-190/roger-bell-west/python/ch-1.py b/challenge-190/roger-bell-west/python/ch-1.py
new file mode 100755
index 0000000000..6a73fdf7c1
--- /dev/null
+++ b/challenge-190/roger-bell-west/python/ch-1.py
@@ -0,0 +1,26 @@
+#! /usr/bin/python3
+
+import unittest
+import re
+
+def capitaldetection(s):
+ if re.match(r"^([A-Z]+|[a-z]+|[A-Z][a-z]+)$", s):
+ return True
+ else:
+ return False
+
+class TestCapitaldetection(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(capitaldetection("Perl"), True, 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(capitaldetection("TPF"), True, 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(capitaldetection("PyThon"), False, 'example 3')
+
+ def test_ex4(self):
+ self.assertEqual(capitaldetection("raku"), True, 'example 4')
+
+unittest.main()
diff --git a/challenge-190/roger-bell-west/python/ch-2.py b/challenge-190/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..9114d511ba
--- /dev/null
+++ b/challenge-190/roger-bell-west/python/ch-2.py
@@ -0,0 +1,49 @@
+#! /usr/bin/python3
+
+import unittest
+
+from collections import deque
+
+def decodedlist(s):
+ stack = deque()
+ stack.append([s])
+ out = set()
+ while True:
+ ent = stack.popleft()
+ tail = ent.pop()
+ if len(tail) == 0:
+ out.add(tuple(ent))
+ else:
+ if tail[0] != "0":
+ q = ent.copy()
+ q.append(tail[0])
+ q.append(tail[1:])
+ stack.append(q)
+ if len(tail) >= 2:
+ v = int(tail[0:2])
+ if v >= 1 and v <= 26:
+ q = ent.copy()
+ q.append(tail[0:2])
+ q.append(tail[2:])
+ stack.append(q)
+ if len(stack) == 0:
+ break
+ k = []
+ alphazero = ord("A") - 1
+ for x in out:
+ k.append("".join(chr(int(cs)+alphazero) for cs in x))
+ k.sort()
+ return k
+
+class TestDecodecounts(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(decodedlist("11"), ["AA", "K"], 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(decodedlist("1115"), ["AAAE", "AAO", "AKE", "KAE", "KO"], 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(decodedlist("127"), ["ABG", "LG"], 'example 3')
+
+unittest.main()
diff --git a/challenge-190/roger-bell-west/raku/ch-1.p6 b/challenge-190/roger-bell-west/raku/ch-1.p6
new file mode 100755
index 0000000000..acc72697d8
--- /dev/null
+++ b/challenge-190/roger-bell-west/raku/ch-1.p6
@@ -0,0 +1,18 @@
+#! /usr/bin/perl6
+
+use Test;
+
+plan 4;
+
+is(capitaldetection("Perl"), True, 'example 1');
+is(capitaldetection("TPF"), True, 'example 2');
+is(capitaldetection("PyThon"), False, 'example 3');
+is(capitaldetection("raku"), True, 'example 4');
+
+sub capitaldetection($s) {
+ if ($s ~~ /^(<[A..Z]>+|<[a..z]>+|<[A..Z]><[a..z]>+)$/) {
+ return True;
+ } else {
+ return False;
+ }
+}
diff --git a/challenge-190/roger-bell-west/raku/ch-2.p6 b/challenge-190/roger-bell-west/raku/ch-2.p6
new file mode 100755
index 0000000000..84e770982e
--- /dev/null
+++ b/challenge-190/roger-bell-west/raku/ch-2.p6
@@ -0,0 +1,49 @@
+#! /usr/bin/perl6
+
+use Test;
+
+use MONKEY-SEE-NO-EVAL;
+
+plan 3;
+
+is-deeply(decodedlist("11"), ["AA", "K"], 'example 1');
+is-deeply(decodedlist("1115"), ["AAAE", "AAO", "AKE", "KAE", "KO"], 'example 2');
+is-deeply(decodedlist("127"), ["ABG", "LG"], 'example 3');
+
+sub decodedlist($s) {
+ my @stack;
+ @stack.push([$s]);
+ my $out = SetHash.new;
+ while (True) {
+ my $ent = @stack.shift;
+ my $tail = $ent.pop;
+ if ($tail.chars == 0) {
+ $out{$ent.raku} = True;
+ } else {
+ if (substr($tail, 0, 1) ne "0") {
+ my $q = $ent.clone;
+ $q.push(substr($tail, 0, 1));
+ $q.push(substr($tail, 1));
+ @stack.push($q);
+ }
+ if ($tail.chars >= 2) {
+ my $v = 0 + substr($tail, 0, 2);
+ if ($v >= 1 && $v <= 26) {
+ my $q = $ent.clone;
+ $q.push(substr($tail, 0, 2));
+ $q.push(substr($tail, 2));
+ @stack.push($q);
+ }
+ }
+ }
+ if (@stack.elems == 0) {
+ last;
+ }
+ }
+ my @k;
+ my $alphazero = ord("A") - 1;
+ for $out.keys -> $x {
+ @k.push(EVAL($x).map({chr($alphazero + $_)}).join(""));
+ }
+ return Array(@k.sort);
+}
diff --git a/challenge-190/roger-bell-west/ruby/ch-1.rb b/challenge-190/roger-bell-west/ruby/ch-1.rb
new file mode 100755
index 0000000000..934901e241
--- /dev/null
+++ b/challenge-190/roger-bell-west/ruby/ch-1.rb
@@ -0,0 +1,30 @@
+#! /usr/bin/ruby
+
+require 'test/unit'
+
+def capitaldetection(s)
+ if /^([A-Z]+|[a-z]+|[A-Z][a-z]+)$/.match(s) then
+ return true
+ else
+ return false
+ end
+end
+
+class TestDivisiblepairs < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal(true, capitaldetection("Perl"))
+ end
+
+ def test_ex2
+ assert_equal(true, capitaldetection("TPF"))
+ end
+
+ def test_ex3
+ assert_equal(false, capitaldetection("PyThon"))
+ end
+
+ def test_ex4
+ assert_equal(true, capitaldetection("raku"))
+ end
+end
diff --git a/challenge-190/roger-bell-west/ruby/ch-2.rb b/challenge-190/roger-bell-west/ruby/ch-2.rb
new file mode 100755
index 0000000000..6121b6651b
--- /dev/null
+++ b/challenge-190/roger-bell-west/ruby/ch-2.rb
@@ -0,0 +1,57 @@
+#! /usr/bin/ruby
+
+require 'test/unit'
+
+require 'set'
+
+def decodedlist(s)
+ stack = [[s]]
+ out = Set.new
+ while true do
+ ent = stack.shift
+ tail = ent.pop
+ if tail.length == 0 then
+ out.add(Marshal.dump(ent))
+ else
+ if tail[0] != "0" then
+ q = ent[0..-1]
+ q.push(tail[0])
+ q.push(tail[1..-1])
+ stack.push(q)
+ end
+ if tail.length >= 2 then
+ v = tail[0..1].to_i
+ if v >=1 and v <= 26 then
+ q = ent[0..-1]
+ q.push(tail[0..1])
+ q.push(tail[2..-1])
+ stack.push(q)
+ end
+ end
+ end
+ if stack.length == 0 then
+ break
+ end
+ end
+ k = []
+ alphazero = "A".ord - 1
+ out.each do |x|
+ k.push(Marshal.load(x).map{|cs| (cs.to_i + alphazero).chr}.join(""))
+ end
+ return k.sort
+end<