Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

CJam, 43 36 bytes

qN/('[/~;"[] = {"@{S/W=W<}%", "*"};" 

Online Example

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {" |add formatting to stack @ |rotate to remaining lines { }% |for each line in array S/W= |split after last space W< |remove last character (;) ", "* |insert ", " to array "};" |add formatting 

A big thanks to Martin EnderMartin Ender for the improvements on my first CJam answer.

CJam, 43 36 bytes

qN/('[/~;"[] = {"@{S/W=W<}%", "*"};" 

Online Example

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {" |add formatting to stack @ |rotate to remaining lines { }% |for each line in array S/W= |split after last space W< |remove last character (;) ", "* |insert ", " to array "};" |add formatting 

A big thanks to Martin Ender for the improvements on my first CJam answer.

CJam, 43 36 bytes

qN/('[/~;"[] = {"@{S/W=W<}%", "*"};" 

Online Example

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {" |add formatting to stack @ |rotate to remaining lines { }% |for each line in array S/W= |split after last space W< |remove last character (;) ", "* |insert ", " to array "};" |add formatting 

A big thanks to Martin Ender for the improvements on my first CJam answer.

saves 7 bytes
Source Link
Linus
  • 2k
  • 10
  • 22

CJam, 4343 36 bytes

qN/('[/~;"[] = {"+o"@{';-' S/)\;"W=W<}%", "}%);o""*"};"o;" 

[Online Example][1]Online Example

Explanation:

qN/  |Read all lines to array ('[/~;  |slice first line left of [ "[] = {"+o " |add formatting andto printstack @ { }% |rotate to remaining |forlines  each line in array  { ';-'}% /)\; |for each line in |reducearray  to number before ;   S/W= ", "|split after last space  |insert ", " to array   W< |remove last character (;)  );o |remove tail  ", ""* and print  |insert ", " to array  "};"o;" |add formatting and|add printformatting 

[1]:A big thanks to http://cjam.aditsu.net/#code=qN%2F('%5B%2F~%3B%22%5B%5D%20%3D%20%7B%22%2Bo%7B'%3B-'%20%2F)%5C%3B%22%2C%20%22%7D%25)%3Bo%22%7D%3B%22o&input=spam%20eggs%5B10%5D%3B%0Aeggs%5B0%5D%20%3D%200%3B%0Aeggs%5B1%5D%20%3D%204%3B%0Aeggs%5B2%5D%20%3D%208%3B%0Aeggs%5B3%5D%20%3D%20-3%3B%0Aeggs%5B4%5D%20%3D%203%3B%0Aeggs%5B5%5D%20%3D%207%3B%0Aeggs%5B6%5D%20%3D%20888%3B%0Aeggs%5B7%5D%20%3D%20555%3B%0Aeggs%5B8%5D%20%3D%200%3B%0Aeggs%5B9%5D%20%3D%20-2%3BMartin Ender for the improvements on my first CJam answer.

CJam, 43 bytes

qN/('[/~;"[] = {"+o{';-' /)\;", "}%);o"};"o 

[Online Example][1]

Explanation:

qN/  |Read all lines to array ('[/~;  |slice first line left of [ "[] = {"+o  |add formatting and print { }% |for each line in array  ';-' /)\; |reduce to number before ;  ", " |insert ", " to array  );o |remove tail ", " and print  "};"o |add formatting and print 

[1]: http://cjam.aditsu.net/#code=qN%2F('%5B%2F~%3B%22%5B%5D%20%3D%20%7B%22%2Bo%7B'%3B-'%20%2F)%5C%3B%22%2C%20%22%7D%25)%3Bo%22%7D%3B%22o&input=spam%20eggs%5B10%5D%3B%0Aeggs%5B0%5D%20%3D%200%3B%0Aeggs%5B1%5D%20%3D%204%3B%0Aeggs%5B2%5D%20%3D%208%3B%0Aeggs%5B3%5D%20%3D%20-3%3B%0Aeggs%5B4%5D%20%3D%203%3B%0Aeggs%5B5%5D%20%3D%207%3B%0Aeggs%5B6%5D%20%3D%20888%3B%0Aeggs%5B7%5D%20%3D%20555%3B%0Aeggs%5B8%5D%20%3D%200%3B%0Aeggs%5B9%5D%20%3D%20-2%3B

CJam, 43 36 bytes

qN/('[/~;"[] = {"@{S/W=W<}%", "*"};" 

Online Example

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {" |add formatting to stack @ |rotate to remaining lines  { }% |for each line in array    S/W= |split after last space    W< |remove last character (;)    ", "* |insert ", " to array  "};" |add formatting 

A big thanks to Martin Ender for the improvements on my first CJam answer.

add example
Source Link
Linus
  • 2k
  • 10
  • 22

CJam, 43 bytes

qN/('[/~;"[] = {"+o{';-' /)\;", "}%);o"};"o 

[Online Example][1]

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {"+o |add formatting and print { }% |for each line in array ';-' /)\; |reduce to number before ; ", " |insert ", " to array );o |remove tail ", " and print "};"o |add formatting and print 

[1]: http://cjam.aditsu.net/#code=qN%2F('%5B%2F~%3B%22%5B%5D%20%3D%20%7B%22%2Bo%7B'%3B-'%20%2F)%5C%3B%22%2C%20%22%7D%25)%3Bo%22%7D%3B%22o&input=spam%20eggs%5B10%5D%3B%0Aeggs%5B0%5D%20%3D%200%3B%0Aeggs%5B1%5D%20%3D%204%3B%0Aeggs%5B2%5D%20%3D%208%3B%0Aeggs%5B3%5D%20%3D%20-3%3B%0Aeggs%5B4%5D%20%3D%203%3B%0Aeggs%5B5%5D%20%3D%207%3B%0Aeggs%5B6%5D%20%3D%20888%3B%0Aeggs%5B7%5D%20%3D%20555%3B%0Aeggs%5B8%5D%20%3D%200%3B%0Aeggs%5B9%5D%20%3D%20-2%3B

CJam, 43 bytes

qN/('[/~;"[] = {"+o{';-' /)\;", "}%);o"};"o 

Explanation:

qN/ |Read all lines to array ('[/~; |slice left of [ "[] = {"+o |add formatting and print { }% |for each line in array ';-' /)\; |reduce to number before ; ", " |insert ", " to array );o |remove tail ", " and print "};"o |add formatting and print 

CJam, 43 bytes

qN/('[/~;"[] = {"+o{';-' /)\;", "}%);o"};"o 

[Online Example][1]

Explanation:

qN/ |Read all lines to array ('[/~; |slice first line left of [ "[] = {"+o |add formatting and print { }% |for each line in array ';-' /)\; |reduce to number before ; ", " |insert ", " to array );o |remove tail ", " and print "};"o |add formatting and print 

[1]: http://cjam.aditsu.net/#code=qN%2F('%5B%2F~%3B%22%5B%5D%20%3D%20%7B%22%2Bo%7B'%3B-'%20%2F)%5C%3B%22%2C%20%22%7D%25)%3Bo%22%7D%3B%22o&input=spam%20eggs%5B10%5D%3B%0Aeggs%5B0%5D%20%3D%200%3B%0Aeggs%5B1%5D%20%3D%204%3B%0Aeggs%5B2%5D%20%3D%208%3B%0Aeggs%5B3%5D%20%3D%20-3%3B%0Aeggs%5B4%5D%20%3D%203%3B%0Aeggs%5B5%5D%20%3D%207%3B%0Aeggs%5B6%5D%20%3D%20888%3B%0Aeggs%5B7%5D%20%3D%20555%3B%0Aeggs%5B8%5D%20%3D%200%3B%0Aeggs%5B9%5D%20%3D%20-2%3B

Source Link
Linus
  • 2k
  • 10
  • 22
Loading