Skip to main content
Commonmark migration
Source Link

#Pyth, 21 bytes

Pyth, 21 bytes

#Pyth, 21 bytes

Pyth, 21 bytes

Clarification of trailing newline handling
Source Link

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline. If you want it to deal with no trailing newline, add < at the beginning of the program and )_3 at the end.

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline.

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline. If you want it to deal with no trailing newline, add < at the beginning of the program and )_3 at the end.

Source Link

#Pyth, 21 bytes

j.imjC9d.zmjC9+CMdT.z

Here's an entry from one of "those damned Pyth programmers" ;)

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline.

Try it online

The output for the test case is difficult to see in the online interpreter, so I've included it here:

#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   t   (   )       {
105 110 116 32  109 97  105 110 116 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10

How it works

j.imjC9d.zmjC9+CMdT.z  Program. Input: .z (All of STDIN split on newlines)
     C9                 Yield tab character by taking chr(9)
    j                   Join on tab
   m   d.z             Map that over .z
               CM       Map ord()
              +   T     Append 10
           jC9          Join on tab
          m      d .z  Map that over .z
 .i                    Interleave the results of the two mappings
j                      Join on newlines
                       Implicitly print