aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-255/roger-bell-west/javascript/ch-1.js46
-rwxr-xr-xchallenge-255/roger-bell-west/javascript/ch-2.js34
-rw-r--r--challenge-255/roger-bell-west/kotlin/ch-1.kt37
-rw-r--r--challenge-255/roger-bell-west/kotlin/ch-2.kt30
-rwxr-xr-xchallenge-255/roger-bell-west/lua/ch-1.lua53
-rwxr-xr-xchallenge-255/roger-bell-west/lua/ch-2.lua36
-rwxr-xr-xchallenge-255/roger-bell-west/perl/ch-1.pl24
-rwxr-xr-xchallenge-255/roger-bell-west/perl/ch-2.pl21
-rw-r--r--challenge-255/roger-bell-west/postscript/ch-1.ps88
-rw-r--r--challenge-255/roger-bell-west/postscript/ch-2.ps168
-rwxr-xr-xchallenge-255/roger-bell-west/python/ch-1.py29
-rwxr-xr-xchallenge-255/roger-bell-west/python/ch-2.py28
-rwxr-xr-xchallenge-255/roger-bell-west/raku/ch-1.p622
-rwxr-xr-xchallenge-255/roger-bell-west/raku/ch-2.p617
-rwxr-xr-xchallenge-255/roger-bell-west/ruby/ch-1.rb34
-rwxr-xr-xchallenge-255/roger-bell-west/ruby/ch-2.rb26
-rwxr-xr-xchallenge-255/roger-bell-west/rust/ch-1.rs28
-rwxr-xr-xchallenge-255/roger-bell-west/rust/ch-2.rs26
-rw-r--r--challenge-255/roger-bell-west/scala/ch-1.scala39
-rw-r--r--challenge-255/roger-bell-west/scala/ch-2.scala29
-rw-r--r--challenge-255/roger-bell-west/tests.yaml30
21 files changed, 845 insertions, 0 deletions
diff --git a/challenge-255/roger-bell-west/javascript/ch-1.js b/challenge-255/roger-bell-west/javascript/ch-1.js
new file mode 100755
index 0000000000..9c403242c1
--- /dev/null
+++ b/challenge-255/roger-bell-west/javascript/ch-1.js
@@ -0,0 +1,46 @@
+#! /usr/bin/node
+
+"use strict"
+
+function oddcharacter(s, t) {
+ let ss = new Map;
+ for (let c of s.split("")) {
+ if (ss.has(c)) {
+ ss.set(c, ss.get(c) + 1);
+ } else {
+ ss.set(c, 1);
+ }
+ }
+ for (let c of t.split("")) {
+ if (ss.has(c)) {
+ const p = ss.get(c) - 1;
+ if (p == 0) {
+ ss.delete(c);
+ } else {
+ ss.set(c, p);
+ }
+ } else {
+ return c;
+ }
+ }
+ return '@';
+}
+
+if (oddcharacter('Perl', 'Preel') == 'e') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (oddcharacter('Weekly', 'Weeakly') == 'a') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (oddcharacter('Box', 'Boxy') == 'y') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-255/roger-bell-west/javascript/ch-2.js b/challenge-255/roger-bell-west/javascript/ch-2.js
new file mode 100755
index 0000000000..88d1649afc
--- /dev/null
+++ b/challenge-255/roger-bell-west/javascript/ch-2.js
@@ -0,0 +1,34 @@
+#! /usr/bin/node
+
+"use strict"
+
+function mostfrequentword(para, banned) {
+ let words = new Map;
+ for (let s of para.split(/[^A-Za-z]+/)) {
+ if (s.length > 0) {
+ if (words.has(s)) {
+ words.set(s, words.get(s) + 1);
+ } else {
+ words.set(s, 1);
+ }
+ }
+ }
+ words.delete(banned);
+ const m = Math.max(...words.values());
+ let v = [...words.keys()].filter(w => words.get(w) == m);
+ v.sort();
+ return v[0];
+}
+
+if (mostfrequentword('Joe hit a ball, the hit ball flew far after it was hit.', 'hit') == 'ball') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (mostfrequentword('Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.', 'the') == 'Perl') {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-255/roger-bell-west/kotlin/ch-1.kt b/challenge-255/roger-bell-west/kotlin/ch-1.kt
new file mode 100644
index 0000000000..b10d4dd1f5
--- /dev/null
+++ b/challenge-255/roger-bell-west/kotlin/ch-1.kt
@@ -0,0 +1,37 @@
+fun oddcharacter(s: String, t: String): Char {
+ var ss = mutableMapOf<Char, Int>().withDefault({0})
+ for (c in s.toCharArray()) {
+ ss.set(c, ss.getValue(c) + 1)
+ }
+ for (c in t.toCharArray()) {
+ if (ss.getValue(c) > 0) {
+ ss.set(c, ss.getValue(c) - 1)
+ } else {
+ return c
+ }
+ }
+ return '@'
+}
+
+fun main() {
+
+ if (oddcharacter("Perl", "Preel") == 'e') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (oddcharacter("Weekly", "Weeakly") == 'a') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (oddcharacter("Box", "Boxy") == 'y') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-255/roger-bell-west/kotlin/ch-2.kt b/challenge-255/roger-bell-west/kotlin/ch-2.kt
new file mode 100644
index 0000000000..90e62b0147
--- /dev/null
+++ b/challenge-255/roger-bell-west/kotlin/ch-2.kt
@@ -0,0 +1,30 @@
+import kotlin.math.max
+
+fun mostfrequentword(para: String, banned: String): String {
+ var words = mutableMapOf<String, Int>().withDefault({0})
+ for (w in para.split("[^A-Za-z]+".toRegex())
+ .filter{it.length > 0}) {
+ words.set(w, words.getValue(w) + 1)
+ }
+ words.remove(banned)
+ val m = words.values.maxOrNull()!!
+ val l = words.keys.filter{words[it] == m}.toList()
+ return l[0]
+}
+
+fun main() {
+
+ if (mostfrequentword("Joe hit a ball, the hit ball flew far after it was hit.", "hit") == "ball") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (mostfrequentword("Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.", "the") == "Perl") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-255/roger-bell-west/lua/ch-1.lua b/challenge-255/roger-bell-west/lua/ch-1.lua
new file mode 100755
index 0000000000..360bc687f2
--- /dev/null
+++ b/challenge-255/roger-bell-west/lua/ch-1.lua
@@ -0,0 +1,53 @@
+#! /usr/bin/lua
+
+function chars(str)
+ local c = {}
+ for i = 1, string.len(str) do
+ table.insert(c, string.sub(str, i, i))
+ end
+ return c
+end
+
+function oddcharacter(s, t)
+ local ss = {}
+ for _, c in ipairs(chars(s)) do
+ if ss[c] == nil then
+ ss[c] = 1
+ else
+ ss[c] = ss[c] + 1
+ end
+ end
+ for _, c in ipairs(chars(t)) do
+ if ss[c] ~= nil and ss[c] > 0 then
+ ss[c] = ss[c] - 1
+ if ss[c] == 0 then
+ ss[c] = nil
+ end
+ else
+ return c
+ end
+ end
+ return "@"
+end
+
+if oddcharacter("Perl", "Preel") == "e" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if oddcharacter("Weekly", "Weeakly") == "a" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if oddcharacter("Box", "Boxy") == "y" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+
diff --git a/challenge-255/roger-bell-west/lua/ch-2.lua b/challenge-255/roger-bell-west/lua/ch-2.lua
new file mode 100755
index 0000000000..f8374a001b
--- /dev/null
+++ b/challenge-255/roger-bell-west/lua/ch-2.lua
@@ -0,0 +1,36 @@
+#! /usr/bin/lua
+
+function mostfrequentword(para, banned)
+ local words = {}
+ for c in string.gmatch(para, "%a+") do
+ if words[c] == nil then
+ words[c] = 1
+ else
+ words[c] = words[c] + 1
+ end
+ end
+ words[banned] = nil
+ local m = 0
+ for k, v in pairs(words) do
+ m = math.max(m, v)
+ end
+ for k, v in pairs(words) do
+ if v == m then
+ return k
+ end
+ end
+end
+
+if mostfrequentword("Joe hit a ball, the hit ball flew far after it was hit.", "hit") == "ball" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if mostfrequentword("Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.", "the") == "Perl" then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
diff --git a/challenge-255/roger-bell-west/perl/ch-1.pl b/challenge-255/roger-bell-west/perl/ch-1.pl
new file mode 100755
index 0000000000..5b95e0c01f
--- /dev/null
+++ b/challenge-255/roger-bell-west/perl/ch-1.pl
@@ -0,0 +1,24 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 3;
+
+is(oddcharacter('Perl', 'Preel'), 'e', 'example 1');
+is(oddcharacter('Weekly', 'Weeakly'), 'a', 'example 2');
+is(oddcharacter('Box', 'Boxy'), 'y', 'example 3');
+
+sub oddcharacter($s, $t) {
+ my %ss;
+ map {$ss{$_}++} split '',$s;
+ foreach my $c (split '', $t) {
+ if (exists $ss{$c} && $ss{$c} > 0) {
+ $ss{$c}--;
+ } else {
+ return $c;
+ }
+ }
+ return '@';
+}
diff --git a/challenge-255/roger-bell-west/perl/ch-2.pl b/challenge-255/roger-bell-west/perl/ch-2.pl
new file mode 100755
index 0000000000..0e916a0c64
--- /dev/null
+++ b/challenge-255/roger-bell-west/perl/ch-2.pl
@@ -0,0 +1,21 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+use experimental 'signatures';
+
+use Test::More tests => 2;
+
+is(mostfrequentword('Joe hit a ball, the hit ball flew far after it was hit.', 'hit'), 'ball', 'example 1');
+is(mostfrequentword('Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.', 'the'), 'Perl', 'example 2');
+
+use List::Util qw(max);
+
+sub mostfrequentword($para, $banned) {
+ my %words;
+ map {$words{$_}++} grep {length($_) > 0} split /[^A-Za-z]+/,$para;
+ delete $words{$banned};
+ my $m = max(values %words);
+ my @v = sort grep {$words{$_} == $m} keys %words;
+ return $v[0];
+}
diff --git a/challenge-255/roger-bell-west/postscript/ch-1.ps b/challenge-255/roger-bell-west/postscript/ch-1.ps
new file mode 100644
index 0000000000..78dcdecf3d
--- /dev/null
+++ b/challenge-255/roger-bell-west/postscript/ch-1.ps
@@ -0,0 +1,88 @@
+%!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.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 {
+ /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.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} bind def
+
+/dget {
+ 3 1 roll
+ 2 copy
+ known {
+ get exch pop
+ } {
+ pop pop
+ } ifelse
+} bind def
+
+/s2a {
+ [ exch { } forall ]
+} bind def
+
+
+% end included library code
+
+/oddcharacter {
+ 0 dict begin
+ /ss 0 dict def
+ exch
+ s2a {
+ /c exch def
+ ss c 0 dget 1 add ss exch c exch put
+ } forall
+ s2a {
+ /c exch def
+ ss c known ss c 0 dget 0 gt and {
+ ss c 0 dget 1 sub ss exch c exch put
+ } {
+ [ c ] a2s
+ exit
+ } ifelse
+ } forall
+ end
+} bind def
+
+(oddcharacter) test.start
+(Perl) (Preel) oddcharacter (e) eq test
+(Weekly) (Weeakly) oddcharacter (a) eq test
+(Box) (Boxy) oddcharacter (y) eq test
+test.end
diff --git a/challenge-255/roger-bell-west/postscript/ch-2.ps b/challenge-255/roger-bell-west/postscript/ch-2.ps
new file mode 100644
index 0000000000..028f3d25c0
--- /dev/null
+++ b/challenge-255/roger-bell-west/postscript/ch-2.ps
@@ -0,0 +1,168 @@
+%!PS
+
+% begin included library code
+% see https://codeberg.org/Firedrake/postscript-libraries/
+/dget {
+ 3 1 roll
+ 2 copy
+ known {
+ get exch pop
+ } {
+ pop pop
+ } ifelse
+} 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
+
+/values { % dict -> array of dict values
+ [ exch
+ {
+ exch pop
+ } forall
+ ]
+} bind def
+
+/reduce { % array proc -> value
+ 2 dict begin
+ /p exch def
+ /a exch def
+ a 0 get
+ 1 1 a length 1 sub {
+ a exch get
+ p
+ } for
+ end
+} bind def
+
+/filter { % array proc(bool) -> array
+ 1 dict begin
+ /p exch def
+ [ exch
+ {
+ dup p not
+ {
+ pop
+ } if
+ } forall
+ ]
+ end
+} bind def
+
+/keys { % dict -> array of dict keys
+ [ exch
+ {
+ pop
+ } forall
+ ]
+} bind def
+
+/s2a {
+ [ exch { } forall ]
+} 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
+
+/listmax {
+ { max } reduce
+} 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
+
+/isalpha {
+ dup
+ dup 65 ge exch 90 le and exch
+ dup 97 ge exch 122 le and or
+} bind def
+
+/splitalpha {
+ 0 dict begin
+ s2a /s exch def
+ /state false def
+ [
+ /x -1 def
+ 0 1 s length 1 sub {
+ /i exch def
+ s i get isalpha {
+ state not {
+ /x i def
+ } if
+ /state true def
+ } {
+ state {
+ [ x i ]
+ } if
+ /state false def
+ } ifelse
+ } for
+ state {
+ [ x i ]
+ } if
+ ]
+ [ exch {
+ aload pop
+ 1 index exch sub neg
+ s 3 1 roll
+ getinterval a2s
+ } forall
+ ]
+ end
+} bind def
+
+/mostfrequentword {
+ 0 dict begin
+ exch
+ /words 0 dict def
+ splitalpha {
+ /c exch def
+ words c 0 dget 1 add words exch c exch put
+ } forall
+ words exch undef
+ /m words values listmax def
+ /k words keys { words exch get m eq } filter def
+ k 0 get
+ end
+} bind def
+
+(mostfrequentword) test.start
+(Joe hit a ball, the hit ball flew far after it was hit.) (hit) mostfrequentword (ball) eq test
+(Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.) (the) mostfrequentword (Perl) eq test
+test.end
diff --git a/challenge-255/roger-bell-west/python/ch-1.py b/challenge-255/roger-bell-west/python/ch-1.py
new file mode 100755
index 0000000000..4e36a5c865
--- /dev/null
+++ b/challenge-255/roger-bell-west/python/ch-1.py
@@ -0,0 +1,29 @@
+#! /usr/bin/python3
+
+from collections import defaultdict
+
+def oddcharacter(s, t):
+ ss = defaultdict(lambda: 0)
+ for c in s:
+ ss[c] += 1
+ for c in t:
+ if c in ss and ss[c] > 0:
+ ss[c] -= 1
+ else:
+ return c
+ return "@"
+
+import unittest
+
+class TestOddcharacter(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(oddcharacter("Perl", "Preel"), "e", 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(oddcharacter("Weekly", "Weeakly"), "a", 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(oddcharacter("Box", "Boxy"), "y", 'example 3')
+
+unittest.main()
diff --git a/challenge-255/roger-bell-west/python/ch-2.py b/challenge-255/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..83d7b801e7
--- /dev/null
+++ b/challenge-255/roger-bell-west/python/ch-2.py
@@ -0,0 +1,28 @@
+#! /usr/bin/python3
+
+from collections import defaultdict
+import re
+
+def mostfrequentword(para, banned):
+ words = defaultdict(lambda: 0)
+ r = re.compile(r"[^A-Za-z]+")
+ for v in re.split(r, para):
+ if len(v) > 0:
+ words[v] += 1
+ del words[banned]
+ m = max(words.values())
+ v = [w for w in words.keys() if words[w] == m]
+ v.sort()
+ return v[0]
+
+import unittest
+
+class TestMostfrequentword(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(mostfrequentword("Joe hit a ball, the hit ball flew far after it was hit.", "hit"), "ball", 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(mostfrequentword("Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.", "the"), "Perl", 'example 2')
+
+unittest.main()
diff --git a/challenge-255/roger-bell-west/raku/ch-1.p6 b/challenge-255/roger-bell-west/raku/ch-1.p6
new file mode 100755
index 0000000000..0cc5354461
--- /dev/null
+++ b/challenge-255/roger-bell-west/raku/ch-1.p6
@@ -0,0 +1,22 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 3;
+
+is(oddcharacter('Perl', 'Preel'), 'e', 'example 1');
+is(oddcharacter('Weekly', 'Weeakly'), 'a', 'example 2');
+is(oddcharacter('Box', 'Boxy'), 'y', 'example 3');
+
+sub oddcharacter($s, $t) {
+ my %ss;
+ map {%ss{$_}++}, $s.comb;
+ for $t.comb -> $c {
+ if (%ss{$c}:exists && %ss{$c} > 0) {
+ %ss{$c}--;
+ } else {
+ return $c;
+ }
+ }
+ return '@';
+}
diff --git a/challenge-255/roger-bell-west/raku/ch-2.p6 b/challenge-255/roger-bell-west/raku/ch-2.p6
new file mode 100755
index 0000000000..cf079b8513
--- /dev/null
+++ b/challenge-255/roger-bell-west/raku/ch-2.p6
@@ -0,0 +1,17 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 2;
+
+is(mostfrequentword('Joe hit a ball, the hit ball flew far after it was hit.', 'hit'), 'ball', 'example 1');
+is(mostfrequentword('Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.', 'the'), 'Perl', 'example 2');
+
+sub mostfrequentword($para, $banned) {
+ my %words;
+ map {%words{$_}++}, $para.comb(/<[A..Za..z]>+/);
+ %words{$banned}:delete;
+ my $m = %words.values.max;
+ my @v = %words.keys.grep({%words{$_} == $m}).sort;
+ return @v[0];
+}
diff --git a/challenge-255/roger-bell-west/ruby/ch-1.rb b/challenge-255/roger-bell-west/ruby/ch-1.rb
new file mode 100755
index 0000000000..91d762c0a7
--- /dev/null
+++ b/challenge-255/roger-bell-west/ruby/ch-1.rb
@@ -0,0 +1,34 @@
+#! /usr/bin/ruby
+
+def oddcharacter(s, t)
+ ss = Hash.new(0)
+ s.chars.each do |c|
+ ss[c] += 1
+ end
+ t.chars.each do |c|
+ if ss.has_key?(c) and ss[c] > 0 then
+ ss[c] -= 1
+ else
+ return c
+ end
+ end
+ return "@"
+end
+
+require 'test/unit'
+
+class TestOddcharacter < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal('e', oddcharacter('Perl', 'Preel'))
+ end
+
+ def test_ex2
+ assert_equal('a', oddcharacter('Weekly', 'Weeakly'))
+ end
+
+ def test_ex3
+ assert_equal('y', oddcharacter('Box', 'Boxy'))
+ end
+
+end
diff --git a/challenge-255/roger-bell-west/ruby/ch-2.rb b/challenge-255/roger-bell-west/ruby/ch-2.rb
new file mode 100755
index 0000000000..03174df9cf
--- /dev/null
+++ b/challenge-255/roger-bell-west/ruby/ch-2.rb
@@ -0,0 +1,26 @@
+#! /usr/bin/ruby
+
+def mostfrequentword(para, banned)
+ words = Hash.new(0)
+ para.split(/[^A-Za-z]+/).find_all{|v| v.length > 0}.each do |c|
+ words[c] += 1
+ end
+ words.delete(banned)
+ m = words.values.max
+ v = words.keys.find_all{|w| words[w] == m}
+ return v[0]
+end
+
+require 'test/unit'
+
+class TestMostfrequentword < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal('ball', mostfrequentword('Joe hit a ball, the hit ball flew far after it was hit.', 'hit'))
+ end
+
+ def test_ex2
+ assert_equal('Perl', mostfrequentword('Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.', 'the'))
+ end
+
+end
diff --git a/challenge-255/roger-bell-west/rust/ch-1.rs b/challenge-255/roger-bell-west/rust/ch-1.rs
new file mode 100755
index 0000000000..8a0b7144b0
--- /dev/null
+++ b/challenge-255/roger-bell-west/rust/ch-1.rs
@@ -0,0 +1,28 @@
+use counter::Counter;
+
+#[test]
+fn test_ex1() {
+ assert_eq!(oddcharacter("Perl", "Preel"), 'e');
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(oddcharacter("Weekly", "Weeakly"), 'a');
+}
+
+#[test]
+fn test_ex3() {
+ assert_eq!(oddcharacter("Box", "Boxy"), 'y');
+}
+
+fn oddcharacter(s: &str, t: &str) -> char {
+ let mut ss = s.chars().collect::<Counter<char>>();
+ for c in t.chars() {
+ if ss[&c] > 0 {
+ ss[&c] -= 1;
+ } else {
+ return c;
+ }
+ }
+ '@'
+}
diff --git a/challenge-255/roger-bell-west/rust/ch-2.rs b/challenge-255/roger-bell-west/rust/ch-2.rs
new file mode 100755
index 0000000000..e59f23385e
--- /dev/null
+++ b/challenge-255/roger-bell-west/rust/ch-2.rs
@@ -0,0 +1,26 @@
+use counter::Counter;
+
+#[test]
+fn test_ex1() {
+ assert_eq!(
+ mostfrequentword(
+ "Joe hit a ball, the hit ball flew far after it was hit.",
+ "hit"
+ ),
+ "ball"
+ );
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(mostfrequentword("Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.", "the"), "Perl");
+}
+
+fn mostfrequentword(para: &str, banned: &str) -> String {
+ let mut words = para
+ .split(|c: char| !c.is_alphabetic())
+ .filter(|s| s.len() > 0)
+ .collect::<Counter<&str>>();
+ words.remove(&banned);
+ words.k_most_common_ordered(1)[0].0.to_string()
+}
diff --git a/challenge-255/roger-bell-west/scala/ch-1.scala b/challenge-255/roger-bell-west/scala/ch-1.scala
new file mode 100644
index 0000000000..a5a6184653
--- /dev/null
+++ b/challenge-255/roger-bell-west/scala/ch-1.scala
@@ -0,0 +1,39 @@
+import scala.collection.mutable
+
+object Oddcharacter {
+ def oddcharacter(s: String, t: String): Char = {
+ var ss = mutable.Map.empty[Char, Int].withDefaultValue(0)
+ for (c <- s.toList) {
+ ss += (c -> (ss(c) + 1))
+ }
+ for (c <- t.toList) {
+ if (ss(c) > 0) {
+ ss += (c -> (ss(c) - 1))
+ } else {
+ return c
+ }
+ }
+ return '@'
+ }
+ def main(args: Array[String]) {
+ if (oddcharacter("Perl", "Preel") == 'e') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (oddcharacter("Weekly", "Weeakly") == 'a') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (oddcharacter("Box", "Boxy") == 'y') {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-255/roger-bell-west/scala/ch-2.scala b/challenge-255/roger-bell-west/scala/ch-2.scala
new file mode 100644
index 0000000000..4cbb9a5929
--- /dev/null
+++ b/challenge-255/roger-bell-west/scala/ch-2.scala
@@ -0,0 +1,29 @@
+import scala.collection.mutable
+
+object Mostfrequentword {
+ def mostfrequentword(para: String, banned: String): String = {
+ var words = mutable.Map.empty[String, Int].withDefaultValue(0)
+ for (w <- para.split("[^A-Za-z]+").filter(n => n.length > 0)) {
+ words += (w -> (words(w) + 1))
+ }
+ words.remove(banned)
+ val m = words.values.max
+ val l = words.keys.filter(i => words(i) == m).toList
+ return l(0)
+ }
+ def main(args: Array[String]) {
+ if (mostfrequentword("Joe hit a ball, the hit ball flew far after it was hit.", "hit") == "ball") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (mostfrequentword("Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.", "the") == "Perl") {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-255/roger-bell-west/tests.yaml b/challenge-255/roger-bell-west/tests.yaml
new file mode 100644
index 0000000000..ce23ff681d
--- /dev/null
+++ b/challenge-255/roger-bell-west/tests.yaml
@@ -0,0 +1,30 @@
+---
+ch-1:
+ - function: oddcharacter
+ multiarg: true
+ arguments:
+ - Perl
+ - Preel
+ result: e
+ - multiarg: true
+ arguments:
+ - Weekly
+ - Weeakly
+ result: a
+ - multiarg: true
+ arguments:
+ - Box
+ - Boxy
+ result: y
+ch-2:
+ - function: mostfrequentword
+ multiarg: true
+ arguments:
+ - Joe hit a ball, the hit ball flew far after it was hit.
+ - hit
+ result: ball
+ - multiarg: true
+ arguments:
+ - Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge.
+ - the
+ result: Perl