The autodetect mechanism is not always detecting correctly

Back to General discussions forum

oezguery     2023-07-30 06:16:07
User avatar

I have so far been submitting solutions in python alone.
For some reason my solutions are sometimes being autodetected as Lisp or C#.
I have nothing against those languages but it does not reflect the truth.

Rodion (admin)     2023-07-30 09:09:51
User avatar

Özgür, thanks for notifying of this - probably I noticed this also before, but actually it is a bit difficult to tune our trivial "auto-detector".

You can peek into its code if you open this file (it is in JS but probably most of the cases are clear enough):

it could be seen that it gets wrong way into C# if (hopefully I remember and understand correctly) amount of "endline" characters (like semicolons, used in C#, C++, Java) is above certain percentage of total line count. Probably it is not the best criteria :)

As about getting into LISP - this seemingly happens on finding (+ or (* sequences, characteristique for this language with prefix expression notations. Well, perhaps this also should be tuned somehow better...

So as you now see the mechanism, feel free to suggest improvements... Though this may require testing them on existing solutions in different languages to make sure that languages besides Python do not suffer :)

oezguery     2023-07-30 17:29:45
User avatar

Thank you Rodion,
I see why my solutions are often being detected as LISP, I write print(*results) in Python to print results.

Rodion (admin)     2023-07-31 05:42:22
User avatar

Aha! thanks for the hint, let's remove searching for (* then, probably it won't harm LISP detection much. Hopefully it's better now.

As for C# mis-detection, this seems more vague, but I made small change (removed counting closing curly bracket at the end of line) and we'll see if it's better.

Rodion (admin)     2023-08-02 15:31:36
User avatar

UPD: this recurring question provided idea for the new task.

Language Detector

oezguery     2023-08-02 22:15:58
User avatar

Nice task. I need to learn Lua first.

Rodion (admin)     2023-08-03 05:26:08
User avatar

That's true, sorry :) Our Lua Quickstart page says that for Python programmer it may be so familiar that one can start coding straight away. However dealing with strings (search, patterns) may require looking up suitable functions in documentation (and is a bit clumsy in Lua, to my taste, not because language designers were evil, but due to optimization reasons).

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