aboutsummaryrefslogtreecommitdiff
path: root/challenge-250/barroff/julia/ch-2.jl
blob: bff5607ecfaa90429022d2fe3b7843faa186a374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env julia

using Test: @test, @testset

function alphanumeric_string_value(alphanumstr::Vector{T}) where {T<:AbstractString}
    return maximum(
        map(x -> occursin(r"[a-zA-Z]", x) ? lastindex(x) : parse(Int, x), alphanumstr),
    )
end

@testset "alphanumeric string value" begin
    @test alphanumeric_string_value(["perl", "2", "000", "python", "r4ku"]) == 6
    @test alphanumeric_string_value(["001", "1", "000", "0001"]) == 1
end