I was pretty sure I have seen this in sed(1) already, but I couldn’t find it anywhere, so I’ve been nerd-sniped into doing it myself:
:b
p
s/$/0/
s/^/,0/
:a
s/,\(.\)\(.\)\(.\)/\1\2\3,\2\3/
s/111,/o,/
s/110,/o,/
s/101,/o,/
s/100,/x,/
s/011,/x,/
s/010,/x,/
s/001,/x,/
s/000,/o,/
t a
s/,.*//
y/xo/10/
t b
I was pretty sure I have seen this in sed(1) already, but I couldn’t find it anywhere, so I’ve been nerd-sniped into doing it myself:
Example run:
Awesome 👏