About
mftrhu on Keybase, GitHub, HackerNews, Reddit
I usually program in Python, but my first language - a long, long time ago - was Pascal, and lately I have gone back to it to solve these challenges. How d can get their solutions to be so fast is still beyond me.
A few notes on Pascal:
SetLength(arr, len)
gives youarr[0..len-1]
, and not, as I misread,arr[1..len]
.- As a corollary to the previous item, dynamic arrays are mostly not necessary here.
- Unless messing around with
$mode
, "Aninteger
is 16-bit in TP or FPC modes, or 32-bit in ObjFPC or Delphi modes." - better useint32
orint64
instead. - Unless messing around with
$mode
,string
will be an alias forShortString
, andShortString
can only contain up to 255 characters (and will truncate the input silently) - better useAnsiString
instead. - As a corollary to the previous two items, messing around with
$mode
is probably a good idea as it seem to default to Turbo Pascal (tp
) mode. Set{$mode fpc}
to avoid some issues (e.g.case
not working with strings), set{$mode objfpc}
to avoid the most common pitfalls.