binary-heap-benchmark icon indicating copy to clipboard operation
binary-heap-benchmark copied to clipboard

Julia version of heap added

Open artemsolod opened this issue 4 years ago • 8 comments

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!

artemsolod avatar Feb 22 '21 17:02 artemsolod

Please, provide me a way to check Julia syntax without running the program. Give me full code (I tried some without success).

MikeMirzayanov avatar Feb 24 '21 11:02 MikeMirzayanov

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

artemsolod avatar Feb 25 '21 10:02 artemsolod

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

artemsolod avatar Mar 09 '21 22:03 artemsolod

Hi @MikeMirzayanov , I want to bump this issue to know what it will take to have julia language in the codeforces languages. Thanks!

Pramodh-G avatar Aug 03 '21 14:08 Pramodh-G

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?

MikeMirzayanov avatar Dec 03 '21 15:12 MikeMirzayanov

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?

MikeMirzayanov avatar Dec 03 '21 15:12 MikeMirzayanov

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))

artemsolod avatar Dec 05 '21 20:12 artemsolod

ping

goyalyashpal avatar Nov 06 '23 06:11 goyalyashpal