binary-heap-benchmark
binary-heap-benchmark copied to clipboard
Julia version of heap added
I saw a thread on julia
at https://codeforces.com/blog/entry/79 and wanted to help out. This code is a slightly modified copy&paste of python3
version. The biggest difference is julia
's 1-based indexing. On my machine running time was within a factor of 2 slower than c++
version.
Also, I've posted a solution to the "Theatre square" problem mentioned in the thread. https://gist.github.com/artemsolod/3eb48e75b06216fd0af317546c793480
julia
binaries are available here https://julialang.org/downloads/. The command to run code is julia heap.jl
One thing to note is that julia
JIT-compiles code so it seems that every test-case would spend some time recompiling the solution.
Hope this helps!
Please, provide me a way to check Julia syntax without running the program. Give me full code (I tried some without success).
There doesn't seem to be a specific flag to call julia
with for performing this task. However, using a suggestion from https://discourse.julialang.org/t/syntax-validation-of-a-julia-file/55946 the following script should do the trick.
validatesyntax(fname) = include(expr -> Meta.isexpr(expr, (:error, :incomplete)) ? expr : nothing, fname) (length(ARGS) == 1) && validatesyntax(ARGS[1])
If this script is stored in validate_syntax.jl
than the command to check syntax would be julia validate_syntax.jl file_to_check
Hi, @MikeMirzayanov, is this method of checking syntax what you are looking for? Or is there anything else? Btw, that command can be used as a one-liner, i.e. julia -e "validatesyntax(fname) = include(expr -> Meta.isexpr(expr, (:error, :incomplete)) ? expr : nothing, fname);(length(ARGS) == 1) && validatesyntax(ARGS[1])" file_to_check.jl
Hi @MikeMirzayanov , I want to bump this issue to know what it will take to have julia language in the codeforces languages. Thanks!
It seems your "Theatre square" uses ~1GB of RAM (Windows 10, 64-bit, Julia 1.7.0). Do you know any workaround to reduce it?
Also, it uses \n by default as a line-break instead of \r\n (on Windows). Do you know how to force \r\n by default?
Could you please share how you measure RAM usage? Regarding linebreaks, does the following version does what you want?
using Base: println
Base.println(io::IO, xs...) = print(io, xs..., "\r\n")
(a,b,c) = [parse(Int, c) for c in split(readline(stdin), ' ')]
println(ceil(Int, a/c) * ceil(Int, b /c))
ping