diff options
| author | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2024-10-06 22:26:34 +0200 |
|---|---|---|
| committer | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2024-10-06 22:26:34 +0200 |
| commit | 79dc2dffaf500704282e216616c02126f85c00a2 (patch) | |
| tree | 8b82d030286c123bbc740a5d206c4b36983de65a /challenge-289/barroff/julia | |
| parent | e19a3a6ba54a2b2236820f3cf878fe880e066777 (diff) | |
| download | perlweeklychallenge-club-79dc2dffaf500704282e216616c02126f85c00a2.tar.gz perlweeklychallenge-club-79dc2dffaf500704282e216616c02126f85c00a2.tar.bz2 perlweeklychallenge-club-79dc2dffaf500704282e216616c02126f85c00a2.zip | |
feat: add solutions for challenge 289 from BarrOff
Diffstat (limited to 'challenge-289/barroff/julia')
| -rw-r--r-- | challenge-289/barroff/julia/ch-1.jl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-289/barroff/julia/ch-1.jl b/challenge-289/barroff/julia/ch-1.jl new file mode 100644 index 0000000000..0df017f32b --- /dev/null +++ b/challenge-289/barroff/julia/ch-1.jl @@ -0,0 +1,14 @@ +#!/usr/bin/env julia + +using Test: @test, @testset + +function third_maximum(ints::Vector{T})::Int where {T<:Integer} + unique_ints = unique(ints) + return length(unique_ints) > 2 ? sort(unique_ints)[end-2] : maximum(unique_ints) +end + +@testset "third maximum" begin + @test third_maximum([5, 6, 4, 1]) == 4 + @test third_maximum([4, 5]) == 5 + @test third_maximum([1, 2, 2, 3]) == 1 +end |
