aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-05-13 00:35:12 +0100
committerGitHub <noreply@github.com>2024-05-13 00:35:12 +0100
commitb81b70ef4e356b8248cd343b275b178e970c0baa (patch)
treeba2b87e1aecdf988ea08f44e70e97946b2d1fb3f
parenta789b29d237405aa250064b80f10bcbc3e59794d (diff)
parentb1a7148f33bd67db6e6704d256e86f64a437ada4 (diff)
downloadperlweeklychallenge-club-b81b70ef4e356b8248cd343b275b178e970c0baa.tar.gz
perlweeklychallenge-club-b81b70ef4e356b8248cd343b275b178e970c0baa.tar.bz2
perlweeklychallenge-club-b81b70ef4e356b8248cd343b275b178e970c0baa.zip
Merge pull request #10081 from BarrOff/barroff-268
feat: add solutions for challenge 268 from BarrOff
-rw-r--r--challenge-268/barroff/julia/ch-1.jl15
-rw-r--r--challenge-268/barroff/raku/ch-1.p617
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-268/barroff/julia/ch-1.jl b/challenge-268/barroff/julia/ch-1.jl
new file mode 100644
index 0000000000..b89b8b45ac
--- /dev/null
+++ b/challenge-268/barroff/julia/ch-1.jl
@@ -0,0 +1,15 @@
+#!/usr/bin/env julia
+
+using Test: @test, @testset
+
+function magic_number(x::Vector{T}, y::Vector{T})::Int where {T<:Integer}
+ return abs(minimum(x) - minimum(y))
+
+end
+
+@testset "magic number" begin
+ @test magic_number([3, 7, 5], [9, 5, 7]) == 2
+ @test magic_number([1, 2, 1], [5, 4, 4]) == 3
+ @test magic_number([2], [5]) == 3
+end
+
diff --git a/challenge-268/barroff/raku/ch-1.p6 b/challenge-268/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..0282c40358
--- /dev/null
+++ b/challenge-268/barroff/raku/ch-1.p6
@@ -0,0 +1,17 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub magic-number(@x, @y --> Int:D) {
+ abs(min(@x) - min(@y))
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is magic-number([3, 7, 5], [9, 5, 7]), 2, 'works for [3, 7, 5] and [9, 5, 7]';
+ is magic-number([1, 2, 1], [5, 4, 4]), 3, 'works for [1, 2, 1] and [5, 4, 4]';
+ is magic-number([2], [5]), 3, 'works for [2] and [5]';
+}