aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-20 23:22:28 +0100
committerGitHub <noreply@github.com>2025-06-20 23:22:28 +0100
commit67b13bff219577fb89d7b39ed8f518d04528cbb8 (patch)
treefb1e34f6f4a68a5313af8caa501ffeddc9f2840d
parentcf38a6108a1b0635a8c9375c3eea633fe833ca1a (diff)
parent138c6363d4d827ff6afb2d1c68dbd1b864d0b7dd (diff)
downloadperlweeklychallenge-club-67b13bff219577fb89d7b39ed8f518d04528cbb8.tar.gz
perlweeklychallenge-club-67b13bff219577fb89d7b39ed8f518d04528cbb8.tar.bz2
perlweeklychallenge-club-67b13bff219577fb89d7b39ed8f518d04528cbb8.zip
Merge pull request #12202 from Firedrake/rogerbw-challenge-326
RogerBW solutions for challenge no. 326
-rwxr-xr-xchallenge-326/roger-bell-west/crystal/ch-1.cr20
-rwxr-xr-xchallenge-326/roger-bell-west/crystal/ch-2.cr22
-rwxr-xr-xchallenge-326/roger-bell-west/javascript/ch-1.js31
-rwxr-xr-xchallenge-326/roger-bell-west/javascript/ch-2.js58
-rw-r--r--challenge-326/roger-bell-west/kotlin/ch-1.kt32
-rw-r--r--challenge-326/roger-bell-west/kotlin/ch-2.kt32
-rwxr-xr-xchallenge-326/roger-bell-west/lua/ch-1.lua44
-rwxr-xr-xchallenge-326/roger-bell-west/lua/ch-2.lua68
-rwxr-xr-xchallenge-326/roger-bell-west/perl/ch-1.pl23
-rwxr-xr-xchallenge-326/roger-bell-west/perl/ch-2.pl23
-rw-r--r--challenge-326/roger-bell-west/postscript/ch-1.ps77
-rw-r--r--challenge-326/roger-bell-west/postscript/ch-2.ps132
-rwxr-xr-xchallenge-326/roger-bell-west/python/ch-1.py21
-rwxr-xr-xchallenge-326/roger-bell-west/python/ch-2.py29
-rwxr-xr-xchallenge-326/roger-bell-west/raku/ch-1.p620
-rwxr-xr-xchallenge-326/roger-bell-west/raku/ch-2.p617
-rwxr-xr-xchallenge-326/roger-bell-west/ruby/ch-1.rb25
-rwxr-xr-xchallenge-326/roger-bell-west/ruby/ch-2.rb27
-rwxr-xr-xchallenge-326/roger-bell-west/rust/ch-1.rs20
-rwxr-xr-xchallenge-326/roger-bell-west/rust/ch-2.rs26
-rw-r--r--challenge-326/roger-bell-west/scala/ch-1.scala32
-rw-r--r--challenge-326/roger-bell-west/scala/ch-2.scala34
-rw-r--r--challenge-326/roger-bell-west/tests.json32
-rw-r--r--challenge-326/roger-bell-west/typst/ch-1.typ23
-rw-r--r--challenge-326/roger-bell-west/typst/ch-2.typ27
25 files changed, 895 insertions, 0 deletions
diff --git a/challenge-326/roger-bell-west/crystal/ch-1.cr b/challenge-326/roger-bell-west/crystal/ch-1.cr
new file mode 100755
index 0000000000..b893c37a44
--- /dev/null
+++ b/challenge-326/roger-bell-west/crystal/ch-1.cr
@@ -0,0 +1,20 @@
+#! /usr/bin/crystal
+
+def dayoftheyear(a)
+ d1 = Time.parse(a, "%Y-%m-%d", Time::Location::UTC)
+ d0 = Time.utc(d1.year, 1, 1, 0, 0, 0)
+ (d1 - d0).days + 1
+end
+
+require "spec"
+describe "dayoftheyear" do
+ it "test_ex1" do
+ dayoftheyear("2025-02-02").should eq 33
+ end
+ it "test_ex2" do
+ dayoftheyear("2025-04-10").should eq 100
+ end
+ it "test_ex3" do
+ dayoftheyear("2025-09-07").should eq 250
+ end
+end
diff --git a/challenge-326/roger-bell-west/crystal/ch-2.cr b/challenge-326/roger-bell-west/crystal/ch-2.cr
new file mode 100755
index 0000000000..e305df6de4
--- /dev/null
+++ b/challenge-326/roger-bell-west/crystal/ch-2.cr
@@ -0,0 +1,22 @@
+#! /usr/bin/crystal
+
+def decompressedlist(a)
+ out = Array(Int32).new
+ a.each_slice(2) do |n|
+ out.concat(Array.new(n[0], n[1]))
+ end
+ out
+end
+
+require "spec"
+describe "decompressedlist" do
+ it "test_ex1" do
+ decompressedlist([1, 3, 2, 4]).should eq [3, 4, 4]
+ end
+ it "test_ex2" do
+ decompressedlist([1, 1, 2, 2]).should eq [1, 2, 2]
+ end
+ it "test_ex3" do
+ decompressedlist([3, 1, 3, 2]).should eq [1, 1, 1, 2, 2, 2]
+ end
+end
diff --git a/challenge-326/roger-bell-west/javascript/ch-1.js b/challenge-326/roger-bell-west/javascript/ch-1.js
new file mode 100755
index 0000000000..b8e59391f8
--- /dev/null
+++ b/challenge-326/roger-bell-west/javascript/ch-1.js
@@ -0,0 +1,31 @@
+#! /usr/bin/node
+
+"use strict"
+
+function dayoftheyear(a) {
+ let d1 = new Date(Date.parse(a));
+ let v1 = d1.valueOf();
+ d1.setMonth(0);
+ d1.setDate(1);
+ let v0 = d1.valueOf();
+ return Math.floor(0.5 + (v1 - v0) / 86400000 + 1);
+}
+
+if (dayoftheyear('2025-02-02') == 33) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (dayoftheyear('2025-04-10') == 100) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (dayoftheyear('2025-09-07') == 250) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-326/roger-bell-west/javascript/ch-2.js b/challenge-326/roger-bell-west/javascript/ch-2.js
new file mode 100755
index 0000000000..4966c5ae90
--- /dev/null
+++ b/challenge-326/roger-bell-west/javascript/ch-2.js
@@ -0,0 +1,58 @@
+#! /usr/bin/node
+
+"use strict"
+
+// by Frank Tan
+// https://stackoverflow.com/questions/38400594/javascript-deep-comparison
+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 decompressedlist(a) {
+ let out = [];
+ for (let i = 0; i < a.length; i += 2) {
+ const px = new Array(a[i]).fill(a[i + 1]);
+ out.push(...px);
+ }
+ return out;
+}
+
+if (deepEqual(decompressedlist([1, 3, 2, 4]), [3, 4, 4])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (deepEqual(decompressedlist([1, 1, 2, 2]), [1, 2, 2])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write(" ");
+if (deepEqual(decompressedlist([3, 1, 3, 2]), [1, 1, 1, 2, 2, 2])) {
+ process.stdout.write("Pass");
+} else {
+ process.stdout.write("FAIL");
+}
+process.stdout.write("\n");
diff --git a/challenge-326/roger-bell-west/kotlin/ch-1.kt b/challenge-326/roger-bell-west/kotlin/ch-1.kt
new file mode 100644
index 0000000000..d4fb16c04b
--- /dev/null
+++ b/challenge-326/roger-bell-west/kotlin/ch-1.kt
@@ -0,0 +1,32 @@
+import java.time.Duration
+import java.time.LocalDate
+import java.time.format.DateTimeFormatter
+import java.time.temporal.ChronoUnit
+
+fun dayoftheyear(a: String): Int {
+ val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
+ return LocalDate.parse(a, formatter).getDayOfYear()
+}
+
+fun main() {
+
+ if (dayoftheyear("2025-02-02") == 33) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (dayoftheyear("2025-04-10") == 100) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (dayoftheyear("2025-09-07") == 250) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-326/roger-bell-west/kotlin/ch-2.kt b/challenge-326/roger-bell-west/kotlin/ch-2.kt
new file mode 100644
index 0000000000..f61749fe62
--- /dev/null
+++ b/challenge-326/roger-bell-west/kotlin/ch-2.kt
@@ -0,0 +1,32 @@
+fun decompressedlist(a: List<Int>): List<Int> {
+ var out = ArrayList<Int>()
+ for (i in a.chunked(2)) {
+ for (n in 1 .. i[0]) {
+ out.add(i[1])
+ }
+ }
+ return out.toList()
+}
+
+fun main() {
+
+ if (decompressedlist(listOf(1, 3, 2, 4)) == listOf(3, 4, 4)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (decompressedlist(listOf(1, 1, 2, 2)) == listOf(1, 2, 2)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (decompressedlist(listOf(3, 1, 3, 2)) == listOf(1, 1, 1, 2, 2, 2)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+}
diff --git a/challenge-326/roger-bell-west/lua/ch-1.lua b/challenge-326/roger-bell-west/lua/ch-1.lua
new file mode 100755
index 0000000000..1e3e676d1f
--- /dev/null
+++ b/challenge-326/roger-bell-west/lua/ch-1.lua
@@ -0,0 +1,44 @@
+#! /usr/bin/lua
+
+function idiv(a0, b)
+ local a = math.abs(a0)
+ local q = a // b
+ if a0 < 0 then
+ q = -q
+ end
+ return q
+end
+
+function ymd2jd(y, m, d)
+ local mn = idiv(m - 14, 12)
+ return idiv((y + 4800 + mn) * 1461, 4) + idiv((m - 2 - 12 * mn) * 367, 12) - idiv(idiv(y + 4900 + mn, 100) * 3, 4) + d - 32075
+end
+
+function dayoftheyear(a)
+ local _a, _b, y, m, d = string.find(a, "([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])")
+ local d1 = ymd2jd(y, m, d)
+ local d0 = ymd2jd(y, 1, 1)
+ return d1 - d0 + 1
+end
+
+if dayoftheyear("2025-02-02") == 33 then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if dayoftheyear("2025-04-10") == 100 then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if dayoftheyear("2025-09-07") == 250 then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+
diff --git a/challenge-326/roger-bell-west/lua/ch-2.lua b/challenge-326/roger-bell-west/lua/ch-2.lua
new file mode 100755
index 0000000000..5f3f67ab58
--- /dev/null
+++ b/challenge-326/roger-bell-west/lua/ch-2.lua
@@ -0,0 +1,68 @@
+#! /usr/bin/lua
+
+-- by Michael Anderson at
+-- https://stackoverflow.com/questions/8722620/comparing-two-index-tables-by-index-value-in-lua
+-- modified by Roger
+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
+ -- Build list of all keys
+ local kk = {}
+ for k1, _ in pairs(t1) do
+ kk[k1] = true
+ end
+ for k2, _ in pairs(t2) do
+ kk[k2] = true
+ end
+ -- Check each key that exists in at least one table
+ for _, k in ipairs(kk) do
+ if (not recursive_compare(t1[k], t2[k])) then
+ return false
+ end
+ end
+ return true
+end
+
+function decompressedlist(a)
+ local out = {}
+ local n = 0
+ for _, v in ipairs(a) do
+ if n == 0 then
+ n = v
+ else
+ for i = 1, n do
+ table.insert(out, v)
+ end
+ n = 0
+ end
+ end
+ return out
+end
+
+if recursive_compare(decompressedlist({1, 3, 2, 4}), {3, 4, 4}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if recursive_compare(decompressedlist({1, 1, 2, 2}), {1, 2, 2}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if recursive_compare(decompressedlist({3, 1, 3, 2}), {1, 1, 1, 2, 2, 2}) then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+
diff --git a/challenge-326/roger-bell-west/perl/ch-1.pl b/challenge-326/roger-bell-west/perl/ch-1.pl
new file mode 100755
index 0000000000..499b6b2e0e
--- /dev/null
+++ b/challenge-326/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(dayoftheyear('2025-02-02'), 33, 'example 1');
+is(dayoftheyear('2025-04-10'), 100, 'example 2');
+is(dayoftheyear('2025-09-07'), 250, 'example 3');
+
+use DateTime;
+use DateTime::Format::Strptime;
+
+sub dayoftheyear($a) {
+ my $strp = DateTime::Format::Strptime->new(
+ pattern => '%Y-%m-%d',
+ strict => 1,
+ time_zone => 'GMT',
+ );
+ $strp->parse_datetime($a)->day_of_year;
+}
diff --git a/challenge-326/roger-bell-west/perl/ch-2.pl b/challenge-326/roger-bell-west/perl/ch-2.pl
new file mode 100755
index 0000000000..055c52a10d
--- /dev/null
+++ b/challenge-326/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_deeply(decompressedlist([1, 3, 2, 4]), [3, 4, 4], 'example 1');
+is_deeply(decompressedlist([1, 1, 2, 2]), [1, 2, 2], 'example 2');
+is_deeply(decompressedlist([3, 1, 3, 2]), [1, 1, 1, 2, 2, 2], 'example 3');
+
+use List::Util qw(pairs);
+
+
+sub decompressedlist($a) {
+ my @out;
+ foreach my $pair ( pairs @{$a} ) {
+ my ($k, $v) = @$pair;
+ push @out, ($v) x $k;
+ }
+ \@out;
+}
diff --git a/challenge-326/roger-bell-west/postscript/ch-1.ps b/challenge-326/roger-bell-west/postscript/ch-1.ps
new file mode 100644
index 0000000000..3987cee4ef
--- /dev/null
+++ b/challenge-326/roger-bell-west/postscript/ch-1.ps
@@ -0,0 +1,77 @@
+%!PS
+
+% begin included library code
+% see https://codeberg.org/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
+
+/ymd2jd {
+ 4 dict begin
+ aload pop
+ /d exch def
+ /m exch def
+ /y exch def
+ /mn m 14 sub 12 idiv def
+ y 4800 add mn add 1461 mul 4 idiv
+ mn 12 mul neg 2 sub m add 367 mul 12 idiv add
+ y 4900 add mn add 100 idiv 3 mul 4 idiv sub
+ d add
+ 32075 sub
+ end
+} bind def
+
+
+% end included library code
+
+/dayoftheyear {
+ 0 dict begin
+ /a exch def
+ [
+ a 0 4 getinterval cvi
+ a 5 2 getinterval cvi
+ a 8 2 getinterval cvi
+ ]
+ ymd2jd
+ [
+ a 0 4 getinterval cvi
+ 1
+ 1
+ ]
+ ymd2jd
+ sub 1 add
+ end
+} bind def
+
+(dayoftheyear) test.start
+(2025-02-02) dayoftheyear 33 eq test
+(2025-04-10) dayoftheyear 100 eq test
+(2025-09-07) dayoftheyear 250 eq test
+test.end
diff --git a/challenge-326/roger-bell-west/postscript/ch-2.ps b/challenge-326/roger-bell-west/postscript/ch-2.ps
new file mode 100644
index 0000000000..6dc66481a8
--- /dev/null
+++ b/challenge-326/roger-bell-west/postscript/ch-2.ps
@@ -0,0 +1,132 @@
+%!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
+
+/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
+
+/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
+
+/rotor {
+ 5 dict begin
+ /delta exch def
+ /size exch def
+ dup length /len exch def
+ /ar exch def
+ /ix 0 def
+ [
+ {
+ ix size add len gt {
+ exit
+ } if
+ ar ix size getinterval
+ /ix ix size delta add add def
+ } loop
+ ]
+ end
+} bind def
+
+/test.start {
+ print (:) print
+ /test.pass 0 def
+ /test.count 0 def
+} bind def
+
+
+% end included library code
+
+/decompressedlist {
+ [ exch
+ 2 0 rotor {
+ aload pop
+ exch 1 sub
+ {
+ dup
+ } repeat
+ } forall
+ ]
+} bind def
+
+(decompressedlist) test.start
+[1 3 2 4] decompressedlist [3 4 4] deepeq test
+[1 1 2 2] decompressedlist [1 2 2] deepeq test
+[3 1 3 2] decompressedlist [1 1 1 2 2 2] deepeq test
+test.end
diff --git a/challenge-326/roger-bell-west/python/ch-1.py b/challenge-326/roger-bell-west/python/ch-1.py
new file mode 100755
index 0000000000..95c166710e
--- /dev/null
+++ b/challenge-326/roger-bell-west/python/ch-1.py
@@ -0,0 +1,21 @@
+#! /usr/bin/python3
+
+from datetime import datetime, timedelta
+
+def dayoftheyear(a):
+ return datetime.fromisoformat(a).timetuple()[7]
+
+import unittest
+
+class TestDayoftheyear(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(dayoftheyear("2025-02-02"), 33, 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(dayoftheyear("2025-04-10"), 100, 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(dayoftheyear("2025-09-07"), 250, 'example 3')
+
+unittest.main()
diff --git a/challenge-326/roger-bell-west/python/ch-2.py b/challenge-326/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..d3b14629f2
--- /dev/null
+++ b/challenge-326/roger-bell-west/python/ch-2.py
@@ -0,0 +1,29 @@
+#! /usr/bin/python3
+
+# by Ned Batchelder and Nadeen Ulhaq
+# https://stackoverflow.com/a/312464
+def chunks(lst, n):
+ """Yield successive n-sized chunks from lst."""
+ for i in range(0, len(lst), n):
+ yield lst[i:i + n]
+
+def decompressedlist(a):
+ out = []
+ for p in chunks(a, 2):
+ out.extend([p[1]] * p[0])
+ return out
+
+import unittest
+
+class TestDecompressedlist(unittest.TestCase):
+
+ def test_ex1(self):
+ self.assertEqual(decompressedlist([1, 3, 2, 4]), [3, 4, 4], 'example 1')
+
+ def test_ex2(self):
+ self.assertEqual(decompressedlist([1, 1, 2, 2]), [1, 2, 2], 'example 2')
+
+ def test_ex3(self):
+ self.assertEqual(decompressedlist([3, 1, 3, 2]), [1, 1, 1, 2, 2, 2], 'example 3')
+
+unittest.main()
diff --git a/challenge-326/roger-bell-west/raku/ch-1.p6 b/challenge-326/roger-bell-west/raku/ch-1.p6
new file mode 100755
index 0000000000..676b91b016
--- /dev/null
+++ b/challenge-326/roger-bell-west/raku/ch-1.p6
@@ -0,0 +1,20 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 3;
+
+is(dayoftheyear('2025-02-02'), 33, 'example 1');
+is(dayoftheyear('2025-04-10'), 100, 'example 2');
+is(dayoftheyear('2025-09-07'), 250, 'example 3');
+
+sub parsedate($s) {
+ $s ~~ /(<[0..9]>+)\D(<[0..9]>+)\D(<[0..9]>+)/;
+ return Date.new($0, $1, $2);
+}
+
+sub dayoftheyear($a) {
+ my $d1 = Date.new($a);
+ my $d0 = Date.new($d1.year, 1, 1);
+ $d1.daycount - $d0.daycount + 1;
+}
diff --git a/challenge-326/roger-bell-west/raku/ch-2.p6 b/challenge-326/roger-bell-west/raku/ch-2.p6
new file mode 100755
index 0000000000..5506f31885
--- /dev/null
+++ b/challenge-326/roger-bell-west/raku/ch-2.p6
@@ -0,0 +1,17 @@
+#! /usr/bin/raku
+
+use Test;
+
+plan 3;
+
+is-deeply(decompressedlist([1, 3, 2, 4]), [3, 4, 4], 'example 1');
+is-deeply(decompressedlist([1, 1, 2, 2]), [1, 2, 2], 'example 2');
+is-deeply(decompressedlist([3, 1, 3, 2]), [1, 1, 1, 2, 2, 2], 'example 3');
+
+sub decompressedlist(@a) {
+ my @out;
+ for @a.rotor(2 => 0) -> @i {
+ @out.append(@i[1] xx @i[0]);
+ }
+ @out;
+}
diff --git a/challenge-326/roger-bell-west/ruby/ch-1.rb b/challenge-326/roger-bell-west/ruby/ch-1.rb
new file mode 100755
index 0000000000..723f9723a8
--- /dev/null
+++ b/challenge-326/roger-bell-west/ruby/ch-1.rb
@@ -0,0 +1,25 @@
+#! /usr/bin/ruby
+
+require 'date'
+
+def dayoftheyear(a)
+ Date.parse(a).yday
+end
+
+require 'test/unit'
+
+class TestDayoftheyear < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal(33, dayoftheyear('2025-02-02'))
+ end
+
+ def test_ex2
+ assert_equal(100, dayoftheyear('2025-04-10'))
+ end
+
+ def test_ex3
+ assert_equal(250, dayoftheyear('2025-09-07'))
+ end
+
+end
diff --git a/challenge-326/roger-bell-west/ruby/ch-2.rb b/challenge-326/roger-bell-west/ruby/ch-2.rb
new file mode 100755
index 0000000000..588b4b36a6
--- /dev/null
+++ b/challenge-326/roger-bell-west/ruby/ch-2.rb
@@ -0,0 +1,27 @@
+#! /usr/bin/ruby
+
+def decompressedlist(a)
+ out = []
+ a.each_slice(2) do |n|
+ out.concat(Array.new(n[0], n[1]))
+ end
+ out
+end
+
+require 'test/unit'
+
+class TestDecompressedlist < Test::Unit::TestCase
+
+ def test_ex1
+ assert_equal([3, 4, 4], decompressedlist([1, 3, 2, 4]))
+ end
+
+ def test_ex2
+ assert_equal([1, 2, 2], decompressedlist([1, 1, 2, 2]))
+ end
+
+ def test_ex3
+ assert_equal([1, 1, 1, 2, 2, 2], decompressedlist([3, 1, 3, 2]))
+ end
+
+end
diff --git a/challenge-326/roger-bell-west/rust/ch-1.rs b/challenge-326/roger-bell-west/rust/ch-1.rs
new file mode 100755
index 0000000000..054f30beb7
--- /dev/null
+++ b/challenge-326/roger-bell-west/rust/ch-1.rs
@@ -0,0 +1,20 @@
+use chrono::{Datelike, NaiveDate};
+
+#[test]
+fn test_ex1() {
+ assert_eq!(dayoftheyear("2025-02-02"), 33);
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(dayoftheyear("2025-04-10"), 100);
+}
+
+#[test]
+fn test_ex3() {
+ assert_eq!(dayoftheyear("2025-09-07"), 250);
+}
+
+fn dayoftheyear(a: &str) -> u32 {
+ NaiveDate::parse_from_str(a, "%Y-%m-%d").unwrap().ordinal()
+}
diff --git a/challenge-326/roger-bell-west/rust/ch-2.rs b/challenge-326/roger-bell-west/rust/ch-2.rs
new file mode 100755
index 0000000000..0de31fbe24
--- /dev/null
+++ b/challenge-326/roger-bell-west/rust/ch-2.rs
@@ -0,0 +1,26 @@
+#! /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!(decompressedlist(vec![1, 3, 2, 4]), vec![3, 4, 4]);
+}
+
+#[test]
+fn test_ex2() {
+ assert_eq!(decompressedlist(vec![1, 1, 2, 2]), vec![1, 2, 2]);
+}
+
+#[test]
+fn test_ex3() {
+ assert_eq!(decompressedlist(vec![3, 1, 3, 2]), vec![1, 1, 1, 2, 2, 2]);
+}
+
+fn decompressedlist(a: Vec<usize>) -> Vec<usize> {
+ let mut out = Vec::new();
+ for p in a.chunks(2) {
+ let mut px = vec![p[1]; p[0]];
+ out.append(&mut px);
+ }
+ out
+}
diff --git a/challenge-326/roger-bell-west/scala/ch-1.scala b/challenge-326/roger-bell-west/scala/ch-1.scala
new file mode 100644
index 0000000000..c8ff529c8c
--- /dev/null
+++ b/challenge-326/roger-bell-west/scala/ch-1.scala
@@ -0,0 +1,32 @@
+import java.time.Duration
+import java.time.LocalDate
+import java.time.format.DateTimeFormatter
+import java.time.temporal.ChronoUnit
+
+object Dayoftheyear {
+ def dayoftheyear(a: String): Int = {
+ val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
+ return LocalDate.parse(a, formatter).getDayOfYear()
+ }
+ def main(args: Array[String]) {
+ if (dayoftheyear("2025-02-02") == 33) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (dayoftheyear("2025-04-10") == 100) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (dayoftheyear("2025-09-07") == 250) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-326/roger-bell-west/scala/ch-2.scala b/challenge-326/roger-bell-west/scala/ch-2.scala
new file mode 100644
index 0000000000..fc6b553138
--- /dev/null
+++ b/challenge-326/roger-bell-west/scala/ch-2.scala
@@ -0,0 +1,34 @@
+import scala.collection.mutable.ListBuffer
+
+object Decompressedlist {
+ def decompressedlist(a: List[Int]): List[Int] = {
+ var out = new ListBuffer[Int]
+ for (i <- a.grouped(2)) {
+ for (n <- 1 to i(0)) {
+ out += (i(1))
+ }
+ }
+ out.toList
+ }
+ def main(args: Array[String]) {
+ if (decompressedlist(List(1, 3, 2, 4)) == List(3, 4, 4)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (decompressedlist(List(1, 1, 2, 2)) == List(1, 2, 2)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ print(" ")
+ if (decompressedlist(List(3, 1, 3, 2)) == List(1, 1, 1, 2, 2, 2)) {
+ print("Pass")
+ } else {
+ print("Fail")
+ }
+ println("")
+
+ }
+}
diff --git a/challenge-326/roger-bell-west/tests.json b/challenge-326/roger-bell-west/tests.json
new file mode 100644
index 0000000000..3190875174
--- /dev/null
+++ b/challenge-326/roger-bell-west/tests.json
@@ -0,0 +1,32 @@
+{
+ "ch-1" : [
+ {
+ "function" : "dayoftheyear",
+ "arguments" : "2025-02-02",
+ "result" : 33
+ },
+ {
+ "arguments" : "2025-04-10",
+ "result" : 100
+ },
+ {
+ "arguments" :