diff options
Diffstat (limited to 'challenge-253')
| -rw-r--r-- | challenge-253/wambash/julia/ch-1.jl | 10 | ||||
| -rw-r--r-- | challenge-253/wambash/julia/ch-2.jl | 35 |
2 files changed, 45 insertions, 0 deletions
diff --git a/challenge-253/wambash/julia/ch-1.jl b/challenge-253/wambash/julia/ch-1.jl new file mode 100644 index 0000000000..8a2aa795ad --- /dev/null +++ b/challenge-253/wambash/julia/ch-1.jl @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +split_strings(words; separator = " " ) = mapreduce( x -> split(x, separator, keepempty=false ), vcat, words) + +using Test + +@testset "split strings" begin + @test split_strings(["one.two.three","four.five","six"], separator = ".") == ["one","two","three","four","five","six"] + @test split_strings(["\$perl\$\$", "\$\$raku\$"], separator = "\$") == ["perl","raku"] +end diff --git a/challenge-253/wambash/julia/ch-2.jl b/challenge-253/wambash/julia/ch-2.jl new file mode 100644 index 0000000000..681f45f6c8 --- /dev/null +++ b/challenge-253/wambash/julia/ch-2.jl @@ -0,0 +1,35 @@ +#!/usr/bin/env julia + +using Lazy + +weakest_row(matrix) = @>> begin + matrix + pairs + collect + map(reverse) + sort + map(x-> x.second - 1) +end + +using Test + +@testset "Matrix" begin + matrix = [ + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 0], + [1, 0, 0, 0, 0], + [1, 1, 0, 0, 0], + [1, 1, 1, 1, 1] + ] + @test weakest_row(matrix) == [2,0,3,1,4] +end + +@testset "Matrix with same rows" begin + matrix = [ + [1, 0, 0, 0], + [1, 1, 1, 1], + [1, 0, 0, 0], + [1, 0, 0, 0], + ] + @test weakest_row(matrix) == [0,2,3,1] +end |
