[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using Lua in programming contests
- From: Coda Highland <chighland@...>
- Date: Thu, 5 Jan 2017 12:59:31 -0800
On Thu, Jan 5, 2017 at 11:36 PM, Martin <firstname.lastname@example.org> wrote:
> On 17-01-05 10:31 AM, Egor Skriptunoff wrote:
>> But anyway, coding in Pascal is obviously easier:
>> one can successfully solve the same problem using less efficient algorithms.
>> Using Lua in HackerRank is harder.
> I'm not fully agree with this.
> In Pascal/C you'll spend time for problems requiring hash tables. Also
> there are no sparse arrays (at least in Pascal/Delphi) so you have to
> carefully preallocate arrays to stay in memory limit or implement
> dynamic allocation. In Lua you may forget about this details (but in
> change, you have to remember about garbaging).
> Both in Lua and C/Pascal you have to implement long number arithmetics.
> In Java AFAIK it is legal to use built-in long numbers support. So
> probably Java is good for programming contests too.
In Pascal and C you can get away with a linear array of key-value
pairs instead of using a hash table, because the underlying
performance is orders of magnitude higher than an interpreted
language. You could also use a binary tree instead of a hash table,
which is a much simpler implementation than a hash table while still
being faster than a linear array.
The whole point is that you don't have to use the most efficient
algorithm available to you when you're getting compiled to optimized
machine code; you can just brute force your way through it with
something good enough.