Mandelbrot Set 358

Back to General discussions forum

Amaveritas     2023-09-18 21:38:55
User avatar

Hello Rodion (and anyone else),

The checker is saying my code generates an exit code of -1 and that I should tell an admin or that I've broken something. There were no error messages when the code was tested, so I was hoping for some insights into my problem. Any help is appreciated.

Jesse

Rodion (admin)     2023-09-19 04:31:05
User avatar

Jesse, Hi!

Thanks for reporting this! Actually you haven't broken anything, it is timeout signalled this way (code execution is limited by 1 second I think) - but obviously I have forgotten to detect this -1 and show proper error message :(

Will fix it now (and I guess in other similar problems too).

Amaveritas     2023-09-19 06:06:48
User avatar

Thank you for the quick fix, Rodion. I managed to produce an acceptable answer, although I had to set a limit of 7 iterations and R = 1.5. I noticed from the other submissions that tables and square roots were generally avoided. Will try to play around with this problem some more...

Rodion (admin)     2023-09-19 06:12:56
User avatar

Hm-m-m, thanks for sharing this experience! Problem of course involves calculating many points... I recently found that Lua besides standard scripting engine has also JIT implementation, which works with speed similar to programs compiled to native code (e.g. C and Go) - about 7-10 times faster. (this probably makes it language of choice in some industrial projects, i.e. Tarantool)

Probably we may add such lua-jit thing as alternative executor in the nearest future...

TestUser     2023-09-20 16:40:35
User avatar

oh, it's me, Rodion, just from user's account while testing the feature...

As a follow-up, I managed to add LuaJIT interpreter to sandbox, and it is used by the checker for Lua problems too.

To use it, put as a first line of the program some comment containing luajit.

For example, trying to sum up square roots of numbers up to 1 million:

res = 0
for i=1,1000000 do
  res = res + math.sqrt(i)
end
print(res, os.clock())

We get 666667166.45884 0.14582 (the latter value means 146 milliseconds execution time).

Now the same with the magical comment:

--luajit
res = 0
for i=1,1000000 do
  res = res + math.sqrt(i)
end
print(res, os.clock())

Results in 666667166.45884 0.011789 (i.e. just 12 milliseconds).

Drawback is that LuaJIT doesn't support most recent language features - it is conformant to Lua 5.1 "with some syntax from 5.2 and 5.3 included".

I shall add this to our instructions.

Amaveritas     2023-09-20 19:16:30
User avatar

Worked like a charm! The checker accepts a solution using n = 1000 iterations, now. Very nice feature.

Please login and solve 5 problems to be able to post at forum