aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-330/roger-bell-west/crystal/ch-1.cr26
-rwxr-xr-xchallenge-330/roger-bell-west/crystal/ch-2.cr28
-rwxr-xr-xchallenge-330/roger-bell-west/javascript/ch-1.js34
-rwxr-xr-xchallenge-330/roger-bell-west/javascript/ch-2.js36
-rw-r--r--challenge-330/roger-bell-west/kotlin/ch-1.kt34
-rw-r--r--challenge-330/roger-bell-west/kotlin/ch-2.kt36
-rwxr-xr-xchallenge-330/roger-bell-west/lua/ch-1.lua54
-rwxr-xr-xchallenge-330/roger-bell-west/lua/ch-2.lua80
-rwxr-xr-xchallenge-330/roger-bell-west/perl/ch-1.pl23
-rwxr-xr-xchallenge-330/roger-bell-west/perl/ch-2.pl23
-rw-r--r--challenge-330/roger-bell-west/postscript/ch-1.ps70
-rw-r--r--challenge-330/roger-bell-west/postscript/ch-2.ps145
-rwxr-xr-xchallenge-330/roger-bell-west/python/ch-1.py25
-rwxr-xr-xchallenge-330/roger-bell-west/python/ch-2.py25
-rwxr-xr-xchallenge-330/roger-bell-west/raku/ch-1.p621
-rwxr-xr-xchallenge-330/roger-bell-west/raku/ch-2.p621
-rwxr-xr-xchallenge-330/roger-bell-west/ruby/ch-1.rb31
-rwxr-xr-xchallenge-330/roger-bell-west/ruby/ch-2.rb33
-rwxr-xr-xchallenge-330/roger-bell-west/rust/ch-1.rs29
-rwxr-xr-xchallenge-330/roger-bell-west/rust/ch-2.rs31
-rw-r--r--challenge-330/roger-bell-west/scala/ch-1.scala36
-rw-r--r--challenge-330/roger-bell-west/scala/ch-2.scala39
-rw-r--r--challenge-330/roger-bell-west/tests.json32
-rw-r--r--challenge-330/roger-bell-west/typst/ch-1.typ33
-rw-r--r--challenge-330/roger-bell-west/typst/ch-2.typ31
25 files changed, 976 insertions, 0 deletions
diff --git a/challenge-330/roger-bell-west/crystal/ch-1.cr b/challenge-330/roger-bell-west/crystal/ch-1.cr
new file mode 100755
index 0000000000..5507de43ca
--- /dev/null
+++ b/challenge-330/roger-bell-west/crystal/ch-1.cr
@@ -0,0 +1,26 @@
+#! /usr/bin/crystal
+
+def cleardigits(a)
+ out = Array(Char).new
+ a.chars.each do |c|
+ if c >= '0' && c <= '9'
+ out.pop
+ else
+ out.push(c)
+ end
+ end
+ out.join("")
+end
+
+require "spec"
+describe "cleardigits" do
+ it "test_ex1" do
+ cleardigits("cab12").should eq "c"
+ end
+ it "test_ex2" do
+ cleardigits("xy99").should eq ""
+ end
+ it "test_ex3" do
+ cleardigits("pa1erl").should eq "perl"
+ end
+end
diff --git a/challenge-330/roger-bell-west/crystal/ch-2.cr b/challenge-330/roger-bell-west/crystal/ch-2.cr
new file mode 100755
index 0000000000..3841172888
--- /dev/null
+++ b/challenge-330/roger-bell-west/crystal/ch-2.cr
@@ -0,0 +1,28 @@
+#! /usr/bin/crystal
+
+def titlecapital(a)
+ out = Array(String).new
+ a.split(" ").each do |w|
+ p = w.downcase
+ if p.size > 2
+ c = p.chars
+ c[0] = c[0].upcase
+ p = c.join("")
+ end
+ out.push(p)
+ end
+ out.join(" ")
+end
+
+require "spec"
+describe "titlecapital" do
+ it "test_ex1" do
+ titlecapital("PERL IS gREAT").should eq "Perl is Great"
+ end
+ it "test_ex2" do
+ titlecapital("THE weekly challenge").should eq "The Weekly Challenge"
+ end
+ it "test_ex3" do
+ titlecapital("YoU ARE A stAR").should eq "You Are a Star"
+ end
+end
diff --git a/challenge-330/roger-bell-west/javascript/ch-1.js b/challenge-330/roger-bell-west/javascript/ch-1.js
new file mode 100755
index 0000000000..24b7ffeda4
--- /dev/null
+++ b/challenge-330/roger-bell-west/javascript/ch-1.js
@@ -0,0 +1,34 @@
+#! /usr/bin/node
+
+"use strict"
+
+function cleardigits(a) {
+ let out = [];
+ for (let c of a.split("")) {
+ if (c >= '0' && c <= '9') {
+ out.pop();
+ } else {
+ out.push(c);
+ }
+ }
+ return out.join("");
+}
+
+if (cleardigits('cab12') == 'c') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (cleardigits('xy99') == '') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (cleardigits('pa1erl') == 'perl') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-330/roger-bell-west/javascript/ch-2.js b/challenge-330/roger-bell-west/javascript/ch-2.js
new file mode 100755
index 0000000000..a77e6b52d8
--- /dev/null
+++ b/challenge-330/roger-bell-west/javascript/ch-2.js
@@ -0,0 +1,36 @@
+#! /usr/bin/node
+
+"use strict"
+
+function titlecapital(a) {
+ let out = [];
+ for (let w of a.split(" ")) {
+ let p = w.toLowerCase();
+ if (p.length > 2) {
+ let c = p.split("")
+ c[0] = c[0].toUpperCase();
+ p = c.join("");
+ }
+ out.push(p);
+ }
+ return out.join(" ");
+}
+
+if (titlecapital('PERL IS gREAT') == 'Perl is Great') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (titlecapital('THE weekly challenge') == 'The Weekly Challenge') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (titlecapital('YoU ARE A stAR') == 'You Are a Star') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-330/roger-bell-west/kotlin/ch-1.kt b/challenge-330/roger-bell-west/kotlin/ch-1.kt
new file mode 100644
index 0000000000..38b5b3d01f
--- /dev/null
+++ b/challenge-330/roger-bell-west/kotlin/ch-1.kt
@@ -0,0 +1,34 @@
+fun cleardigits(a: String): String {
+ var out = ArrayList<Char>()
+ for (c in a.toCharArray()) {
+ if (c.isDigit()) {
+ out = ArrayList(out.dropLast(1))
+ } else {
+ out.add(c)
+ }
+ }
+ return out.joinToString("")
+}
+
+fun main() {
+
+ if (cleardigits("cab12") == "c") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (cleardigits("xy99") == "") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (cleardigits("pa1erl") == "perl") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-330/roger-bell-west/kotlin/ch-2.kt b/challenge-330/roger-bell-west/kotlin/ch-2.kt
new file mode 100644
index 0000000000..0e1d5c948d
--- /dev/null
+++ b/challenge-330/roger-bell-west/kotlin/ch-2.kt
@@ -0,0 +1,36 @@
+fun titlecapital(a: String): String {
+ var out = ArrayList<String>()
+ for (w in a.split(" ")) {
+ var p = w.lowercase()
+ if (p.length > 2) {
+ var c = p.toCharArray()
+ c[0] = c[0].uppercaseChar()
+ p = c.joinToString("")
+ }
+ out.add(p)
+ }
+ return out.joinToString(" ")
+}
+
+fun main() {
+
+ if (titlecapital("PERL IS gREAT") == "Perl is Great") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (titlecapital("THE weekly challenge") == "The Weekly Challenge") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (titlecapital("YoU ARE A stAR") == "You Are a Star") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-330/roger-bell-west/lua/ch-1.lua b/challenge-330/roger-bell-west/lua/ch-1.lua
new file mode 100755
index 0000000000..f2b1e1f772
--- /dev/null
+++ b/challenge-330/roger-bell-west/lua/ch-1.lua
@@ -0,0 +1,54 @@
+#! /usr/bin/lua
+
+function split(t)
+ local cl = {}
+ string.gsub(t,
+ "(.)",
+ function(c)
+ table.insert(cl, c)
+ end
+ )
+ return cl
+end
+
+function join(t)
+ local out=""
+ for i, v in ipairs(t) do
+ out = out .. v
+ end
+ return out
+end
+
+function cleardigits(a)
+ local out = {}
+ for _, c in ipairs(split(a)) do
+ if c >= "0" and c <= "9" then
+ table.remove(out, #out)
+ else
+ table.insert(out, c)
+ end
+ end
+ return join(out)
+end
+
+if cleardigits("cab12") == "c" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if cleardigits("xy99") == "" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if cleardigits("pa1erl") == "perl" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+
diff --git a/challenge-330/roger-bell-west/lua/ch-2.lua b/challenge-330/roger-bell-west/lua/ch-2.lua
new file mode 100755
index 0000000000..06b0d0875d
--- /dev/null
+++ b/challenge-330/roger-bell-west/lua/ch-2.lua
@@ -0,0 +1,80 @@
+#! /usr/bin/lua
+
+function split(t)
+ local cl = {}
+ string.gsub(t,
+ "(.)",
+ function(c)
+ table.insert(cl, c)
+ end
+ )
+ return cl
+end
+
+function splits(inputstr, sep)
+ sep=sep or '%s'
+ local t={}
+ for field,s in string.gmatch(inputstr, "([^"..sep.."]*)("..sep.."?)") do
+ table.insert(t,field)
+ if s=="" then
+ return t
+ end
+ end
+end
+
+function join(t)
+ local out=""
+ for i, v in ipairs(t) do
+ out = out .. v
+ end
+ return out
+end
+
+function joins(t,pad)
+ local out=""
+ local later = false
+ for k,v in pairs(t) do
+ if later then
+ out = out .. pad
+ end
+ out = out .. v
+ later = true
+ end
+ return out
+end
+
+function titlecapital(a)
+ local out = {}
+ for _, w in ipairs(splits(a, " ")) do
+ local p = string.lower(w)
+ if #p > 2 then
+ local c = split(p)
+ c[1] = string.upper(c[1])
+ p = join(c)
+ end
+ table.insert(out, p)
+ end
+ return joins(out, " ")
+end
+
+if titlecapital("PERL IS gREAT") == "Perl is Great" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if titlecapital("THE weekly challenge") == "The Weekly Challenge" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if titlecapital("YoU ARE A stAR") == "You Are a Star" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+
diff --git a/challenge-330/roger-bell-west/perl/ch-1.pl b/challenge-330/roger-bell-west/perl/ch-1.pl
new file mode 100755
index 0000000000..9c94ef69b4
--- /dev/null
+++ b/challenge-330/roger-bell-west/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 3;
+
+is(cleardigits('cab12'), 'c', 'example 1');
+is(cleardigits('xy99'), '', 'example 2');
+is(cleardigits('pa1erl'), 'perl', 'example 3');
+
+sub cleardigits($a) {
+ my @out;
+ foreach my $c (split '', $a) {
+ if ($c =~ /\d/) {
+ pop @out;
+ } else {
+ push @out, $c;
+ }
+ }
+ join('', @out);
+}
diff --git a/challenge-330/roger-bell-west/perl/ch-2.pl b/challenge-330/roger-bell-west/perl/ch-2.pl
new file mode 100755
index 0000000000..8ac9cf8db5
--- /dev/null
+++ b/challenge-330/roger-bell-west/perl/ch-2.pl
@@ -0,0 +1,23 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 3;
+
+is(titlecapital('PERL IS gREAT'), 'Perl is Great', 'example 1');
+is(titlecapital('THE weekly challenge'), 'The Weekly Challenge', 'example 2');
+is(titlecapital('YoU ARE A stAR'), 'You Are a Star', 'example 3');
+
+sub titlecapital($a) {
+ my @out;
+ foreach my $w (split ' ', $a) {
+ my $p = lc($w);
+ if (length($p) > 2) {
+ $p = ucfirst($p);
+ }
+ push @out, $p;
+ }
+ join(' ', @out);
+}
diff --git a/challenge-330/roger-bell-west/postscript/ch-1.ps b/challenge-330/roger-bell-west/postscript/ch-1.ps
new file mode 100644
index 0000000000..6cfdbf4241
--- /dev/null
+++ b/challenge-330/roger-bell-west/postscript/ch-1.ps
@@ -0,0 +1,70 @@
+%!PS
+
+% begin included library code
+% see https://codeberg.org/Firedrake/postscript-libraries/
+/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
+
+/c.isdigit {
+ dup 48 ge exch 57 le and
+} bind def
+
+/a2s {
+ 2 dict begin
+ /i exch def
+ i length dup string /o exch def
+ 1 sub 0 exch 1 exch {
+ dup i 3 -1 roll get o 3 1 roll put
+ } for
+ o
+ end
+} bind def
+
+/test.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} 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
+
+
+% end included library code
+
+/cleardigits {
+ 0 dict begin
+ [ exch
+ {
+ dup c.isdigit {
+ pop pop
+ } if
+ } forall
+ ] a2s
+ end
+} bind def
+
+(cleardigits) test.start
+(cab12) cleardigits (c) eq test
+(xy99) cleardigits () eq test
+(pa1erl) cleardigits (perl) eq test
+test.end
diff --git a/challenge-330/roger-bell-west/postscript/ch-2.ps b/challenge-330/roger-bell-west/postscript/ch-2.ps
new file mode 100644
index 0000000000..ad8a3b895f
--- /dev/null
+++ b/challenge-330/roger-bell-west/postscript/ch-2.ps
@@ -0,0 +1,145 @@
+%!PS
+
+% begin included library code
+% see https://codeberg.org/Firedrake/postscript-libraries/
+/a2s {
+ 2 dict begin
+ /i exch def
+ i length dup string /o exch def
+ 1 sub 0 exch 1 exch {
+ dup i 3 -1 roll get o 3 1 roll put
+ } for
+ o
+ end
+} bind def
+
+
+
+/test.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} bind def
+
+/strconcat % (a) (b) -> (ab)
+{
+ [
+ 3 -1 roll
+ s2a aload length
+ 2 add -1 roll
+ s2a aload pop
+ ] a2s
+} bind def
+
+/tolower {
+ s2a
+ [ exch
+ {
+ dup dup 65 ge exch 90 le and {
+ 32 add
+ } if
+ } forall
+ ] a2s
+} bind def
+
+/strsplit % (ajbjc) (j) -> [ (a) (b) (c) ]
+{
+ 1 dict begin
+ /sep exch def
+ [ exch
+ {
+ dup length 0 eq {
+ pop
+ exit
+ } {
+ sep search {
+ exch pop
+ dup length 0 eq {
+ pop
+ } {
+ exch
+ } ifelse
+ } {
+ ()
+ } ifelse
+ } ifelse
+ } 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
+
+/s2a {
+ [ exch { } forall ]
+} 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
+
+/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
+
+
+% end included library code
+
+/titlecapital {
+ 0 dict begin
+ [ exch
+ ( ) strsplit
+ {
+ tolower
+ dup length 2 gt {
+ s2a /c exch def
+ c 0 c 0 get 223 and put
+ c a2s
+ } if
+ } forall
+ ] ( ) strjoin
+ end
+} bind def
+
+(titlecapital) test.start
+(PERL IS gREAT) titlecapital (Perl is Great) eq test
+(THE weekly challenge) titlecapital (The Weekly Challenge) eq test
+(YoU ARE A stAR) titlecapital (You Are a Star) eq test
+test.end
diff --git a/challenge-330/roger-bell-west/python/ch-1.py b/challenge-330/roger-bell-west/python/ch-1.py
new file mode 100755
index 0000000000..3b88e51361
--- /dev/null
+++ b/challenge-330/roger-bell-west/python/ch-1.py
@@ -0,0 +1,25 @@
+#! /usr/bin/python3
+
+def cleardigits(a):
+ out = []
+ for c in a:
+ if c.isdigit():
+ out.pop()
+ else:
+ out.append(c)
+ return "".join(out)
+
+import unittest
+
+class TestCleardigits(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(cleardigits("cab12"), "c", 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(cleardigits("xy99"), "", 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(cleardigits("pa1erl"), "perl", 'example 3')
+
+unittest.main()
diff --git a/challenge-330/roger-bell-west/python/ch-2.py b/challenge-330/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..f49af0a50a
--- /dev/null
+++ b/challenge-330/roger-bell-west/python/ch-2.py
@@ -0,0 +1,25 @@
+#! /usr/bin/python3
+
+def titlecapital(a):
+ out = []
+ for w in a.split(" "):
+ p = w.lower()
+ if len(p) > 2:
+ p = p.title()
+ out.append(p)
+ return " ".join(out)
+
+import unittest
+
+class TestTitlecapital(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(titlecapital("PERL IS gREAT"), "Perl is Great", 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(titlecapital("THE weekly challenge"), "The Weekly Challenge", 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(titlecapital("YoU ARE A stAR"), "You Are a Star", 'example 3')
+
+unittest.main()
diff --git a/challenge-330/roger-bell-west/raku/ch-1.p6 b/challenge-330/roger-bell-west/raku/ch-1.p6
new file mode 100755
index 0000000000..6f324f75aa
--- /dev/null
+++ b/challenge-330/roger-bell-west/raku/ch-1.p6
@@ -0,0 +1,21 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 3;
+
+is(cleardigits('cab12'), 'c', 'example 1');
+is(cleardigits('xy99'), '', 'example 2');
+is(cleardigits('pa1erl'), 'perl', 'example 3');
+
+sub cleardigits($a) {
+ my @out;
+ for $a.comb -> $c {
+ if ($c ~~ /\d/) {
+ @out.pop;
+ } else {
+ @out.push($c);
+ }
+ }
+ @out.join('');
+}
diff --git a/challenge-330/roger-bell-west/raku/ch-2.p6 b/challenge-330/roger-bell-west/raku/ch-2.p6
new file mode 100755
index 0000000000..6b3042e7fe
--- /dev/null
+++ b/challenge-330/roger-bell-west/raku/ch-2.p6
@@ -0,0 +1,21 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 3;
+
+is(titlecapital('PERL IS gREAT'), 'Perl is Great', 'example 1');
+is(titlecapital('THE weekly challenge'), 'The Weekly Challenge', 'example 2');
+is(titlecapital('YoU ARE A stAR'), 'You Are a Star', 'example 3');
+
+sub titlecapital($a) {
+ my @out;
+ for $a.split(' ') -> $w {
+ my $p = lc($w);
+ if ($p.chars > 2) {
+ $p = tclc($p);
+ }
+ @out.push($p);
+ }
+ join(' ', @out);
+}
diff --git a/challenge-330/roger-bell-west/ruby/ch-1.rb b/challenge-330/roger-bell-west/ruby/ch-1.rb
new file mode 100755
index 0000000000..62950398d2
--- /dev/null
+++ b/challenge-330/roger-bell-west/ruby/ch-1.rb
@@ -0,0 +1,31 @@
+#! /usr/bin/ruby
+
+def cleardigits(a)
+ out = Array.new
+ a.chars.each do |c|
+ if c >= '0' && c <= '9'
+ out.pop
+ else
+ out.push(c)
+ end
+ end
+ out.join("")
+end
+
+require 'test/unit'
+
+class TestCleardigits < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal('c', cleardigits('cab12'))
+ end
+
+ def test_ex2
+ assert_equal('', cleardigits('xy99'))
+ end
+
+ def test_ex3
+ assert_equal('perl', cleardigits('pa1erl'))
+ end
+
+end
diff --git a/challenge-330/roger-bell-west/ruby/ch-2.rb b/challenge-330/roger-bell-west/ruby/ch-2.rb
new file mode 100755
index 0000000000..f650488d43
--- /dev/null
+++ b/challenge-330/roger-bell-west/ruby/ch-2.rb
@@ -0,0 +1,33 @@
+#! /usr/bin/ruby
+
+def titlecapital(a)
+ out = Array.new
+ a.split(" ").each do |w|
+ p = w.downcase
+ if p.size > 2
+ c = p.chars
+ c[0] = c[0].upcase
+ p = c.join("")
+ end
+ out.push(p)
+ end
+ out.join(" ")
+end
+
+require 'test/unit'
+
+class TestTitlecapital < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal('Perl is Great', titlecapital('PERL IS gREAT'))
+ end
+
+ def test_ex2
+ assert_equal('The Weekly Challenge', titlecapital('THE weekly challenge'))
+ end
+
+ def test_ex3
+ assert_equal('You Are a Star', titlecapital('YoU ARE A stAR'))
+ end
+
+end
diff --git a/challenge-330/roger-bell-west/rust/ch-1.rs b/challenge-330/roger-bell-west/rust/ch-1.rs
new file mode 100755
index 0000000000..a263d8be15
--- /dev/null
+++ b/challenge-330/roger-bell-west/rust/ch-1.rs
@@ -0,0 +1,29 @@
+#! /bin/sh
+//usr/bin/env rustc --test $0 -o ${0}x && ./${0}x --nocapture; rm -f ${0}x ; exit
+
+#[test]
+fn test_ex1() {
+ assert_eq!(cleardigits("cab12"), "c");
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(cleardigits("xy99"), "");
+}
+
+#[test]
+fn test_ex3() {
+ assert_eq!(cleardigits("pa1erl"), "perl");
+}
+
+fn cleardigits(a: &str) -> String {
+ let mut out = Vec::new();
+ for c in a.chars().collect::<Vec<char>>() {
+ if c.is_ascii_digit() {
+ out.pop();
+ } else {
+ out.push(c);
+ }
+ }
+ out.into_iter().collect()
+}
diff --git a/challenge-330/roger-bell-west/rust/ch-2.rs b/challenge-330/roger-bell-west/rust/ch-2.rs
new file mode 100755
index 0000000000..92e84d21aa
--- /dev/null
+++ b/challenge-330/roger-bell-west/rust/ch-2.rs
@@ -0,0 +1,31 @@
+#! /bin/sh
+//usr/bin/env rustc --test $0 -o ${0}x && ./${0}x --nocapture; rm -f ${0}x ; exit
+
+#[test]
+fn test_ex1() {
+ assert_eq!(titlecapital("PERL IS gREAT"), "Perl is Great");
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(titlecapital("THE weekly challenge"), "The Weekly Challenge");
+}
+
+#[test]
+fn test_ex3() {
+ assert_eq!(titlecapital("YoU ARE A stAR"), "You Are a Star");
+}
+
+fn titlecapital(a: &str) -> String {
+ let mut out = Vec::new();
+ for w in a.split(' ') {
+ let mut p = w.to_ascii_lowercase();
+ if p.len() > 2 {
+ let mut c = p.chars().collect::<Vec<char>>();
+ c[0].make_ascii_uppercase();
+ p = c.into_iter().collect();
+ }
+ out.push(p);
+ }
+ out.join(" ")
+}
diff --git a/challenge-330/roger-bell-west/scala/ch-1.scala b/challenge-330/roger-bell-west/scala/ch-1.scala
new file mode 100644
index 0000000000..758051e8ec
--- /dev/null
+++ b/challenge-330/roger-bell-west/scala/ch-1.scala
@@ -0,0 +1,36 @@
+import scala.collection.mutable.ListBuffer
+
+object Cleardigits {
+ def cleardigits(a: String): String = {
+ var out = new ListBuffer[Char]
+ for (c <- a) {
+ if (c.isDigit) {
+ out = out.dropRight(1)
+ } else {
+ out += c
+ }
+ }
+ out.mkString
+ }
+ def main(args: Array[String]) {
+ if (cleardigits("cab12") == "c") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (cleardigits("xy99") == "") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (cleardigits("pa1erl") == "perl") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-330/roger-bell-west/scala/ch-2.scala b/challenge-330/roger-bell-west/scala/ch-2.scala
new file mode 100644
index 0000000000..6ef92d54e9
--- /dev/null
+++ b/challenge-330/roger-bell-west/scala/ch-2.scala
@@ -0,0 +1,39 @@
+
+import scala.collection.mutable.ListBuffer
+
+object Titlecapital {
+ def titlecapital(a: String): String = {
+ var out = new ListBuffer[String]
+ for (w <- a.split(" ")) {
+ var p = w.toLowerCase()
+ if (p.length > 2) {
+ var c = p.to[ListBuffer]
+ c(0) = c(0).toUpper
+ p = c.mkString
+ }
+ out += p
+ }
+ out.mkString(" ")
+ }
+ def main(args: Array[String]) {
+ if (titlecapital("PERL IS gREAT") == "Perl is Great") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (titlecapital("THE weekly challenge") == "The Weekly Challenge") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (titlecapital("YoU ARE A stAR") == "You Are a Star") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-330/roger-bell-west/tests.json b/challenge-330/roger-bell-west/tests.json
new file mode 100644
index 0000000000..f1b7fc6b19
--- /dev/null
+++ b/challenge-330/roger-bell-west/tests.json
@@ -0,0 +1,32 @@
+{
+ "ch-1" : [
+ {
+ "function" : "cleardigits",
+ "arguments" : "cab12",
+ "result" : "c"
+ },
+ {
+ "arguments" : "xy99",
+ "result" : ""
+ },
+ {
+ "arguments" : "pa1erl",
+ "result" : "perl"
+ }
+ ],
+ "ch-2" : [
+ {
+ "function" : "titlecapital",
+ "arguments" : "PERL IS gREAT",
+ "result" : "Perl is Great"
+ },
+ {
+ "arguments" : "THE weekly challenge",
+ "result" : "The Weekly Challenge"
+ },
+ {
+ "arguments" : "YoU ARE A stAR",
+ "result" : "You Are a Star"
+ }
+ ]
+}
diff --git a/challenge-330/roger-bell-west/typst/ch-1.typ b/challenge-330/roger-bell-west/typst/ch-1.typ
new file mode 100644
index 0000000000..932e80f9de
--- /dev/null
+++ b/challenge-330/roger-bell-west/typst/ch-1.typ
@@ -0,0 +1,33 @@
+#let cleardigits(a) = {
+ let out = ()
+ for c in a {
+ if c >= "0" and c <