Skip to main content
5 of 11
Overzealous editing
doug
  • 1.4k
  • 3
  • 9

K (ngn/k), 337 331 315 294 bytes

s:{,/((#l)#("-";"")){x/y}',''l:(0,((#y)>)#+\(0,(-1+#l)#-1 1)+l:1_|1+&x#2)_y}
j:{0,+\(-1+2*x)/*/1(*\'1+-2*<':')\~:\2_((#l)#!2)@&l:,/+|1(2*1+)\|!x}
f:{t:@["|-"{1=1|x|-x}d;(-1+&0<l;!#y);:;(" ..''"(0<)#l:(0,,/-:\1,w:-1+2*x)?*/1(~=':)\d:-':i:j[x];y:s[x;y])];(x,w)#@[(x*w)#" ";(i;*|i);:;(t;"<>"2!x)]}

Try it online!

-6 : Save a few bytes with shorter names.
-16 : Tidying up
-19 : Cruft

doug
  • 1.4k
  • 3
  • 9