Also, a brute-force (but simple-looking) approach that is O(n²) might be

function levicivita{T<:Integer}(p::AbstractVector{T})
    n = lenght(p)
    ɛ = 1

    for i = 1:n
        for j = i+1:n
            ɛ *= sign(p[j] - p[i])
            ɛ == 0 && return 0
        end
    end

    return ɛ
end

Reply via email to