Marshall Lochbaum's online BQN REPL has an interesting(and aesthetically pleasing) method of displaying arrays. Your task is to implement a version with simpler rules.



· 2 ┌·    4 ┌·                     
    · 3     · ┌·                   
        ┘     · ┌─                 
                · 6 ┌·    7        
                    · 5            

Rules for drawing

  • A singleton array has

as its top left corner.

  • A non-singleton array has

as its top left corner.

(In the actual BQN, this is used for rank-0, or "unit" arrays)

  • All arrays have

as their bottom right corner.

  • Each element at a certain depth will be displayed at the same depth vertically. For example, 2 and 4 are displayed 1 unit from the top since they are at depth 1.
  • Each further level of nesting depth moves 1 unit down in depth.
  • Numbers next to each other will be separated by a single space.

Other details

  • You may take a ragged numeric array in any way your language supports.
  • The input will only consist of integers and nested arrays containing integers.
  • If your language does not support arrays with depth, you may take a string/other equivalent that your language supports.
  • If your language's codepage does not contain the characters ┌ · ─ ┘, you can count them as 1 byte.
  • This is . Shortest answer in each language wins.
  • Since bacon strips are thin, your code must be thin and small as well.
  • \$\begingroup\$ Nice challenge, though I feel like "Take a nested array, and 'pull down' elements one line for each depth of nest", with none of the special character requirements, might be the purer form of it. \$\endgroup\$
    – Jonah
    Apr 24, 2021 at 16:27
  • 1
    \$\begingroup\$ @Jonah That is a good idea. I'll sandbox it. \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 16:28
  • \$\begingroup\$ I realized you'd still need a way to show arrays ending -- eg, if you had two adjacent nested arrays. That could be printed on the same line though. \$\endgroup\$
    – Jonah
    Apr 25, 2021 at 0:36
  • \$\begingroup\$ @Jonah seems like this is the exact same idea, except upside down. \$\endgroup\$
    – Razetime
    Apr 25, 2021 at 4:42
  • \$\begingroup\$ Yeah it’s too close \$\endgroup\$
    – Jonah
    Apr 25, 2021 at 5:03

1 Answer 1


Charcoal, 72 bytes


Try it online! Link is to verbose version of code. Uses lists rather than arrays because they're easier to input. Explanation:


Switch over each character of the input as a string.

For a (, ...


... save the vertical position as the top margin, ...


... assume a single-element list, ...


... and save the vertical position again, this time as the bottom margin.


For a ), ...


... get the bottom margin of this list, plus 1, ...


... move to that row, ...

... close the list, ...


... move to and forget the top margin of this list, ...


... and update the bottom margin of the containing list if necessary.


For a ,, ...


... grab the text on the previous row, ...


... find the and change the character after it to a , ...

... and move to the next column on the original row.


Otherwise, just output the current character.

Note that the · is in Charcoal's code page (so because it needs to be quoted it ends up costing me two bytes!) but the box-drawing characters are not. They would normally cost three bytes in Charcoal so as I use them four times I have subtracted 8 bytes from Charcoal's calculation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.