Ctrl+P again to print, arrows/tab to navigate results, enter to confirm

    General

    Types

    Numbers and keywords

    Example I (for-to)
    for i:=1 to 100 do doSomething(i);
    
    for i:=1to 100do doSomething(i);
    
    Example II (repeat-until)
    i:=0;repeat doSomething(i);i+=1;until i=100;
    
    i:=0;repeat doSomething(i);i+=1until i=100;
    
    Example III (end)
    begin i:=0;repeat i+=1;doSomething(i)until i=100;end.
    
    begin i:=0;repeat i+=1;doSomething(i)until i=100end.
    {❌ ERROR, parsed as 100e and expecting the exponent}
    
    begin i:=0;repeat i+=1;doSomething(i)until i=1e2end.
    {✅ NO ERROR}
    

    HEX and OCT integers

    Example I (hex superiority)
    begin doSomething(x);x:=x div 10;end;
    
    begin doSomething(x);x:=x div$a;end;
    
    Example II (oct superiority)
    begin doSomething(x);x:=x div 500;end;
    
    begin doSomething(x);x:=x div$1f4;end;
    
    begin doSomething(x);x:=x div$1f4end;
    {❌ ERROR, FPC is trying to parse "$1f4e" as a hex integer}
    
    begin doSomething(x);x:=x div&764;end;
    
    begin doSomething(x);x:=x div&764end;
    {✅ NO ERROR, oct values don't have 'e' in the range of digits and can't be represented in scientific notation}
    

    Loops

    Example I (one operation)
    for i:=1to 100do doSomething(i);
    
    i:=0;repeat i+=1;doSomething(i)until i=100;
    
    Example II (two operations)
    for i:=1to 100do begin doSomething(i);doSomethingElse(i)end;
    
    i:=0;repeat i+=1;doSomething(i);doSomethingElse(i)until i=100;
    
    Example III (two operations with a variable implicitly set to 0)
    var i:word;{...}for i:=1to 100do begin doSomething(i);doSomethingElse(i)end;
    
    var i:word;{...}repeat i+=1;doSomething(i);doSomethingElse(i)until i=100;
    

    Functions and procedures

    Example I (no args)
    begin writeln()end.
    
    begin writeln;end.
    
    Example II (func name)
    function f(x:word):word;
    var i:word;
    begin
      for i:=1to x do doSomething(i);
      f:=x*x;
    end;
    
    function f(x:word):word;
    begin
      for f:=1to x do doSomething(f);
      f:=x*x;
    end;
    

    Arguments number

    Example
    var i:word;begin for i:=1 to 100 do doSomething(i);end.
    
    begin for argc:=1 to 100 do doSomething(argc);end.
    

    CTRL-format for characters

    Example (^` vs ' ')
    {$H+}
    uses sysutils;begin writeln('code golf'.split(' ')[1]);end.
    
    {$H+}
    uses sysutils;begin writeln('code golf'.split(^`)[1]);end.
    
    Most useful replacements
    ^@ → '\0'
    ^i → '\t'
    ^j → '\n'
    ^m → '\r'
    
    ^` → ' '
    ^< → '|'
    ^> → '~'
    
    ^a..^z → char(1)..char(26)
    ^0..^9 → 'p'..'y'
    

    Argument Iteration

    For holes with inputs, this is the most common pattern:

    var i:word;begin repeat i+=1;...;until i=argc-1;end.
    

    When the body code is one line, you can use this (7b shorter):

    var i:word;begin for i:=1to argc-1do ...;end.
    

    Hardcoding Argc

    Find your hole here. If you don't found the hole or seen (TO-DO), just use this code and run few times to ensure argc is hardcoded:

    begin
      writeln(argc);
    end.
    

    Then, you can replace argc-1 with the specified argc, and this works. For example, if the argc is said to be 128, then replace argc-1 with 128. Keep in mind when the hole's argc is edited, it's possible to break your code - just update argc.

    Overshooting Argc

    You can often overshoot argc by using a larger constant than the actual argument count. This can save bytes because some numeric literals are shorter than the exact argc value. For example, if argc is 128, 2e2 may be usable instead of 128 if the extra iterations do not affect the output. This can also work for random-argc holes when a sufficiently large constant is safe. For example, 5e4 can current replace argc-1 in all holes. Be careful: this is only valid when the extra iterations are harmless. For example, when your code contains ReadStr, then you'd get a EInOutError error.

    Variant

    Example (FizzBuzz mock)
    {n bytes}
    var i:word;s:string;
    begin
     for i:=1 to 100 do begin
      s:=getFizzBuzzString(i);
      if s=''then write(i);
      writeln(s);
     end;
    end.
    
    {n-3 bytes}
    var i:word;s:variant;
    begin
     for i:=1 to 100 do begin
      s:=getFizzBuzzString(i);
      if s=''then s:=i;
      writeln(s);
     end;
    end.
    

    String to Number parsing

    Example
    var x:int32;s:string='69419';begin val(s,x);writeln(x+1)end.
    
    uses sysutils;var s:string='69418';begin writeln(strtoint(s)+2)end.
    
    uses{$H+}sysutils;var s:string='69417';begin writeln(s.toint64+3)end.
    
    uses strutils;var s:string='69416';begin writeln(numb2dec(s,10)+4)end.
    
    var v:variant;x:int32;s:string='69415';begin v:=s;x:=v;writeln(x+5)end.
    
    uses sysutils;var x:int32;s:string='69414';begin sscanf(s,'%d',[@x]);writeln(x+6)end.
    

    Packer

    2:1

    uses baseunix;
    var f:text;c:wchar;
    begin
    assign(f,^0);rewrite(f);
    for c in'PACKED_CODE'do write(f,chr(lo(ord(c))));
    reset(f);fpdup2(3,0);
    fpexecv('/usr/bin/pascal',argv)
    end.