About the Pascal category

This subcategory is for Pascal programmers. Don’t be shy, no question is too simple or too complicated.

Please, do not post here if your question is about a puzzle, a contest or anything that relates to the CodinGame platform (there are other categories for that purpose).

hello! i’ll be first to report about pascal!

i have already one improvement about solving puzzles in pascal: use strutils - it helps alot in almost half of puzzles!

i think i have another improvement

how current ParseIn procedure looks like:

uses classes;

procedure ParseIn(Inputs: TStrings) ;
var Line : string;
begin
    readln(Line);
    Inputs.Clear;
    Inputs.Delimiter := ' ';
    Inputs.DelimitedText := Line;
end;

var
    Inputs: TStringList;
    SomeIntValue, NextIntValue: Int32;
begin
    Inputs := TStringList.Create;
    ParseIn(Inputs);
    SomeIntValue := StrToInt(Inputs[0]);
    NextIntValue := StrToInt(Inputs[1]);
    ...
    //and so on

    flush(StdErr); flush(output); // DO NOT REMOVE
end.

IMHO this will be better:

uses strutils;

var
    SomeIntValue, NextIntValue: Int32;
    Line: String;
    function ParseIn(i : Int32) : String;
    begin
       ParseIn := ExtractWord(i, Line, [' ']); 
    end;
begin
    readln(Line);
    SomeIntValue := StrToInt(ParseIn(1));
    NextIntValue := StrToInt(ParseIn(2));
    ...
    //and so on
    
    flush(StdErr); flush(output);
end.
1 Like

guys, help! i need a “clean” button, because i fixed one typo in my solution and see no effects

What packages are supported on CG?
I tried to use AVLTree, but could’nt make it work.

It seems like of all the data structures from this page only RTL part is avaliable.
http://wiki.lazarus.freepascal.org/Data_Structures,_Containers,_Collections
I couldn’t use neither AVL_Tree nor Contnrs units.

I would really like to be able to use contnrs for TQueue and TStack.

also, CG IDE commenting shortcut is using “–” for a comment which is plain wrong.

What Units/Packages are available or supported? And I wouldn’t mind changing the ParseIn method. bvs23bkv33 did a good job on that. No object creation required. It needs less characters and therefore ideal for short code competitions.