Q;S⁹o_ Helper link.
Arguments: [k, 0, k] and [0, m, 0] (any order)
Q Unique; deduplicate the left argument.
; Concatenate the result with the right argument.
S Take the sum of the resulting array.
⁹o Logical OR with the right argument; replaces zeroes in the
right argument with the sum.
_ Subtract; take the difference with the right argument to
remove its values.
This maps [k, 0, k], [0, m, 0] to [0, k + m, 0] and
[0, m, 0], [k, 0, k] to [m + 2k, 0, m + 2k].
3ḶḂç@⁸СIµa"Ṿ€o⁶z⁶Zµ€Z Monadic link. Argument: A (array of column indices)
3Ḷ Yield [0, 1, 2].
Ḃ Bit; yield [0, 1, 0].
I Increments of n; yield [].
С Apply...
ç@ the helper link with swapped arguments...
⁸ n times, updating the left argument with the return
value, and the right argument with the previous value
of the left one. Collect all intermediate values of
the left argument in an array.
µ µ€ Map the chain in between over the intermediate values.
Ṿ€ Uneval each; turn all integers into strings.
a" Vectorized logical AND; replace non-zero integers with
their string representation.
o⁶ Logical OR with space; replace zeroes with spaces.
Zz⁶ Zip with Zip;fill value space; transpose the resulting 2D
array after inserting spaces to make it rectangular.
Z Zip; transpose the result to restore the original shape.
Z Zip; transpose the resulting 3D array.