zig(x) = abs(x - 4 floor(x / 4) - 2) - 1
zag(x) = zig(x - 1)