blob: 1a99bc9456ce9a449818967984842a4474fb1601 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/env julia
using Test: @test, @testset
function unique_sum_zero(n::T) where {T<:Integer}
ints = []
map(x -> append!(ints, [x, -x]), 1:Int(floor(n / 2)))
if n % 2 == 1
append!(ints, 0)
end
sort!(ints)
return ints
end
@testset "unique sum zero" begin
@test unique_sum_zero(5) == [-2, -1, 0, 1, 2]
@test unique_sum_zero(3) == [-1, 0, 1]
@test unique_sum_zero(1) == [0]
@test unique_sum_zero(0) == []
end
|