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

using Test: @test, @testset

function target_index(k::T, ints::Vector{T}) where {T<:Integer}
	findall(x -> x == k, sort(ints)) .- 1
end

@testset "target index" begin
	@test target_index(2, [1, 5, 3, 2, 4, 2]) == [1, 2]
	@test target_index(6, [1, 2, 4, 3, 5]) == []
	@test target_index(4, [5, 3, 2, 4, 2, 1]) == [4]
end