aboutsummaryrefslogtreecommitdiff
path: root/challenge-280/barroff/julia/ch-1.jl
blob: 056e092cc39474d44961ed3903511b6da5e32fc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env julia

using Test: @test, @testset

function twice_appearance(str::AbstractString)::Char
    str_set = Set{Char}()
    for c in str
        if in(c, str_set)
            return c
        end
        push!(str_set, c)
    end
end

@testset "twice appearance" begin
    @test twice_appearance("acbddbca") == 'd'
    @test twice_appearance("abccd") == 'c'
    @test twice_appearance("abcdabbb") == 'a'
end