#GNU sed -r, 160
GNU sed -r, 160
Sigh, I thought this would be smaller, but here it is anyway. Unfortunately sed regexes don't have any lookaround capability.
:
s/(.*)1$/ =\1/;t
s/([= ]+)/\1\n\1/
:b
s/ (.*\n)/===\1/;tb
s/(1*)1 $/\n\1/
:c
s/([^\n]*\n[^\n]*\n)(1*)1$/\1\1\2/;tc
s/(=+)(.*)/\1\2\1/
s/(^|\n)(.)/\1=\2/g
Taking input as unary from STDIN:
$ sed -rf boxes.sed <<< "11 111"
=============
= = = =
=============
= = = =
=============
$