Zig implementation (with online playground)