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

    Printing

    Here is the shortest way to print a string

    _=&@import("std").posix.write(1,"Hello!");
    

    And the shortest way to print anything that isn't a string. io.getStdOut() has been removed in the latest revision of zig. This no longer works:

    // _=&@import("std").io.getStdOut().writer().print("{}",.{12345});
    

    Try this instead:

    const s=@import("std");_=&s.posix.dup2(1,2);s.debug.print("{}\n",.{i});
    

    Or this (invalid after Zig 0.15.1) if you need your solution to crash without printing an error message to stdout:

    _=&@import("std").fs.File.stdout().deprecatedWriter().print("{}\n",.{i});
    

    Note that the string printer, posix.write, takes a number as its first argument. If the number is 2, it prints to stderr, which code.golf ignores, so this can be used for conditional printing. Passing any number other than 1 or 2 crashes the program.

    Variable declarations

    When declaring more than one variable of the same type, it is often good to avoid declaring the type each time.

    var a:u8=0;var b:u8=0;
    

    vs.

    var a:u8=0;var b=a;
    

    Usize

    Don't declare a variable as usize, u64 is the same thing

    var x:usize=0;
    var x:u64=0;