Skip to main content
2 of 4
improved formatting and added more input data
wen1k
  • 53
  • 6

Lua, 205 bytes

load("t="..(...).."c=#t for i=1,c do c=math.max(c,#t[i])end p=load'io.stdout:write(...)'p'{'for i=1,c do for j=1,c do _=j==1 and p'{'p(t[i]and t[i][j]or 0)p(j==c and'}'or',')end _=i~=c and p','end p'}'")()

Try it online!

Human readable code:

load(
  "t="..(...)..
  "c=#t
   for i=1,c do
     c=math.max(c,#t[i])
   end
   p=load'io.stdout:write(...)'
   p'{'
   for i=1,c do 
     for j=1,c do
       _=j==1 and p'{'
       p(t[i]and t[i][j]or 0)
       p(j==c and'}'or',')
     end
     _=i~=c and p','
   end
   p'}'
  ")
()
wen1k
  • 53
  • 6