Skip to main content
Removed 4 bytes from the code
Source Link
Endenite
  • 4.1k
  • 12
  • 28

Javascript (ES6), 121 110110 106 bytes

-11 Bytes15 bytes thanks to @Shaggy and @Justin

m=>`[[${(a=m.split`
`.map(x=>x.trim().replacematch(/ +\S+/g,").join`, ")`)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`"]`

Example code snippet:

f=
 
m=>`[[${(a=m.split`
`.map(x=>x.trim().replacematch(/ +\S+/g,").join`, ")`)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`
 
console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 121 110 bytes

-11 Bytes thanks to @Shaggy

m=>`[[${(a=m.split`
`.map(x=>x.trim().replace(/ +/g,", "))).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`"

Example code snippet:

f=
 
m=>`[[${(a=m.split`
`.map(x=>x.trim().replace(/ +/g,", "))).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`
 
console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 121 110 106 bytes

-15 bytes thanks to @Shaggy and @Justin

m=>`[[${(a=m.split`
`.map(x=>x.match(/\S+/g).join`, `)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`

Example code snippet:

f=
m=>`[[${(a=m.split`
`.map(x=>x.match(/\S+/g).join`, `)).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`
console.log(f(
`1 -2
 3  5
 6  7`
))

Reduced the code by 11 bytes
Source Link
Endenite
  • 4.1k
  • 12
  • 28

Javascript (ES6), 121121 110 bytes

-11 Bytes thanks to @Shaggy

s=>s="[["+m=>`[[${(s=sa=m.split`
`.map(x=>x.trim().replace(/(.) +/g,"$1", ").split(/\n */)).join("]join`], [")+`]][`}]]
{{`+s${a.join("join`}, {")+``}}}
[`+s[${a.join(";join`; ")+"]"`}]`"

Example code snippet:

f=

s=>s="[["+m=>`[[${(s=sa=m.split`
`.map(x=>x.trim().replace(/(.) +/g,"$1", ").split(/\n */)).join("]join`], [")+`]][`}]]
{{`+s${a.join("join`}, {")+``}}}
[`+s[${a.join(";join`; ")+"]"`}]`

console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 121 bytes

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

Example code snippet:

f=

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 121 110 bytes

-11 Bytes thanks to @Shaggy

m=>`[[${(a=m.split`
`.map(x=>x.trim().replace(/ +/g,", "))).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`"

Example code snippet:

f=

m=>`[[${(a=m.split`
`.map(x=>x.trim().replace(/ +/g,", "))).join`], [`}]]
{{${a.join`}, {`}}}
[${a.join`; `}]`

console.log(f(
`1 -2
 3  5
 6  7`
))

updated the byte count, off by 1
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Javascript (ES6), 120121 bytes

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

Example code snippet:

f=

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 120 bytes

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

Example code snippet:

f=

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

console.log(f(
`1 -2
 3  5
 6  7`
))

Javascript (ES6), 121 bytes

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

Example code snippet:

f=

s=>s="[["+(s=s.trim().replace(/(.) +/g,"$1, ").split(/\n */)).join("], [")+`]]
{{`+s.join("}, {")+`}}
[`+s.join("; ")+"]"

console.log(f(
`1 -2
 3  5
 6  7`
))

Fixed a problem in the program
Source Link
Endenite
  • 4.1k
  • 12
  • 28
Loading
Removed 8 bytes from the code
Source Link
Endenite
  • 4.1k
  • 12
  • 28
Loading
Source Link
Endenite
  • 4.1k
  • 12
  • 28
Loading