title: Full Width Text

text:
# Question
Title: Full Width Text
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes:

```
F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e .

```

Write a program that takes a line in text from standard input and outputs it as full-width text to standard out.

## Leaderboard

```
var QUESTION_ID=75979,OVERRIDE_USER=52353;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
> 29 votes
# Jelly, ~~5~~ ~~3~~ 2 bytes

Thanks to *Dennis* for saving 2 bytes. Also thanks to *FryAmTheEggman* for saving 1 byte. Code:

```
p⁶

```

Explanation:

```
p⁶   # Cartesian product with the input and the space character.

```

Uses the Jelly encoding.

Try it online!

# Answer
> 28 votes
# Python 3.5, 18 bytes

```
print(*input(),'')

```

This works because `print`'s default separator is single space.

# Answer
> 17 votes
# Hexagony, ~~21~~ ~~13~~ ~~12~~ 10 bytes

**Code:**

Saved a *lot* of bytes thanks to *FryAmTheEggman*. Code:

```
P,<0/*;@.>

```

Or in a more readable form:

```
  P , <
 0 / * ;
@ . > . .
 . . . .
  . . .

```

Try it online!

**Explanation:**

The Hexagony program starts at the top-left corner, immediately setting the memory edge to the ASCII value of `P`, which is 80. After that, we can see that the following path is taken:

We can see that the path taken is: `P,<;.P/0....;*/>`. After the `P`, we take a byte of user input. If this is empty, the following branch (`<`) would direct us to the North East. If the input is non-empty, the branch directs us to the South East. After that, we output the user input using `;`. We set the memory edge back to `P`, which is 80. The zero followed by the mirror is then concatenated to our number, resulting into 800. This is then outputted using the `;` command, but first it is taken modulo 256, resulting into 32, which is the space character. After that, we reset the memory edge using the `*` command and return to loop over the rest of the user input. When we're done with the user input, the path is directed to the North East:

This basically goes to the `@` command, which terminates the program.

Using Timwi's amazing *HexagonyColorer* for making the diagrams.

# Answer
> 13 votes
## Haskell, 11 bytes

```
((:" ")=<<)

```

Usage example: `((:" ")=<<) "Code Golf"` -\> `"C o d e G o l f "`.

Map each character `c` to a two element list `[c, space]` and concatenate everything into a single list.

# Answer
> 9 votes
# Retina, 5

```
.
$&

```

Note the space at the end of the second line.

`$&` is equivalent to `$0`. Thanks to @mbomb007 for this link.

Try it online.

# Answer
> 6 votes
# JavaScript, 20 Bytes

Simple, I just wish that Array.join added the space to the end so I could save 3 bytes.

```
s=>[...s,``].join` `

```

# Answer
> 5 votes
## Java, 132 (System.in) or 99 (Program argument) bytes

Can you feel the overhead tonight?

```
class F{public static void main(String[]a){System.out.print(new java.util.Scanner(System.in).nextLine().replaceAll("(.)", "$0 "));}}
class W{public static void main(String[]a){for(char c:a[0].toCharArray())System.out.print(c+" ");}}

```

shooqie figured out a 6 byte shorter way to do this but I won't steal their approach. I've used it with the STDIN and lambda versions, however.

28 characters for a lambda but that doesn't meet the program requirement.

```
s->s.replaceAll("(.)","$0 ")

```

# Answer
> 5 votes
# Awk, 7 bytes

(4 characters code + 3 characters command line option.)

```
NF++

```

Sample run:

```
bash-4.3$ awk -F '' 'NF++' <<< 'Full width text.'
F u l l   w i d t h   t e x t .

```

(There is some disagreement on what should be included in the command line option count. I included what is actually passed to the `awk` interpreter: “-”, “F” and a separator between “F” and the empty string parameter. See below what I mean.)

```
bash-4.3$ od -tax1 /proc/`pidof awk`/cmdline
0000000   a   w   k nul   -   F nul nul   N   F   +   + nul
         61  77  6b  00  2d  46  00  00  4e  46  2b  2b  00
                         ╰────────╯

```

# Answer
> 5 votes
# \>\<\>, ~~13~~ 10 bytes

*3 bytes saved thanks to @Sp3000*

```
i:0(?;o 'o

```

**Try it here**. Click the link, then *Submit*, then type some input and press *Give*, and finally run the program with *Start* or *Run without animation*.

### Explanation

```
i       read a character
:       duplicate
0(      is it less than 0?
?;      if so: end program. Else:
o       output read character
 '      push all chars until matching (same) quote. Top character is a space
o       output that character, which is a space. Go back to the beginning

```

# Answer
> 4 votes
# Java, 92

```
class T{public static void main(String[]A){System.out.print(A[0].replaceAll("(.)","$0 "));}}

```

# Answer
> 4 votes
# Cubix, 10 bytes

Cubix is a 2 dimensional language developed by @ETHproductions where the commands are wrapped onto a cube. Try it online

```
@.?wi^\oSo

```

This maps onto a cube with edge length 2

```
    @ .
    ? w
i ^ \ o S o . .
. . . . . . . .
    . .
    . .

```

Starts with a input `i`. The flow is redirected north `^` to the top face. `?` If the value is negative turn left to finish `@`, zero carries on into shift right `w` or positive turn right then reflect left `\`. Output character with a trailing space `oSo`.

# Answer
> 4 votes
# Cubix, 9 bytes

```
@./.i?>So

```

**See it work online!**

Cubix is a language in which the instructions are mapped out onto the face of a cube. This program forms the following cube net:

```
    @ .
    / .
i ? > S o . . .
. . . . . . . .
    . .
    . .

```

The instruction pointer begins at `i`, which takes another character-code from input and pushes it to the stack. If there is no more input left to be taken, the `?` turns the IP left, where it hits `/`, and is reflected upwards to `@`, which terminates the program.

However, if there is input left, the value will be a character code. As all1 character codes are positive, the `?` makes the IP turn right, where it wraps all the way around the cube, passing `o` on the way which outputs the char. It then hits `/` which makes it loop back around to `>So`, which pushes and prints a space. The IP carries on west until wrapping around back to the `i`, back to the start of the main loop.

1 *If the character is a null byte, it will ignore the `?` and carry on straight ahead, simply outputting a single space.*

---

Of course, there's only so much a written explanation can do, so I highly recommend you view this in the online interpreter. There's a "speed" option, which allows you to view the execution as slow or fast as you like.

# Answer
> 4 votes
# Stax, 2 bytes

Ties Jelly!

```
0\

```

Try it at staxlang.xyz!

All this does is push `0` to the stack and zip the string from standard input with it, repeating the 0 as necessary. In Stax, code point 0 in a string is usually converted to 32 (space).

This is short enough that packing it into `ûT` does nothing but reduce readability.

# Answer
> 3 votes
# Pyth, ~~5~~ 4 bytes

*Thanks to @FryAmTheEggman for saving a byte.*

```
s*zd

```

Try it online here.

# Answer
> 3 votes
# MATL, 7 bytes

```
tnZ"v1e

```

**Try it online!**

### Explanation

```
t    % implicitly take input string and duplicate it
n    % number of elements
Z"   % string with that many spaces
v    % concatenate vertically (2xN array, where N is input length)
1e   % reshape into 1 row. Implicitly display

```

# Answer
> 3 votes
## Seriously, 7 bytes

```
' ;,@j+

```

Try it online!

Man, that required ending space added 3 additional bytes. Without it, `,' j` would work for 4.

Explanation:

```
' ;,@j+
' ;      push two copies of a single space
   ,@    push input, swap
     j+  join on spaces, append a space

```

# Answer
> 3 votes
# 05AB1E, 4 bytes

```
Sð«J

```

Try it online.

## Explanation

```
Sð«J

S     split string into a list
 ð«   append a space to each element
   J  join

```

# Answer
> 3 votes
# Gema, 5 bytes

```
?=?\

```

Sample run:

```
bash-4.3$ gema '?=?\ ' <<< 'Full width text.'
F u l l   w i d t h   t e x t .

```

# Answer
> 3 votes
# CJam, ~~5~~ 4 bytes

*1 byte fewer thanks to @FryAmTheEggman*

```
lSf+

```

**Try it online!**

### Explanation

```
l     e# read line
Sf+   e# map "concatenation" (+) with a space (S) as extra parameter
      e# implicitly display characters in the stack

```

# Answer
> 3 votes
# GolfScript, 6 bytes

```
' ':n*

```

Try it online!

# Answer
> 3 votes
# C, 56 Bytes (as program argument), 46 Bytes (from stdin)

```
main(int a,char**b){while(*b[1])printf("%c ",*b[1]++);}

```

Plain old C answer. Once compiled, the program needs to be called with a string as it's first parameter, a string with spaces needs to be enclosed in quotes. For the example in the start post:

```
./prog "Full width text is text that has a space after every character, including the last one."

```

Which will output

```
F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e .

```

Solution that reads directly from stdin.

```
main(c){while(c=~getchar())printf("%c ",~c);}

```

One byte less thanks to @FryAmTheEggman

# Answer
> 3 votes
# brainfuck, ~~24~~ 22 bytes

Simple example using the shortest known 32 for the space character(s).

```
,[.>>-[-[-<]>>+<]>-.,]

```

**Try it online**

# Answer
> 3 votes
# R, 36 bytes

```
cat(strsplit(readline(),"")[[1]],"")

```

Example:

```
> cat(strsplit(readline(),"")[[1]],"")
Hello R!
H e l l o   R !

```

# Answer
> 3 votes
# WhoScript 38 bytes

```
1v;pr;e;#0 1;-;i;t=;ti;o;tl;" ";d;>;pf

```

Works best when the string is given at the command line, but it can be done one character at a time in real time as well.

Ungolfed:

```
time_vortex
  psychic_paper read
  duplicate
  # 0 1
  -
  integer
  TARDIS =
  TARDIS if
      opening
  TARDIS landing
  # 20
paradox
pop
psychic_paper flush

```

# Answer
> 3 votes
### PHP, 39 bytes

```
echo join(' ',str_split($argv[1])).' ';

```

Run it from the command line

```
php fullwidth.php "Full width text is text that has a space after every character, including the last one."

```

https://eval.in/541179

# Answer
> 3 votes
## Labyrinth, 10 bytes

```
<.23.%):,>

```

This terminates with an error, but the error messages goes to STDERR.

Try it online!

### Explanation

This is one of the rare cases where a completely linear program is feasible. The loop is achieved via the source code modification commands `<` and `>`, which works because after each iteration we know that the stack is empty again.

`<` cyclically shifts the entire line one cell to the left, so we end up with:

```
.23.%):,><

```

This takes the instruction pointer (IP) with it so the IP is now at the right end of the code and has to move left. Next, the `>` does the opposite modification so it shifts the source code back to

```
<.23.%):,>

```

Now we execute a single iteration (from right to left), before everything starts over:

```
,    Read a character code from STDIN, or -1 at EOF.
:)   Duplicate and increment.
%    Modulo. At EOF this will attempt a division by zero and terminate. Otherwise, we
     have n % (n+1) = n, so we're left with the input character again.
.    Print it back to STDOUT.
32   Turn the top of the stack into a 32.
.    Print it as well (a space).

```

# Answer
> 3 votes
# C, 50 bytes

Little bit of `main()` recursion :)

```
main(c){~(c=getchar())?printf("%c ",c),main():0;}

```

Try it online! \- If using this on your own machine, use `Ctrl`+`D` to signify EOF.

# Answer
> 3 votes
# Python 2, ~~27~~ ~~25~~ 24 bytes

```
lambda x:' '.join(x)+' '

```

Shorter than Raffi's answer...

*-1 thanks to 60919 (FlipTack).*

# Answer
> 3 votes
## APL, 5 bytes

```
∊2∘↑¨

```

This takes 2 items for each character in the string, with the effect of adding a space

To make it a program that takes stdin, it's the same number of bytes:

```
∊2↑¨⎕

```

Try it here.

# Answer
> 3 votes
# Threead, ~~45~~ 16 Bytes non-competing.

```
  B[coB]
32c   o

```

Takes input via STDIN.

The first Line/Tape simply reads bytes from STDIN, and writes them. The second line, initially stores a space via `32c`, then at the same time that the next character is being read, outputs that space.

Try it online!

# Answer
> 3 votes
# PHP, 31 bytes

```
<?=chunk_split($argv[1],1," ");

```

takes input from command line argument.

# Answer
> 2 votes
## Pyke, 5 bytes

```
dm+s_

```

Explanation:

```
d     -    load ' ' onto the stack
 m+   -   map(add, eval_input_or_not(), " ")
   s  -  "".join(^)
    _ - ^[::-1]

```

At the moment Pyke has a bug where if map is given a string, it reverses it :(

### Or with a new fixed version, 3 bytes

```
dL+

```

Try it here!

```
left_map(input(), " ", add)

```

# Answer
> 2 votes
## Ruby, ~~24~~ 15 bytes

```
gsub /./,'\0 '

```

Requires the `-p` flag (byte added).

Thanks to xsot for 9 bytes!

# Answer
> 2 votes
## C, 48 bytes

```
main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}

```

Try it online

* `main(c)` declares the `main` function that takes one argument `c`. If the data type is not specified, everything is an `int`. Therefore `c` is an `int` variable.
* The `main` routine consists of one `for` statement, `for(…);`. The body of the `for` loop is empty, everything happens inside the control header.
* `c=8192` initialize `c` to the value `32 * 256`. `32` is the ordinal value of a space character. `256` shifts the value 8 bits to the left (more significant places).
* `read(0,&c,1)` reads `1` Byte from `STDIN` (`0`) to the address of `c` (`&c`). This command returns a successful status as long as there is input to read.
* Provided the `read` is successful, `write(1,&c,2)` writes `2` Bytes that are stored at the address of `c` to `STDOUT` (`1`).

# Answer
> 2 votes
## Labyrinth, 11 bytes

```
32@
 :,
 ..

```

This is an 11-byte answer which terminates without an error – see @MartinBüttner's answer for a 10-byte answer which terminates with an error. Try it online!

Starting from the top-left, we have the following setup step:

```
32        Turn a zero at the bottom of the stack into 32 (space)

```

Then we turn right at the `2`, entering the following tight loop:

```
:          Duplicate top of stack (space)
,          Read char from STDIN
.          Output char
.          Output space

```

This loop repeats until `,` reads EOF, which pushes -1 to the top of the stack. The -1 makes us turn left into the `@`, terminating the program.

---

Here are two additional error-free 11-byte solutions, by Martin:

### Extra version A

```
  3
.:2
.,@

```

This version is the same as the above, but rotated 90 degrees. We still start on the `3`, since this is the first valid instruction in reading order.

### Extra version B

```
^,.
@:.
2
3

```

This version is effectively the same as the previous two, but uses an initial `^` to rotate the first column upon running the program, such that the board becomes:

```
@,.
2:.
3
^

```

After this, the code is the same as the original, except rotated 90 degrees in the other direction.

# Answer
> 2 votes
## Befunge-93, 12 bytes

```
~:1+!#@_, ",

```

Tested using this online interpreter.

```
~                           Read char
 :1+!                       Push (char == -1)
     #@_                    Halt if so, i.e. on EOF
        ,                   Output char
          "~:0`!#@_, "      Push the chars between the quotes, one by one
                      ,     Output the top char, i.e. space

```

# Answer
> 2 votes
# Sed, 8 bytes

```
's/$*/ /g'

```

Can be run from bash as

```
$ sed 's/$*/ /g' <<< "Full Width Text."

```

Outputs

```
 F u l l   w i d t h   t e x t .

```

# Answer
> 2 votes
# beeswax, 20 bytes

```
p?Cy ?<~1V_
>` `Ag'b

```

Example:

```
julia> beeswax("Full Width Text.bswx")
sHello, World!
H e l l o ,   W o r l d !
Program finished!

```

Explanation:

```
             lstack    gstack

          _  [0,0,0]•  []•                          create bee
         V   [0,0,0]•  [72,101,108,108,111,10]•     read in string to gstack
        1    [0,0,1]•                               lstack 1st=1
       ~     [0,1,0]•                               flip lstack 1st and 2nd
      <      [0,0,0]•                           (1) redirect to left
     ?       [0,1,0]•  [72,101,108,108,111]•        pop gstack top value (\n)
   y         [0,1,0]•  [101,108,108,111,72]•        rotate gstack down by lstack[-,steps,depth]•
                                                    depth=0 defaults to full stack length
  C                    STDOUT='H'                   print gstack top value as Char to STDOUT
 ?                     [101,108,108,111]•           pop gstack top value
p                                                   redirect to lower left
>                                                   redirect to right
 ` `                   STDOUT=' '                   print space char to STDOUT
    A                  [101,108,108,111,4]•         push gstack length on top of gstack
     g       [0,1,4]•                               lstack 1st=gstack top
      '                                             skip next if lstack 1st=0
       b                                            redirect to upper left
      <                                             loop back to (1)
     ?                 [101,108,108,111]•
   y         [0,1,4]•  [108,108,111,101]•
  C                    STDOUT='e'
 ?                     [108,108,111]•
p
>` `                   STDOUT=' '

.                          .                             .
.                          .                             .
.                          .                             .

```

# Answer
> 2 votes
# MATL, 7 bytes

```
32HY(1e

```

**Try it Online!**

**Explanation**

```
    % Implicitly grab input as a string
32  % Number literal (ASCII for ' ')
H   % Clipboard H contains 2 by default
Y(  % Fill the second "row" with spaces
1e  % Force everything onto one row. Due to MATLAB being row-major, this inserts the spaces
    % Implicitly display the result

```

# Answer
> 2 votes
## Hoon, 41 bytes

```
|*
*
`tape`(turn +< |=(@ (cat 3 +< ' ')))

```

Takes advantage of not having to specify the tape of a wet gate (`|*`), and that arguments are places at `+<` to prevent having to name them.

There are actually two different types of strings in Hoon: tapes, and cords. tapes are `(list @tD)`, while cords are simply `@t`. Think the difference between a vector and an array: tapes can be indexed into and manipulated easily, while cords are "static" and basically just bignums.

This entry maps over the characters in the tape it gets as input, and adds on the value of `' '` to the end of the atom and then casts the result back to a tape.

Technically, this should probably be a type error: tape is a list of characters, and we are stuffing two in the space of only one. Luckily, while Hoon has syntax to say what you should expect the size of an atom to be, it doesn't actually *enforce* that expectation. Even slamming a too-big atom with a specific sized verification gate doesn't give back the default value like it should. Naturally, we abuse this and it even prints correctly in the console, as long as you don't try to full-width text any UTF-8 characters.

Usage:

```
> %.  "Full width text is text that has a space after every character, including the last one."
  |*
  *
  `tape`(turn +< |=(@ (cat 3 +< ' ')))
"F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e . "

```

# Answer
> 2 votes
# C#, 137 bytes

```
Func<string,string>f=(a)=>{return string.Concat(a.ToCharArray().SelectMany(x=>(new char[] {' '}),(x, y)=>x.ToString()+y.ToString()));};

```

doing a console on it gives result : Console.WriteLine(f("arnab bhattacharya")); a r n a b b h a t t a c h a r y a

# Answer
> 2 votes
# Carrot, 13 bytes, non-competing

```
#^//./gS" "^

```

(note trailing space in code)

Try it online!

(to be able to see the trailing space in the output, open up the JS console and select the outputted text in the console output)

### Explanation

Note: the "stack" is actually just a string (not an array) in Carrot

```
#^                        // pushes the input `#` to the stack, now the stack == input
  /                       // split on:
   /./g                   //  every character in the stack

```

Now the program is in arrayMode, meaning that the stack is now an array (or stackA to be more precise)

```
       S" "               // join on spaces

```

Now we got spaces after every character except for the last one

```
           ^<space>       // append a space to the stack

```

And then the stack is implicitly outputted

# Answer
> 2 votes
# C++ (gcc), 120 133 77 bytes

```
#import<iostream>
int main(){char c;while(std::cin.get(c))std::cout<<c<<" ";}

```

Thanks to my father, who showed me a nifty trick for getting the characters directly from the input stream... and in turn almost halfed my byte count!

Old solution below using getline and joining substrings:

```
#import<iostream>
int i;int main(){std::string s,n;std::getline(std::cin,n);for(;i<n.size();i++){s+=n.substr(i,1)+" ";}std::cout<<s;}

```

Try it Online!

My very first try on golfing. Feel free to give suggestions.

# Answer
> 2 votes
# Julia, 31 bytes

```
print(join(readline(),' ')*" ")

```

Try it online!

# Answer
> 2 votes
# APL(NARS), 13 chars, 26 bytes

```
∊k,¨' '⍴⍨≢k←⍞

```

Input a line from standard input, and return a line, test:

```
∊k,¨' '⍴⍨≢k←⍞
hello there
h e l l o   t h e r e

```

# Answer
> 2 votes
# K (ngn/k), 10 bytes

```
{,/x,'" "}

```

Try it online!

(Ignored the stdin constraint. Let me know if I should delete, am new to SE)

---

**EDIT**: i made a mistake WRT stdin functionality in k. thanks, @ngn, for the correction:

# K (ngn/k), 18 bytes

```
{1@,/(0:""),'" ";}

```

Try it online!

---

# k4, 12 bytes

```
,/(0:0),'" "

```

which looks like:

```
 ,/(0:0),'" "
full-width text
"f u l l - w i d t h   t e x t "

```

# Answer
> 2 votes
## , 4 bytes

```
 "+M

```

## Explanation

```
   M % Foreach the input list:
  +  % Join the current item with ...
 "   % ... A space character

```

# Answer
> 2 votes
# naz, ~~50~~ ~~42~~ 40 bytes

```
2x1v1x1f0a0x1x2f1r3x1v1e1o0m8a4m1o2f0x2f

```

Works for any null-terminated input string.

*Saved 8 bytes by condensing the code into 2 functions instead of 3!*

Try it online!

**Explanation** (with `0x` instructions removed)

```
2x1v                     # Set variable 1 equal to 0
1x1f0a                   # Function 1
                         # Add 0 to the register
1x2f1r3x1v1e             # Function 2
                         # Read a byte of input
                         # Goto function 1 if it equals variable 1
            1o0m8a4m1o2f # Otherwise, output it, output a space,
                         # then call function 2
2f                       # Call function 2

```

The only way for a naz program to know when to stop reading its input is to give it a special case to check for; here we use a null byte, since a value of 0 can be stored immediately.

# Answer
> 2 votes
# Grok, 13 bytes

```
:lYW!j
q}W Ih

```

I just finished my first Esolang and decided to submit a Code-golf answer with it to show it off. It's inspired by Befunge, \>\<\>, and the Vim editor. More information on it is in the GitHub repository.

# Answer
> 2 votes
# CLC-INTERCAL, 108 bytes.

```
DO;1<-#1DO;1SUB#1<-#117DO;2<-#1DOCOMEFROM#9DOWRITEIN;2(1)DO:1<-;2SUB#1DDOCOMEFROM':1~:1'~#1(9)DOREADOUT;2+;1

```

Copy and paste to try it online!

## How it works

DONOTE ;1 has " "
DONOTE ;2 shall accept a character
DO;1<-#1
DO;1SUB#1<-#117
DO;2<-#1

DOCOMEFROM#9
  DOWRITEIN;2
  DONOTE if EOF, then :1 will be #0
  DONOTE otherwise it's at least #65536
  (1)DO:1<-;2SUB#1
  DONOTE error exit here
  D
  DONOTE come here if not EOF
  DOCOMEFROM':1~:1'~#1
(9)DOREADOUT;2+;1
```
</code></pre>

# Answer
> 1 votes
## Minkolang 0.15 \- 9 bytes

```
od?.O" "O

```

Try it here!

### Explanation

```
o            Take character from input
 d           Duplicate top of stack
  ?.         Pop top of stack and jump over the . if truthy, stop otherwise
    O        Output input char
     " "O    Output a space

```

Minkolang's codebox is toroidal, hence there is no need to put an explicit loop in it.

# Answer
> 1 votes
## Convex, 3 bytes

Convex is a new language that I am developing that is heavily based on CJam and Golfscript. The interpreter and IDE can be found here. Input is an integer into the command line arguments. Indexes are one-based. Uses the CP-1252 encoding.

```
S*S

```

Explanation:

```
     # Implied input
S*   # Join by spaces
  S  # Add a space at the end
     # Implied output

```

Additionally, @DonMuesli's CJam answer without the `l` (so `Sf+`) will also work for 3 bytes.

# Answer
> 1 votes
## sed, 8 bytes

```
s/./& /g

```

When running this from the shell you should quote it of course e.g.

```
echo Full Width Text | sed 's/./& /g' | od -c

```

# Answer
> 1 votes
## Python 3, 39 bytes

```
print("".join([x+" "for x in input()]))

```

# Answer
> 1 votes
## Ruby, 41 bytes

```
puts gets.chomp.chars.map{|e|e+" "}.join

```

`chomp` eats trailing newlines.

# Answer
> 1 votes
# SMBF, 9 bytes

Note the trailing space. Uses the space in the code rather than creating a 32 in a cell.

```
,[.<.>,]

```

The tryitonline.net interpreter appears to have a bug and loop indefinitely with this, so it only works in my Python interpreter. Changing the SMBF source code (currently on line 171) inside the Python code is required.

# Answer
> 1 votes
# Go, ~~154~~ 120 bytes

```
package main
import(
."fmt"
."os"
."strings")
func main(){s:=Join(Args[1:], " ")
for _,c:=range s{Print(string(c)," ")}}

```

Saved a few bytes with command line args.

# Answer
> 1 votes
# Vitsy, 10 bytes

```
zl\[O' 'O]

z          Grab all string input.
 l\[     ] Do the stuff in the brackets length of the stack times.
    O   O  Output as character.
     ' '   Push literal space.

```

Try it online!

# Answer
> 1 votes
# Scala, 35 bytes

```
Console.readLine.map(_+" ")mkString

```

Example:

```
scala> Console.readLine.map(_+" ")mkString
res1: String = "H e l l o   S c a l a ! "

```

PS. A function would be slightly shorter (32 bytes):

```
(s:String)=>s.map(_+" ")mkString

```

# Answer
> 1 votes
# LiveScript, 17.

```
->"#{it/''*' '} "

```

# Answer
> 1 votes
# APL, 11 bytes

```
{,/' ',¨⍵}

```

catenate ' ' with each in omega (argument), then join (reduce-catenate, `,/`)

# Answer
> 1 votes
# Mathematica, 42 bytes

```
Print@@(#<>" "&)/@Characters@InputString[]

```

Pretty self-explanatory. `InputString` takes a line from STDIN, `Characters` converts it to a list of characters, `(#<>" "&)/@` produces a new string with spaces after those characters, and `Print` prints the result.

# Answer
> 1 votes
# Perl 5, ~~11~~ 10 + 1 flags = 11 bytes

really, the same as the Perl 6 one, but the sed syntax changed.

```
s/./$& /g

```

example:

```
perl -pe "s/./$& /g" <<< abc

```

~~old:~~

~~```
perl -pne "s/(.)/\1 /g" <<< abc

```~~

# Answer
> 1 votes
## Batch, 87 bytes

```
@set/pt=&set w=
:l
@if not "%t%"=="" set w=%w%%t:~,1% &set t=%t:~1%&goto l
@echo(%w%

```

Conveniently taking input from STDIN is the same length as taking it from program arguments (`set t=%*`). The space between the `%` and `&` on the third line is significant, of course. The `(` after the `echo` simply prevents it from erroring out if the input is empty.

# Answer
> 1 votes
# Python 3, 31 28

```
print(' '.join(input())+' ')

```

I know i'm late on this one, and definitely not a winner, but thought i'd try it out.

**Edit:** Switched to python 3. Thanks to *CatsAreFluffy* for saving 3 bytes!

# Answer
> 1 votes
# Grond, 22 21 chars

```
a(p().sp('').jn(' '))

```

Edit: removed semicolon
compiler in js below

```
String.prototype.reverse = function() {
  return this.split("").reverse().join("");
}
function compile(source){
var wc = source; // wc stands for working copy
var lastWC;
while (true) {
  lastWC = wc;
  wc = wc.reverse();
  wc = wc.replace(/\(a(?!\w)/, "(trela"); //alert ,a
  wc = wc.replace(/\(f(?!\w)/, "(rof"); // for, f
  wc = wc.replace(/\(w(?!\w)/, "(elihw"); //while,w
  wc = wc.replace(/\(p(?!\w)/, "(tpmorp"); //prompt,p
  wc = wc.replace(/\(vr\./, "(esrever."); //reverse, rv
  wc = wc.replace(/\(tm\./, "(chtam."); // match, mt
  wc = wc.replace(/\(nj\./, "(nioj."); //join, .jn
  wc = wc.replace(/\(pr\./, "(ecalper."); //replace, .rp
  wc = wc.replace(/\(ls\./, "(.ecils"); //slice, sl
  wc = wc.replace(/\(lt\./, "(esaCrewoLot."); //toLowerCase, tl
  wc = wc.replace(/\(ut\./, "(esaCreppUot."); //toUpperCase, tu
    wc = wc.replace(/\(ps\./, "(tilps."); //split, sp
  wc = wc.reverse();
  wc = wc.replace(/\.l(?!\w)/, ".length"); // .length, .l
  if (lastWC === wc)
    break;
}

// quine builtin commented out because it messes things up TODO: Fix it.
wc = " String.prototype.la=function(h){var x=this.split(''); x[h] = x[h].toLowerCase(); return x.join('');};String.prototype.ca=function(h){var x=this.split(''); x[h] = x[h].toUpperCase(); return x.join('');};String.prototype.reverse=function(){return this.split('').reverse().join('');}; \n var h = ['hello, world', 'Hello, World', 'Hello, World!', 'hello, world!', 'hello world', 'hello world!', 'Hello World', 'Hello World!', 'Hello, world.', 'Hello, World.' ,'hello world.' , 'Hello World.']; /* var q ='" + source + "';*/ " + wc;

return wc;
  }
eval(compile("a(p().sp('').jn(' '));"));//source
```
Grond on github: https://github.com/epicTCK/Grond

# Answer
> 1 votes
## Nim, 41 bytes

```
for c in stdin.readAll:stdout.write c&' '

```

I sure hope there's a better way, but `readChar` didn't seem to help...

Ideone link

# Answer
> 1 votes
# Reng v.1.2, 15 bytes

Try it out here! The input is given as `"input"`.

```
ai p|$raoWo?!|~

```

`a` is a one-way mirror from the left. `ai p|` gets all input, `$` drops the residual `-1` not found input, `r` reverses the stack, and `aoWo?!|~` is an output loop. `W` pushes 32, the space, and outputs it after outputting the character. `?!` breaks out if not true, and `~` ends the program.

# Answer
> 1 votes
# RETURN, 10 bytes

```
`""¨{' °},

```

`Try it here.`

Takes input from STDIN. It's just take STDIN, split along chars, join with space, output.

# Answer
> 1 votes
# Jolf, 7 bytes

Try it here!

```
p4i*li♣
p4       interweave
  i      the input
   *li♣  with a string of spaces with = length to the input

```

# Answer
> 1 votes
# , 5 chars / 7 bytes

```
ᴉü⬭+⬭

```

`Try it here (Firefox only).`

Short and sweet. Get input split along chars and join with space.

# Answer
> 1 votes
# Clojure, 34 bytes

```
#(apply str(mapcat(fn[x][x" "])%))

```

Clojure is amazingly fun to work with but annoying to golf. Usually there's a really nice idiomatic solution to these challenges that isn't that many identifiers, but it's massive thanks to things like the identity function being `identity` (not fully golfed in these forms):

```
(defn fw [s] (apply str (interleave s (repeat " "))))

```

or

```
(defn fw [s] (apply str (mapcat (juxt identity (constantly " ")) s)))

```

# Answer
> 1 votes
## Lua, 31 Bytes

**Saved 1 byte thanks to @LeakyNun**

A simple chained substitution, replace each character by itself and a space.

```
s=(...):gsub(".","%1 ")print(s)

```

An other solution with the same byte count:

```
print((...):gsub(".","%1 "),'')

```

# Answer
> 1 votes
# O 1.2, 6 bytes

```
I' ]^o

```

Sample run:

```
bash-4.3$ java xyz.jadonfowler.o.O <(echo "I' ]^o") <<< 'Full width text.'
F u l l   w i d t h   t e x t .

```

This could be 5 characters in O 2 as `IT]^o`, but sadly it not seems to fully support the `^` command yet.

# Answer
> 1 votes
# J, 8 bytes

```
,@,.&' '

```

`,.` is the stitch command, and `' ' , 'string'` creates a table with a space following each character. `,` takes these items out of the table when used as a monad, and `@` composes this function with our other function. Use:

```
   fullWidth =: ,@,.&' '
   fullWidth 'this text is full width!'
   fullWidth 'this text is full width!'
t h i s   t e x t   i s   f u l l   w i d t h !

```

Great thanks to Zgarb who helped me make this answer.

# Answer
> 1 votes
# PowerShell, 32 bytes

```
-join([char[]]$args[0]|%{"$_ "})

```

---

**Explanation**

Take in the input to the function and convert it to a char array. Add one space to each character and rejoin. Nothing really fancy here.

# Answer
> 1 votes
## Prelude, 11 bytes

```
?(!8^+^+!?)

```

This needs a spec-compliant interpreter which reads and writes character codes (instead of integers).

The program is fairly simple.

```
?(...?)

```

This sets up a `while(read() != EOF)` loop. Then we simply have:

```
!   Print input character.
8   Push 8.
^+  Duplicate, add. Gives 16.
^+  Duplicate, add. Gives 32.
!   Print space.

```

# Answer
> 1 votes
# Common Lisp, 40 bytes

```
(map()(lambda(x)(format t"~C "x))(read))

```

I was very surprised that `format` couldn't do this by itself: it can only iterate over lists, not strings.

# Answer
> 1 votes
# Pip, 5 bytes

```
_.sMq

```

The special variable `q` reads a line of stdin. We `M`ap to it the lambda function `_.s`, which concatenates a space to each character. By default, the resulting list is concatenated and autoprinted.

# Answer
> 1 votes
# Ouroboros, 11 bytes

```
i.0<5*(o32o

```

Ouroboros is an esolang in which every line of code represents a snake eating its tail. It draws a fair amount of inspiration from 2D languages like Befunge and \>\<\>.

The `i` command reads a character, or `-1` for EOF. We duplicate this, check if it's less than `0`, and multiply the resulting `1` (true) or `0` (false) by `5`.

* If we have reached EOF, the top of the stack is now `5`. The `(` command tells the snake to eat that many characters of its tail. This results in swallowing the execution pointer (currently on `(`, the fifth-last character), which terminates the program.
* Otherwise, `0` characters are eaten, and execution continues. We have a copy of the input ASCII code on the stack, which we output via `o`; then output a space (ASCII 32) and loop back to the beginning.

### Try it out

```
// Define Stack class
function Stack() {
  this.stack = [];
  this.length = 0;
}
Stack.prototype.push = function(item) {
  this.stack.push(item);
  this.length++;
}
Stack.prototype.pop = function() {
  var result = 0;
  if (this.length > 0) {
    result = this.stack.pop();
    this.length--;
  }
  return result;
}
Stack.prototype.top = function() {
  var result = 0;
  if (this.length > 0) {
    result = this.stack[this.length - 1];
  }
  return result;
}
Stack.prototype.toString = function() {
  return "" + this.stack;
}

// Define Snake class
function Snake(code) {
  this.code = code;
  this.length = this.code.length;
  this.ip = 0;
  this.ownStack = new Stack();
  this.currStack = this.ownStack;
  this.alive = true;
  this.wait = 0;
  this.partialString = this.partialNumber = null;
}
Snake.prototype.step = function() {
  if (!this.alive) {
    return null;
  }
  if (this.wait > 0) {
    this.wait--;
    return null;
  }
  var instruction = this.code.charAt(this.ip);
  var output = null;
  console.log("Executing instruction " + instruction);
  if (this.partialString !== null) {
    // We're in the middle of a double-quoted string
    if (instruction == '"') {
      // Close the string and push its character codes in reverse order
      for (var i = this.partialString.length - 1; i >= 0; i--) {
        this.currStack.push(this.partialString.charCodeAt(i));
      }
      this.partialString = null;
    } else {
      this.partialString += instruction;
    }
  } else if (instruction == '"') {
    this.partialString = "";
  } else if ("0" <= instruction && instruction <= "9") {
    if (this.partialNumber !== null) {
      this.partialNumber = this.partialNumber + instruction;  // NB: concatenation!
    } else {
      this.partialNumber = instruction;
    }
    next = this.code.charAt((this.ip + 1) % this.length);
    if (next < "0" || "9" < next) {
      // Next instruction is non-numeric, so end number and push it
      this.currStack.push(+this.partialNumber);
      this.partialNumber = null;
    }
  } else if ("a" <= instruction && instruction <= "f") {
    // a-f push numbers 10 through 15
    var value = instruction.charCodeAt(0) - 87;
    this.currStack.push(value);
  } else if (instruction == "$") {
    // Toggle the current stack
    if (this.currStack === this.ownStack) {
      this.currStack = this.program.sharedStack;
    } else {
      this.currStack = this.ownStack;
    }
  } else if (instruction == "s") {
    this.currStack = this.ownStack;
  } else if (instruction == "S") {
    this.currStack = this.program.sharedStack;
  } else if (instruction == "l") {
    this.currStack.push(this.ownStack.length);
  } else if (instruction == "L") {
    this.currStack.push(this.program.sharedStack.length);
  } else if (instruction == ".") {
    var item = this.currStack.pop();
    this.currStack.push(item);
    this.currStack.push(item);
  } else if (instruction == "m") {
    var item = this.ownStack.pop();
    this.program.sharedStack.push(item);
  } else if (instruction == "M") {
    var item = this.program.sharedStack.pop();
    this.ownStack.push(item);
  } else if (instruction == "y") {
    var item = this.ownStack.top();
    this.program.sharedStack.push(item);
  } else if (instruction == "Y") {
    var item = this.program.sharedStack.top();
    this.ownStack.push(item);
  } else if (instruction == "\\") {
    var top = this.currStack.pop();
    var next = this.currStack.pop()
    this.currStack.push(top);
    this.currStack.push(next);
  } else if (instruction == "@") {
    var c = this.currStack.pop();
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(c);
    this.currStack.push(a);
    this.currStack.push(b);
  } else if (instruction == ";") {
    this.currStack.pop();
  } else if (instruction == "+") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a + b);
  } else if (instruction == "-") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a - b);
  } else if (instruction == "*") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a * b);
  } else if (instruction == "/") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a / b);
  } else if (instruction == "%") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(a % b);
  } else if (instruction == "_") {
    this.currStack.push(-this.currStack.pop());
  } else if (instruction == "I") {
    var value = this.currStack.pop();
    if (value < 0) {
      this.currStack.push(Math.ceil(value));
    } else {
      this.currStack.push(Math.floor(value));
    }
  } else if (instruction == ">") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a > b));
  } else if (instruction == "<") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a < b));
  } else if (instruction == "=") {
    var b = this.currStack.pop();
    var a = this.currStack.pop();
    this.currStack.push(+(a == b));
  } else if (instruction == "!") {
    this.currStack.push(+ !this.currStack.pop());
  } else if (instruction == "?") {
    this.currStack.push(Math.random());
  } else if (instruction == "n") {
    output = "" + this.currStack.pop();
  } else if (instruction == "o") {
    output = String.fromCharCode(this.currStack.pop());
  } else if (instruction == "r") {
    var input = this.program.io.getNumber();
    this.currStack.push(input);
  } else if (instruction == "i") {
    var input = this.program.io.getChar();
    this.currStack.push(input);
  } else if (instruction == "(") {
    this.length -= Math.floor(this.currStack.pop());
    this.length = Math.max(this.length, 0);
  } else if (instruction == ")") {
    this.length += Math.floor(this.currStack.pop());
    this.length = Math.min(this.length, this.code.length);
  } else if (instruction == "w") {
    this.wait = this.currStack.pop();
  }
  // Any unrecognized character is a no-op
  if (this.ip >= this.length) {
    // We've swallowed the IP, so this snake dies
    this.alive = false;
    this.program.snakesLiving--;
  } else {
    // Increment IP and loop if appropriate
    this.ip = (this.ip + 1) % this.length;
  }
  return output;
}
Snake.prototype.getHighlightedCode = function() {
  var result = "";
  for (var i = 0; i < this.code.length; i++) {
    if (i == this.length) {
      result += '';
    }
    if (i == this.ip) {
      if (this.wait > 0) {
        result += '';
      } else {
        result += '';
      }
      result += escapeEntities(this.code.charAt(i)) + '';
    } else {
      result += escapeEntities(this.code.charAt(i));
    }
  }
  if (this.length < this.code.length) {
    result += '';
  }
  return result;
}

// Define Program class
function Program(source, speed, io) {
  this.sharedStack = new Stack();
  this.snakes = source.split(/\r?\n/).map(function(snakeCode) {
    var snake = new Snake(snakeCode);
    snake.program = this;
    snake.sharedStack = this.sharedStack;
    return snake;
  }.bind(this));
  this.snakesLiving = this.snakes.length;
  this.io = io;
  this.speed = speed || 10;
  this.halting = false;
}
Program.prototype.run = function() {
  this.step();
  if (this.snakesLiving) {
    this.timeout = window.setTimeout(this.run.bind(this), 1000 / this.speed);
  }
}
Program.prototype.step = function() {
   for (var s = 0; s < this.snakes.length; s++) {
    var output = this.snakes[s].step();
    if (output) {
      this.io.print(output);
    }
  }
  this.io.displaySource(this.snakes.map(function (snake) {
      return snake.getHighlightedCode();
    }).join("
"));
 }
Program.prototype.halt = function() {
  window.clearTimeout(this.timeout);
}

var ioFunctions = {
  print: function (item) {
    var stdout = document.getElementById('stdout');
    stdout.value += "" + item;
  },
  getChar: function () {
    if (inputData) {
      var inputChar = inputData[0];
      inputData = inputData.slice(1);
      result = inputChar.charCodeAt(0);
    } else {
      result = -1;
    }
    var stdinDisplay = document.getElementById('stdin-display');
    stdinDisplay.innerHTML = escapeEntities(inputData);
    return result;
  },
  getNumber: function () {
    while (inputData && (inputData[0] < "0" || "9" < inputData[0])) {
      inputData = inputData.slice(1);
    }
    if (inputData) {
      var inputNumber = inputData.match(/\d+/)[0];
      inputData = inputData.slice(inputNumber.length);
      result = +inputNumber;
    } else {
      result = -1;
    }
    var stdinDisplay = document.getElementById('stdin-display');
    stdinDisplay.innerHTML = escapeEntities(inputData);
    return result;
  },
  displaySource: function (formattedCode) {
    var sourceDisplay = document.getElementById('source-display');
    sourceDisplay.innerHTML = formattedCode;
  }
};
var program = null;
var inputData = null;
function showEditor() {
  var source = document.getElementById('source'),
    sourceDisplayWrapper = document.getElementById('source-display-wrapper'),
    stdin = document.getElementById('stdin'),
    stdinDisplayWrapper = document.getElementById('stdin-display-wrapper');

  source.style.display = "block";
  stdin.style.display = "block";
  sourceDisplayWrapper.style.display = "none";
  stdinDisplayWrapper.style.display = "none";

  source.focus();
}
function hideEditor() {
  var source = document.getElementById('source'),
    sourceDisplay = document.getElementById('source-display'),
    sourceDisplayWrapper = document.getElementById('source-display-wrapper'),
    stdin = document.getElementById('stdin'),
    stdinDisplay = document.getElementById('stdin-display'),
    stdinDisplayWrapper = document.getElementById('stdin-display-wrapper');

  source.style.display = "none";
  stdin.style.display = "none";
  sourceDisplayWrapper.style.display = "block";
  stdinDisplayWrapper.style.display = "block";

  var sourceHeight = getComputedStyle(source).height,
    stdinHeight = getComputedStyle(stdin).height;
  sourceDisplayWrapper.style.minHeight = sourceHeight;
  sourceDisplayWrapper.style.maxHeight = sourceHeight;
  stdinDisplayWrapper.style.minHeight = stdinHeight;
  stdinDisplayWrapper.style.maxHeight = stdinHeight;
  sourceDisplay.textContent = source.value;
  stdinDisplay.textContent = stdin.value;
}
function escapeEntities(input) {
  return input.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
function resetProgram() {
  var stdout = document.getElementById('stdout');
  stdout.value = null;
  if (program !== null) {
    program.halt();
  }
  program = null;
  inputData = null;
  showEditor();
}
function initProgram() {
  var source = document.getElementById('source'),
    stepsPerSecond = document.getElementById('steps-per-second'),
    stdin = document.getElementById('stdin');
  program = new Program(source.value, +stepsPerSecond.innerHTML, ioFunctions);
  hideEditor();
  inputData = stdin.value;
}
function runBtnClick() {
  if (program === null || program.snakesLiving == 0) {
    resetProgram();
    initProgram();
  } else {
    program.halt();
    var stepsPerSecond = document.getElementById('steps-per-second');
    program.speed = +stepsPerSecond.innerHTML;
  }
  program.run();
}
function stepBtnClick() {
  if (program === null) {
    initProgram();
  } else {
    program.halt();
  }
  program.step();
}
function sourceDisplayClick() {
  resetProgram();
}
```

```
.container {
    width: 100%;
}
.so-box {
    font-family:'Helvetica Neue', Arial, sans-serif;
    font-weight: bold;
    color: #fff;
    text-align: center;
    padding: .3em .7em;
    font-size: 1em;
    line-height: 1.1;
    border: 1px solid #c47b07;
    -webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    background: #f88912;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3), 0 2px 0 rgba(255, 255, 255, 0.15) inset;
}
.control {
    display: inline-block;
    border-radius: 6px;
    float: left;
    margin-right: 25px;
    cursor: pointer;
}
.option {
    padding: 10px 20px;
    margin-right: 25px;
    float: left;
}
h1 {
    text-align: center;
    font-family: Georgia, 'Times New Roman', serif;
}
a {
    text-decoration: none;
}
input, textarea {
    box-sizing: border-box;
}
textarea {
    display: block;
    white-space: pre;
    overflow: auto;
    height: 50px;
    width: 100%;
    max-width: 100%;
    min-height: 25px;
}
span[contenteditable] {
    padding: 2px 6px;
    background: #cc7801;
    color: #fff;
}
#stdout-container, #stdin-container {
    height: auto;
    padding: 6px 0;
}
#reset {
    float: right;
}
#source-display-wrapper , #stdin-display-wrapper{
    display: none;
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid black;
    box-sizing: border-box;
}
#source-display , #stdin-display{
    font-family: monospace;
    white-space: pre;
    padding: 2px;
}
.activeToken {
    background: #f93;
}
.nextActiveToken {
    background: #bbb;
}
.swallowedCode{
    color: #999;
}
.clearfix:after {
    content:".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}
.clearfix {
    display: inline-block;
}
* html .clearfix {
    height: 1%;
}
.clearfix {
    display: block;
}
```

```

<textarea id="source" placeholder="Enter your program here" wrap="off">i.0<5*(o32o</textarea>

<textarea id="stdin" placeholder="Input" wrap="off">Input text...</textarea>

<input type="button" id="run" class="control so-box" value="Run" onclick="runBtnClick()" /><input type="button" id="pause" class="control so-box" value="Pause" onclick="program.halt()" /><input type="button" id="step" class="control so-box" value="Step" onclick="stepBtnClick()" /><input type="button" id="reset" class="control so-box" value="Reset" onclick="resetProgram()" />

<textarea id="stdout" placeholder="Output" wrap="off" readonly></textarea>

Steps per Second:
20

```

# Answer
> 1 votes
# Pyth, 5 bytes

```
+jdzd

```

Test here

Explanation:

```
 jdz    Join input with spaces
+   d   Concatenate space

```

# Answer
> 1 votes
# Silicon, 6 bytes

```
iSæ%æ+

```

**Explanation:**

```
iSæ%æ+
i        Input
 S       Split the input
  æ      Push a space
   %     Join at spaces
    æ+   Append a space to the end of the string
         Implicit output

```

## ~~7 bytes~~

```
iSæ²jæ+

```

# Answer
> 1 votes
# 0815, 26 bytes

```
<:20:~>}: :!~$#:
:{~$>^: :

```

# Answer
> 1 votes
## Tcl, 44 bytes

```
puts [regsub -all {(.)} [gets stdin] {\1 }]

```

# Answer
> 1 votes
# C#, 35 bytes

```
s=>string.Join(" ",s.ToList())+" ";

```

C# lambda where the input and the output are `string`. You can try it on .NetFiddle.

# Answer
> 1 votes
# Swift 2.2, ~~48~~ 46 bytes

```
for c in i.characters{print(c,terminator:" ")}

```

Hey, at least it's shorter than Java... Saved 2 chars by using a `for in` loop instead of a `forEach` closure.

# Answer
> 1 votes
# tcl, 41

```
puts [regsub -all (.) [gets stdin] \\1\ ]

```

on http://rextester.com/KCIB63188

# Answer
> 1 votes
# C ~~55~~, 49 bytes

```
g(){c;while((c=getchar())!='\n')printf("%c ",c);}

```

Ungolfed version:

```
void g()
{
  char c;
  while((c=getchar())!='\n')
  printf("%c ", c);
}

```

# Answer
> 1 votes
# TI-84 BASIC, 44 bytes

Pretty straightforward approach:

```
Input Str1
sub(Str1,1,1
For(A,2,length(Str1
Ans+" "+sub(Str1,A,1
End
Ans+"

```

The only size optimizations I could come up with were:

* leaving off closing quotes and parentheses at the end of lines
* using `Ans` instead of a string variable (the `Ans` token is 1 byte, `StrN` are 2, and assignment to `Ans` is implicit)
* printing the result by placing it on the last line of the program (no `Disp` command needed)

This program wouldn't work correctly for an empty input string, since it unconditionally stores the first character of `Str1` in `Ans`. (This is necessary because concatenation with an empty string raises an error!) Fortunately, the `Input` command doesn't accept an empty string in the first place.

The size calculation was informed by TI-Basic Developer's token size charts.

# Answer
> 1 votes
# OIL, ~~52~~ 49 bytes noncompeting

*Note: The second line contains a space character.*

```
5

12
0
23
10
24
3
7
10
4
24
4
1
8
11
1
11
6
6
5

```

---

I explode the input string, then print each character and then a space.

# Answer
> 1 votes
# Pushy, 7 bytes

```
32DL:{'

```

**Try it online!**

Works like so:

```
       \ Implicit: Input is on stack as charcodes
32D    \ Set the printing delimiter to a space
L:     \ Input length times do:
  {    \   Cyclically shift the stack left
   '   \   Print the last character (includes trailing space)

```

---

Alternatively, for the same byte count, one could have:

```
L:{32;"

```

**Try it online!**

```
L:   ;   \ Length times do:
  {      \   Shift string left
   32    \   Insert char 32 (a space)
      "  \ Afterwards, print the whole string

```

# Answer
> 1 votes
# Japt, 4 bytes

```
®+S

```

Try it online!

# Answer
> 1 votes
# Lua, 57 bytes

```
t=""io.read():gsub(".",function(c)t=t..c.." "end)print(t)

```

# Answer
> 1 votes
# SmileBASIC 3, 44 bytes

```
INPUT A$FOR I=0TO LEN(A$)-1?A$[I]+" ";
NEXT

```

This doesn't leave a new line after the output, so from direct you might get

```
?HELLO
H E L L O OK

```

but hopefully it's not an issue.

# Answer
> 1 votes
# C#, 52 bytes

Manual, straightforward approach, without using Linq.

```
s=>{var r="";foreach(var c in s)r+=c+" ";return r;};

```

Anonymous method which gets every character from the string and adds a space after each one.

Full program:

```
using System;

namespace FullWidthText
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string, string> f =
            s =>
            {
                var r = "";
                foreach (var c in s)
                    r += c + " ";
                return r;
            };

            Console.WriteLine(f("Full width text is text that has a space after every character, including the last one."));
        }
    }
}

```

# Answer
> 1 votes
## Vim, ~~12~~ 10 keystrokes

```
:s/./& /g<CR>

```

1 byte longer:

```
qqa <Esc>l@qq@q

```

-2 bytes thanks to @KritixiLithos

# Answer
> 1 votes
# q/kdb+, 12 bytes

**Solution:**

```
raze{x,'" "}

```

**Example:**

```
q)raze{x,'" "}"Hello World!"
"H e l l o   W o r l d ! "

```

**Explanation:**

```
,'   / join (,) each left ("H", "e", "l"...) with each right (" ")
raze / reduce list

```

**Notes:**

Would be 9 bytes doing it more directly rather than as a lambda function:

```
q)raze"Hello World!",'" "
"H e l l o   W o r l d ! "

```

# Answer
> 1 votes
# Javascript, 19 bytes

```
s=>[...s,,].join` `

```

# Answer
> 1 votes
# Brain-Flak, 46 bytes

```
{({}<>)<>}<>{({}<>)((((()()()()){}){}){})<>}<>

```

Try it online!

Explanation:

```
#Reverse the whole stack
{({}<>)<>}<>

#Reverse the whole stack,
{({}<>)

    #Pushing 32 between each character
    ((((()()()()){}){}){})<>}<>

```

# Answer
> 1 votes
# APL (Dyalog), 4 bytes

Requires `⎕ML←0` which used to be standard

```
,⍪,∊

```

Try it online!

`,` ravel (flatten)

the columnified argument

`,` followed by

the prototypes (one space per character)

# Answer
> 1 votes
# Python 3,  ~~95 93 92 80 32 26~~  30 bytes

Saved a byte thanks to @caird coinheringaahing

Saved bunch of bytes from @DJMcMayhem + My idea

```
print(' '.join(input())+' ')

```

Takes input, splits it, then prints a join with spaces

This is my first time golfing.

# Answer
> 1 votes
# Brainfuck, 23 ~~24~~ ~~25~~ Bytes

### 1 Byte thanks to ovs

```
-[-[-<]>>+<]>-<+[,.>.<]

```

Try it online!
This code makes use of most interpreters wrapping to 255 if the number is negative.

# Previous solution:

```
++++[>++++++++<-]+[,.>.<]

```

Try it online!

## Explanation:

```
++++[>++++++++<-]   |Leaves the second cell with the number 32, the ASCII Code for a space.
+[,.>.<]            |Simple loop, gets the input, outputs it and adds a space.

```

Suggestions are welcome.

# Answer
> 1 votes
## Canvas, ~~4~~ 3 bytes

```
 ］∑

```

Try it here!

Explanation:
```
   Push input to stack (implicit)
   For each character in the input: (implicit)
   Push the character to the stack (implicit)
   Push " " to the stack
］ Collapse results from loop into an array
∑  Join the array into a single string
   Print the ToS (implicit)

```

*-1 byte thanks to dzaima!*

# Answer
> 1 votes
# k, 10 bytes

```
{,/x,'" "}

```

### Explanation

`{..}` is the lambda syntax

`x,'""` takes the first argument x, and applies the join operator `,` to every character, creating an array of "l " pairs

`,/` folds the array with the join operator

# Answer
> 1 votes
# Gol\>\<\>, 7 bytes

```
iEH}` }

```

Courtesy of JoKing, who golfed this to the max!!! JoKing combined the loops into one simple loop, also avoided the mistake I made, I added 2 spaces rather than one.

Try it online!

**Slightly newer of My original golfed, 23 bytes**

```
Ti:0)?t~l&T` }}&M:&?trH

```

Try it online!

**Old version, 28 bytes**

```
Ti:0)?t~l&T"  "}}}&M:&0)?trH

```

This can probably be golfed futher, but code breakdown below!

```
Ti:0)?t~l&T"  "}}}&M:&0)?trH

Ti:0)?t~                    //gets every char from input, and pushes them to the stack
          T"  "}}}          //push 2 spaces after every char, push to the bottom of the stack for later
        l&T       &M:&0)?t  //push original length and store, every loop decrement and if it is greater than zero, repeat
                          rH//reverse stack and output the whole stack as characters

```

Try it online!

# Answer
> 1 votes
# Perl 6, 14 bytes

```
put get.comb,$

```

Try it online!

Prints a trailing newline.

### Explanation:

```
put             # print to stdout
    get.comb    # the list of characters in the input,
            ,$  # And an empty string
put             # Implicitly separated by spaces

```

# Answer
> 1 votes
# PowerShell, 24 bytes

```
"$args"-replace'.','$0 '

```

Try it online!

# Answer
> 1 votes
# Zsh, 21 bytes

```
echo ${(s::)$(<&0)}\

```

Try it online!

`$(capture)`, `${(s::)plit}`, `echo`. The last `"\ "` is needed for the trailing space.

# Answer
> 1 votes
# Befunge-98 (PyFunge), 6 bytes

```
"#@~,,

```

Try it online!

The Befunge-98 answer is pretty long, so here is a shorter one. Basically the same answer as this Befunge-93 answer by Sp3000, but ends up being half as long, thanks to Befunge-98s ~ reflecting on EOF.

One thing that bugged me is, that when you run it on multi line input, every line but the first will be indented (since the linebreak will be followed by a space as well), so here is a version (11 bytes), that doesn't have that problem.

```
"#@~:,a-!j,

```

Try it online!

# Answer
> 1 votes
# Keg, `-rs`, 3 bytes

```
( '

```

Shifts the input putting a space after each character, reverses the stack via the `-rs` flag and then implicitly outputs the stack.

# Answer
> 1 votes
# PowerShell, ~~17~~ 8 bytes

-9 bytes thanks to @mazzy!

```
"$args "

```

Try it online!

There are already a couple of PowerShell answers to this question, but I thought I'd throw mine into the mix. It takes splatter input from a command line argument. It also assumes that `$ofs` is equal to one space, which it is by default.

# Answer
> 1 votes
# Vyxal , ~~<sup>3</sup>~~ 2 bytes

```
Ṅð

```

Try it Online!

Explanation:

```
     # Implicit input
Ṅ    # Insert ' ' between each character
  ð  # Push ' '
     # 'Ṫ' flag - sum entire stack and print

```

---

## If the final space wasn't necessary:

## Vyxal `S`, 0 bytes

Try it Online!

Explanation:

```
  # Implicit input
  # 'S' flag - Print top of stack joined by spaces

```

# Answer
> 1 votes
# Commodore C64 BASIC, 39 Tokenised BASIC bytes, 42 PETSCII characters with keyword abbreviations

```
0INPUTA$:FORI=1TOLEN(A$):?MID$(A$,I,1)" ";:NEXT

```

On running this listing, the interpreter will expect an input of strings which when the return key is pressed, will store the text entered into the variable `A$`. It will then iterate over each position of the string to its length and `PRINT` it, proceeded by a white space, and then will continue at the next cursor position until the final character of the string is printed (this will be followed by a space too).

Some notes: A Commodore C64 screen is 40 characters wide by default, and the maximum number of characters that may be stored in a string is 255, however, when using `INPUT` the interpreter will only accept a total entry of 77 characters without some trickery (80 characters if you delete the ? prompt, enter 80 characters and then cursor up two lines and press the RETURN key).

See screenshot for this in action.

# Answer
> 1 votes
## Pascal, 90 bytes

This is a full `program` suitable for a processor supporting “Standard Pascal” and/or “Extended Pascal” as defined by ISO standards 7185 and 10206 respectively. As per specification it takes *a line* (not many lines). Note, calling `EOLn(input)` causes an error if `EOF(input)` is `true` prior invocation of `EOLn`. Hence it must be guaranteed that input contains at least an end‑of‑line marker.

```
program p(input,output);begin while not EOLn do begin write(input↑,' ');get(input)end end.

```

We can add **−10 bytes** if it is guaranteed that `input` is a non‑empty line:

```
program p(input,output);begin repeat write(input↑,' ');get(input)until EOLn end.

```

# Answer
> 1 votes
# K (ngn/k), 5 bytes

```
,/2$'

```

Try it online!

Runs as a function within the repl.

* `2$'` right-pad each individual character of the input to length 2, i.e. append a space
* `,/` flatten the resulting list of strings into a single string and (implicitly) return

If input *must* be read from STDIN, the following suffices for 9 bytes:

```
,/2$'*0:`

```

It is the same as above, but takes a line of input from STDIN via `*0:``.

# Answer
> 0 votes
# Elixir, ~~55~~ 43

```
Regex.replace(~r/(.)\n?/,IO.gets(""),"\\0 ")

```

Sadly, stripping the newline is pretty costly in terms of characters (not sure if I can remove it).

# Answer
> 0 votes
# Japt, 5 bytes

```
U¬¸+S

```

Try it here.

# Answer
> 0 votes
# Javascript, 35 chars

Full program

```
alert(prompt().replace(/./g,"$& "))

```

# Javascript ES6, 24 chars

Just a function

```
s=>s.replace(/./g,"$& ")

```

# Answer
> 0 votes
# Befunge-93, 18 bytes

```
>~:1`#v_@
^," ",<

```

# Answer
> 0 votes
## Python 2.7, 62 Bytes

Yes, I know this is not as competitive with most of the other answers, but I wanted to use zip in some sort of way.

```
i=input();j=''.join;print(j([j(z)for z in zip(i,' '*len(i))]))

```

# Answer
> 0 votes
## Befunge-98, 21 bytes

```
>  ~:av
^,*84,w
@,*84,<

```

Lengthier than one already present but has the ending space requested by OP.

# Answer
> 0 votes
# Matlab/Octave, 51 bytes

```
s=s(.5:.5:length(s))
s(1:2:length(s))=' '

```

# Answer
> 0 votes
# Octave, 18 bytes

```
@(s)[s;32+0*s](:)'

```

Creates an anonymous function. Can then be run using `ans('input string')`

Same rationale as my MATL answer. Takes advantage of the fact that you can flatten `(:)` an array in Octave prior to assignment to a variable.

# Answer
> 0 votes
# MATLAB, 25 bytes

```
@(s)reshape([s;0*s],1,[])

```

Creates an anonymous function that can be then called using `ans('input string')`.

Exploits that fact that a null character is displayed as a space in MATLAB. Therefore `[s;0*s]` appends a new row that is all spaces. Then using `reshape` flattens this back out into a string but the spaces are inter-spersed due to the row-major ordering.

# Answer
> 0 votes
# Excel VBA, <sub>~~21~~</sub> 19 Bytes

Anonymous VBE immediate window function that takes input from cell `[A1]` and outputs to the VBE immediate window

```
?StrConv([A1],64)"

```

-1 Byte for removing `&` in `?` statement

-1 Byte for removing terminal `"` from `" "`

# Answer
> 0 votes
# MY, 8 bytes (noncompeting)

```
⍞ηυ←2Ġ'←

```

Try it online!

Explanation:

* `1E/⍞` \- receive a line of input from STDIN
* `57/η` \- split into individual characters
* `58/υ` \- joined by spaces
* `26/←` \- print to STDOUT without a newline
* `02/2` \- push 2 to the stack
* `25/Ġ` \- hexadecimal shift (pop n; push 16n. 2 * 16 is 32, which is the ASCII codepoint of the space)
* `28/'` \- convert to character (The space character, `υ` doesn't add a space to the end of the string)
* `26/←` \- output with no newline

I originally was thinking of using a vecify command (would have cost a lot of bytes) but then I remembered I had the nice little `υ`.

# Answer
> 0 votes
# AHK, 37 bytes

```
Loop,Parse,1
Send,%A_LoopField%{VK20}

```

The variable `1` is the first passed argument. `{VK20}` is a space.

# Answer
> 0 votes
# Taxi, 363 bytes

```
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Chop Suey.[a]Go to Chop Suey:n 1 r 1 l 4 r 1 l.Switch to plan "z" if no one is waiting.Pickup a passenger going to Post Office.Go to Zoom Zoom:n 1 l 3 r." " is waiting at Writer's Depot.Go to Writer's Depot:w.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Switch to plan "a".[z]

```

Try it online!

Un-golfed / formatted:

```
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to Chop Suey.
[a]
Go to Chop Suey: north 1st right 1st left 4th right 1st left.
Switch to plan "z" if no one is waiting.
Pickup a passenger going to Post Office.
Go to Zoom Zoom: north 1st left 3rd right.
" " is waiting at Writer's Depot.
Go to Writer's Depot: west.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st right 2nd right 1st left.
Switch to plan "a".
[z]

```

Nothing fancy here. It's just an old challenge that Taxi is able to easily handle, a rare thing at times.

# Answer
> 0 votes
# **Rust, 49 Bytes**

```
|mut x:String|{x.replace(""," ");x.remove(0);x}

```

it is an anonymous function, or lambda. It gets input from x, then modifies and returns it.

# Answer
> 0 votes
# SNOBOL4 (CSNOBOL4), 71 bytes

```
	I =INPUT
S	I LEN(1) . X REM . I :F(O)
	O =O X ' ' :(S)
O	OUTPUT =O
END

```

Try it online!

# Answer
> 0 votes
# Swift, 45 bytes

```
{$0.map{"\($0) "}.joined()}as(String)->String

```

Try it online!

# Answer
> 0 votes
# Standard ML (Mlton), 34 bytes

```
String.translate(fn c=>str c^" ");

```

Try it online! It turns out `translate : (char -> string) -> string -> string` from the `String` library is exactly the function needed for this task. The lambda `fn c=>str c^" "` takes a char, converts it to a string with the function `str` and prepends it to the string `" "`. `translate` applies this function to all chars and combines the resulting strings to a single string.

---

Other versions I found before stumbling over the `translate` function:

```
String.concatWith" "o map str o explode;
concat o map(fn c=>str c^" ")o explode;
foldr(fn(c,s)=>str c^" "^s)""o explode;
String.concatWithMap" "str o explode;    (* only in SML/NJ *)

```

# Answer
> 0 votes
# SmileBASIC, 39 bytes

```
LINPUT A$WHILE""<A$?SHIFT(A$);" ";
WEND

```

# Answer
> 0 votes
# Ahead, 8 bytes

```
~Wi@j '~

```

Try it online!

# Answer
> 0 votes
# C# (Visual C# Interactive Compiler), 44 bytes

```
for(int c;-1<(c=Read());Write((char)c+" "));

```

Try it online!

Not the first C# submission :) But it follows the challenge to the letter in terms of using `STDIN` and `STDOUT`.

# Answer
> 0 votes
# Japt `-P`, 2 bytes

```
ïS

```

Try it

```
ï      :Cartesian product with
 S     :  Space

```

# Answer
> 0 votes
# C#, 105 bytes

```
public class P{public static void Main(string[]a){foreach(char c in a[0]){System.Console.Write(c+" ");}}}

```

EDIT: Removed space between string\[\] and a, also removed ToString as its not crucial saving a total of 12 bytes

# Answer
> 0 votes
# C# (Visual C# Interactive Compiler), 44 bytes

Version reading an argument

```
Write(string.Join(" ",Args[0].ToList())+" ")

```

Try it online!

# 47 bytes

Version reading standard input

```
Write(string.Join(" ",ReadLine().ToList())+" ")

```

Try it online!

# Answer
> 0 votes
# 05AB1E, 3 bytes

```
ðâJ

```

Try it online!

```
ðâJ  # full program
  J  # join...
 â   # cartesian product of...
     # implicit input...
 â   # and...
ð    # " "
     # implicit output

```

# Answer
> 0 votes
# BRASCA, 10 bytes

```
![aEmmA{]x

```

Try it online!

## Explanation

```
!           - Push stack length
 [a   A{]   - For i in range(0,stack_length)
   E        - Push a space
    mm      - Shift the stack twice
         x  - Remove the excess 0
<implicit>  - Output the stack reversed

```

# Answer
> 0 votes
# Zsh, 16 bytes

```
<<<${${1/// }# }

```

Try it online!

# Answer
> 0 votes
# Factor \+ `sequences.interleaved`, 29 bytes

```
readln 32 <interleaved> print

```

Modern versions of Factor (i.e. not TIO) allow most sequences to be `print`ed as strings. So have a screenshot of running this in the listener:

# Answer
> 0 votes
# Thunno 2 `J`, 2 bytes

```
ðṖ

```

Attempt This Online!

Port of Dennis's Jelly answer: cartesian product with space. `J` flag joins the list.

# Answer
> 0 votes
# Python, 30 Bytes

```
lambda x:' '.join(list(x))+' '

```

`T r y i t o n l i n e !`

# Answer
> 0 votes
# Rockstar, 43 bytes

```
listen to S
cut S
join S with " "
say S+" "

```

Try it (Code will need to be pasted in)

# Answer
> 0 votes
# Nibbles, 3.5 bytes (7 nibbles)

```
+.@:$" "

```

Attempt This Online!

### Explanation

```
+.@:$" "
  @       First line of stdin as a string (list of chars)
 .        Map this function:
    $       To each char,
   :        Append
     " "    A space
+         Concatenate the resulting list of strings together

```

# Answer
> 0 votes
# ARBLE, 17 bytes

```
gsub(s,".","%1 ")

```

Full Program.

Try it online!

# Answer
> 0 votes
# Swift 5.9, 38 bytes

```
let f={($0+"").map{" \($0)"}.joined()}

```

---
Tags: code-golf, string
---


# Question
Title: Tips for shortening this type-safe addition in JavaScript
Consider:

```
c=(a,b)=>(+a||0)+(+b||0)

```

Yes, it is not good to solve it like that. But I want to shorten it even more. If `a` is a string and `b` is a string, then return `0`. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat it as a number).

I tried to shorten this more, but I just can’t.

This is the specification for the task:

## Usage

```
node app.js

```

## Expected behavior

The program returns the sum of two numbers. If no numbers are provided, the result should be `0`. If only one number is provided, only that number should be returned.

## Tests

```
node app.js 4 5 # 9

node app.js 4 # 4

node app.js 4 a # 4

node app.js a 4 # 4

node app.js a b # 0

node app.js 2.1 b # 2.1

node app.js 2.1 2.5 # 4.6

node app.js # 0

```

## Update

It also needs to handle floats as well not only integers.

This is my current code (only the code on line 1 should be optimized to be as small as possible):

```
c=(a,b)=>(+a||0)+(+b||0)

const input1 = process.argv[2];
const input2 = process.argv[3];

const result = c(input1, input2);

console.log(result);

```

# Answer
# JavaScript, ~~15~~ 14 bytes

```
c=a=>b=>~-a-~b

```

Try it online!
> 9 votes

# Answer
If you only need to handle integers, you can use bitwise operations to convert them into a numbers:

```
c=(a,b)=>(a|0)+(b|b) // Both ways shown fine

```

Or even shorter:

```
c=a=>b=>~-a-~b // (a-1)-(-b-1)

```

Try it online!

This doesn't work for floats, but this trick seems unmentioned elsewhere, so I've left it here.
> 8 votes

# Answer
# JavaScript, 23 bytes

```
c=(a,b)=>(a||0)-(-b||0)

```
> 2 votes

---
Tags: code-golf, tips, javascript
---


# Question
Title: Shortest code in your language to persist a string across a reboot
### Your Programs:

You'll write two programs (both in the same language). The storage program takes a string from STDIN and stores it somewhere *persistent* (see below) and then exits without error. The retrieval program takes no input, retrieves the string that was stored, and prints it to STDOUT.

### Objective test of Persistence:

You should be able to run the storage program on your local machine, then power-cycle your local machine, then call the retrieval program on your local machine. You can stash the string however you want (even on the web) as long as you pass this reboot test.

### Test Cases:

Storage then retrieval:

```
echo foo | Store
Retrieve
foo

```

Repeated Stores should overwrite (like a set() method):

```
echo foo | Store
echo bar | Store
Retrieve
bar

```

Repeated Retrieval is non-destructive (like a get() method):

```
echo foo | Store
Retrieve
foo
Retrieve
foo

```

Retrieval before any invocation of Storage:

You don't need to worry about this. Your retrieval program can assume that the storage program has been run at some point in the past.

### Input/Output flexibility.

People have asked me to expand this from strict STDIN/STDOUT to the standard IO rules. I can't because it would introduce too many loopholes. Some standard IO options already have the input stored in a persistent way, eg "programs may take input from a file". I'd like to be more flexible than just strict STDIN and STDOUT, but without opening the floodgates.

From the standard IO rules thread I'm cherry-picking the ones that don't break the challenge:

If you use an alternate it must be user-interactive. The user shouldn't have to do any other work besides piping their input to your program, typing it into a prompt your program provides, or typing input as a command-line-arg of your program. The user shouldn't have to do anything other than running your retrieve program to see the output displayed on screen or sent to STDOUT or STDERR.

### Allowed assumptions:

* Your two programs will be run in the same directory
* Your programs have read-write permissions for that directory
* Files you create will survive the reboot (not in a temp dir)
* One trailing newline that wasn't part of the string is allowed. No other trailing whitespace

### This is code-golf, and your score is the sum of bytes from both programs.

# Answer
> 89 votes
## zsh, 4 bytes

Store: `>f` (reads from STDIN and writes to a file called `f`)
Retrieve: `<f` (writes the contents of `f` to STDOUT)

# Answer
> 57 votes
# TI-BASIC (Z80), 1 byte?

Store:  (just enter the string)
Retrieve: `Ans` (byte 27)

But if that isn't valid:

# TI-BASIC (Z80), ~~7~~ 6 bytes

-1 thanks to Jakob.

Store: `Prompt Str0` (bytes DD AA 09)
Retrieve: `disp Str0` (bytes ED AA 09)

# Answer
> 24 votes
# Browser JS, 44 bytes

**Store**:

```
localStorage.a=prompt()

```

**Retrieve**:

```
alert(localStorage.a)

```

# Answer
> 20 votes
# POSIX shell sh/bash/... 8 bytes

store:

```
dd>f

```

get:

```
dd<f

```

# Answer
> 12 votes
# Python 3, 46 bytes

### store, 45 bytes:

```
open(*'fw').write('print(%r)'%open(0).read())

```

The retrieve program is built by the store command, a file named `f`. (1 byte for the file name)

# Answer
> 10 votes
# Batch, 16 bytes

```
COPY CON A
TYPE A

```

# Answer
> 8 votes
# Rust, 136 bytes

## Store (84 bytes)

```
use std::{fs::*,io::*};

```

```
||{let mut v=vec![];stdin().read_to_end(&mut v);write("a",v)}

```

## Retrieve (52 bytes)

```
||print!("{}",std::fs::read_to_string("a").unwrap())

```

## Acknowledgments

# Answer
> 8 votes
# Bash, ~~12 11~~ 10 bytes

## store, ~~7 6~~ 5 bytes

~~`cat ->f`~~ \# no need for `-`, stdin is default

~~`cat >f`~~ \# no need for space, `>` separates as well

```
cat>f

```

## retrieve, 5 bytes

```
cat f

```

# Answer
> 8 votes
# Powershell - 4 Bytes

Storage:

```
ac

```

(alternative also `sc`)

Retrieval

```
gc

```

Edit: I just noticed the output is not allowed any user input... so it jumps from 4 to either 6 or 8 bytes

Storage:

```
ac f

```

(alternative also `sc f`) for the 8 byte version

```
ac

```

(and specify `f` as path) for the 6 byte Version

Retrieval

```
gc f

```

# Answer
> 7 votes
# HP 49G RPL, 48 bytes

To save: `:2: A DUP PURGE STO`, 26.5 bytes

To restore: `:2: A RCL`, 21.5 bytes

If we can leave in the backup battery, we get:

# HP 49G RPL, 0 bytes

To save: , 0 bytes

To restore: , 0 bytes, since the HP 49G leaves the stack untouched across reboots.

# Answer
> 6 votes
# APL (APLX), 5 bytes

Store: `⍞⍈1`
Retrieve: `⍇1`

get line from stdin
`⍈1` write to next available component of file number 1

`⍇1` read the ~~first~~* last component of file number 1

* Documentation says *first* but experimentation shows *last*.

# Answer
> 6 votes
# bash, 10 bytes (non-competing)

```
touch $@
ls

```

Unix filenames can contain any character except `NUL` and `/`, and their names can be upto 255 bytes long so this will be able to store only strings up to that length (consider that a limitation of the storage medium), and that don't contain '/' in them. That's one reason this is non-competing, another is that this assumes the directory it's run on is empty (or that extraneous output from `ls` is allowed). I still wanted to post this because it just seemed a cool and non-obvious way to store information.

Another on a similar vein, which wouldn't have the same length and character limitations would be:

## ~~35~~ 33 bytes

```
mkdir -p $@
find|sed '$!d;s/..//'

```

This allows the `/` character in the string, and supports many more characters (exactly how many depends on implementation).

*(-2 bytes on this thanks to @Cows quack)*

# Answer
> 5 votes
# Python 3, 56 bytes

## Store (33 bytes)

```
open(*'aw').write(open(0).read())

```

## Retrieve (23 bytes)

```
print(open('a').read())

```

Prints with a trailing newline.

# Answer
> 4 votes
# Japt, ~~46~~ 30 bytes

*-16 bytes thanks to Shaggy.*

One of the first times I've tried using Japt. The JS eval can be fidgety sometimes. Uses the browser's `window.localStorage`.

## Store (16 bytes)

```
Ox`lo¯lSÈSge.P=U

```

## Retrieve (14 bytes)

```
Ox`lo¯lSÈSge.P

```

# Answer
> 4 votes
## Haskell, 46 bytes

Store (26 bytes):

```
getContents>>=writeFile"t"

```

Retrieve (20 bytes):

```
readFile"t">>=putStr

```

# Answer
> 3 votes
# C (GCC), 98 bytes

## Store (46 bytes)

Input is via first command line argument.

```
main(c,v)char**v;{fputs(v[1],fopen("a","w"));}

```

## Retrieve (52 bytes)

```
c,d;r(){for(d=open("a",0);read(d,&c,1);)putchar(c);}

```

## Unportability

* Requires that several pointer types fit in `int`.

## Acknowledgments

# Answer
> 3 votes
# Ruby (26 Bytes)

## Set (16 Bytes)

```
IO.write'a',gets

```

## Get (10 Bytes)

```
IO.read'a'

```

# Answer
> 3 votes
# MATLAB (30 Bytes)

## Set (22 Bytes)

```
a=input('','s');save a

```

Can shave off 4 bytes by changing to `input('')`, but this will require input to be in single quotes: `'input string'`

## Get (8 Bytes)

```
load a;a

```

# Answer
> 2 votes
# APL (Dyalog Unicode), 18 bytes

Store: `⍞⎕NPUT⎕A 1` Try it online!
Retrieve: `⊃⎕NGET⎕A` Try it online!

get line from stdin
`⎕NPUT` put it in a native file called
`⎕A` the uppercase alphabet `1` and overwrite if the file exists

the first part (the data, the next parts are encoding and line ending type) of
`⎕NGET` get the native file
`⎕A` the uppercase alphabet

# Answer
> 2 votes
# R (27 bytes)

## store (21 bytes)

```
x=readLines('stdin')

```

## load (6 bytes)

```
cat(x)

```

For this to work, the first script needs to be invoked with the command line option `--save`, and the second one with `--restore` (though in interactive mode this isn’t necessary: these options are the default).

This could be shortened by 7 bytes were it not for the fact that a bug in R prevents the default argument of `readLine` from working in non-interactive mode. In interactive mode, it is *not* necessary, and the solution therefore only uses **20 bytes**.

# Answer
> 2 votes
# Perl 5, 48 26 23 bytes

### Write, 20+1(-n) bytes

*-3 bytes thanks to mob*

```
open f,">>f";print f

```

I'm actually not certain about this one points-wise, but it meets the criteria. For past entries, only the cli options were counted, so that's what I'm going with.

### Read, 0+2 bytes

```
perl -pe "" f

```

# Answer
> 2 votes
# Java (JDK 10), 204 Bytes

**Warning:** Overwrites any preferences that any java programs have stored for your username!

### Store, 94 Bytes:

```
interface S{static void main(String[]a){java.util.prefs.Preferences.userRoot().put("",a[0]);}}

```

Try it online!

### Retrieve 110 Bytes:

```
interface R{static void main(String[]a){System.out.print(java.util.prefs.Preferences.userRoot().get("",""));}}

```

Try it online!

```
java S foo
java R
foo

```

This works by taking input as an arg and storing it in the user preferences backing-store provided by java.util.prefs. It overwrites the user's root node to save one byte on naming a node. If you want to test it non-deestructively, either run it from a throwaway username or change the key from "" to a node name.

# Answer
> 2 votes
# C#, 157 Bytes

**Set, 74 Bytes:**

```
class P{static void Main(string[]a){System.IO.File.WriteAllLines("a",a);}}

```

**Get, 83 Bytes:**

```
class P{static void Main(){System.Console.Write(System.IO.File.ReadAllText("a"));}}

```

-1 Bytes thanks to VisualMelon
-2 Bytes thanks to LiefdeWen

# Answer
> 2 votes
# Sed, 2+2 bytes:

Stores to file `f`:

```
wf

```

Reads from file `f`:

```
rf

```

Try a demo online!

# Answer
> 1 votes
# Attache, 23 + 16 = 39 bytes

Simply writes STDIN to file `A`, then reads file `A`.

`store.@`:

```
$A&FileWrite!AllInput[]

```

`retrieve.@`:

```
Echo!FileRead!$A

```

## Testing

```
C:\Users\conorob\Programming\attache (master -> origin)
λ echo testing | attache store.@

C:\Users\conorob\Programming\attache (master -> origin)
λ attache retrieve.@
testing

```

# Answer
> 1 votes
# Lua, 57 53 51 bytes

**Store, 27 bytes**

```
io.open("x","w"):write(...)

```

**Retrieve, 24 bytes**

```
print(io.open"x":read())

```

# Answer
> 1 votes
**RUBY**

**Store** *(24 bytes)*

```
File.write('a', ARGV[0])

```

**Retrieve** *(16 bytes)*

```
p File.read('a')

```

# Answer
> 1 votes
# C (Unix/GNU), 23+23 = 46 bytes

## Store, ~~27~~23 bytes

```
main(){system("dd>f");}

```

## Retrieve, ~~27~~23 bytes

```
main(){system("dd<f");}

```

This basically wraps jofel's answer into a C program.

Note: The `dd` commands outputs some statistics to `stderr`, so you will see some additional output when you naively run it in the shell. However, since the challenge only says that the stored string must be presented on `stdout`, not `stderr`, I take it that it is allowed to have additional output on `stderr`... Anyway, suppressing `stderr` output is as easy as replacing `dd` with `cat`, increasing the byte counts of the two programs by one, each.

# Answer
> 1 votes
# C (gcc), ~~77~~ 67 + 25 = 92 bytes

Compiles with only a few warnings on my gcc.

**store.c**

```
#include<stdio.h>
main(int c,char**v){fputs(v[1],fopen("f","w"));}

```

Can probably golf out the include, but I couldn't figure out how. Segfaults if you don't pass it anything, but whatever.

Peter Cordes: -1

**read.c**

```
main(){system("cat f");}

```

# Answer
> 1 votes
# PHP, 26+1 + 21 = 48 bytes

Store.php:

```
<?fputs(fopen(s,w),$argn);

```

Run with `echo <input> | php -nF Store.php`.

Retrieve.php:

```
<?=fgets(fopen(s,r));

```

Run with `php -n Retrieve.php`.

# Answer
> 1 votes
# JavaScript (Node.js), 129 bytes

### Store, 78 bytes

`(p=process).stdin.resume().on('data',t=>require('fs').writeFile('_',t,p.exit))`

### Retrieve, 51 bytes

`console.log(require('fs').readFileSync('_','utf8'))`

# Answer
> 1 votes
# Batch - 11 Bytes

```
%12>f
type f

```

The input is received as a command-line argument and persists (with the error message created upon execution attempt, since CMD attempts to execute the parameter) in `f`.

---

# Batch - 7 Bytes (non-competitive)

```
'>%1
dir

```

There are a plethora of invalid characters in a file name, so this wouldn't work for some strings, but this essentially saves an arbitrary character to the filename given by the parameter. To read it, it just lists all files in the directory, including our string.

# Answer
> 0 votes
# Java 8, 156 bytes

Both solutions are lambdas taking empty input and throwing `java.io.IOException`.

## Store (93 bytes)

```
import java.nio.file.*;

```

```
v->Files.copy(System.in,Paths.get("a"),StandardCopyOption.values()[0])

```

## Retrieve (63 bytes)

```
import java.nio.file.*;

```

```
v->Files.copy(Paths.get("a"),System.out)

```

# Answer
> 0 votes
# SmileBASIC (v3+), 23 + 14 = 37 bytes

Simple filesystem-based answer. Works in all known SmileBASIC environments v3.x or above. Be careful, in case you happen to have an important text file named `A`!

## Store, 23 bytes

```
LINPUT S$SAVE"TXT:A",S$

```

## Retrieve, 14 bytes

```
?LOAD("TXT:A")

```

---

# SmileBASIC (v2), 21 + 16 = 37 bytes

Adjusted to work on old SmileBASIC (Petit Computer/mkII for DSi).

## Store, 21 bytes

```
LINPUT MEM$SAVE"MEM:A

```

## Retrieve, 16 bytes

```
LOAD"MEM:A
?MEM$

```

---

I'm honestly kinda amazed both versions work out to the same total byte count.

# Answer
> 0 votes
# Powershell | 26 bytes

## Store (store.ps1 | 24 bytes)

```
"`$s='$input'">>$profile

```

## Retrieve (retrieve.ps1 | 2 bytes)

```
$s

```

## Calling

```
Read-Host|.\store.ps1

# close powershell, reboot
# open new Powershell

.\retrieve.ps1

```

# Answer
> 0 votes
# Cgam, 7 bytes

### Store, 4 bytes

```
qSow

```

### Retrieve, 3 bytes

```
Sog

```

Unfortunately, there is not yet a web interpreter, all you can do is download the code, build it, and run it yourself...

# Answer
> 0 votes
# NodeJS (REPL) v10.0.0, 57 bytes

Store: `fs.writeFileSync("a",process.args)`

Read: `fs.readFileSync("a")+[]`

# Answer
> 0 votes
## Mathematica, 23 bytes

```
InputString[]>>"a"

```

`Put[]`, abbreviated `>>` as an infix operator, receives an expression as its left operand, then writes that expression to the filespec given in its right operand, here the file `a`. `InputString[]` interactively (graphically or textually, depending on how the kernel is being accessed) receives a string and returns that expression. This store program is 18 bytes.

```
<<"a"

```

`Get[]`, abbreviated `<<` as a prefix operator, reads the file specified by its right argument, evaluating each expression in it, then returns the last such expression. This retrieval program is 5 bytes.

You can use `Directory[]` to find out where the file is stored. The representation stored in the file is quoted, so is equivalent to an expression representing a string.

# Answer
> 0 votes
## Pascal (95+92=187)

Store:

```
program i;var f:Text; s:string;begin Assign(f,'i');Rewrite(f);Read(s);Write(f,s);Close(f);end.

```

Retrive:

```
program o;var f:Text;s:string;begin Assign(f,'i');Reset(f);Read(f,s);Write(s);Close(f);end.

```

You can omit Close(f); in retrive and shorten it a little bit, but, not in a spirit of pascal!

# Answer
> 0 votes
# Yabasic, 36+38=74 bytes

Two scripts that write to the file `t` in the current directory. TIO Link provided both the getter and setter in both cases

### Setter

```
Input""s$
Open#1,"t","w"
?#1s$
Close#1

```

### Getter

```
Open#1,"t","r"
Input#1t$
Close#1
?t$

```

Try it online!

# Answer
> 0 votes
## HP‑41C series, 16 B

The alpha‑register (α‑register) can store **up to 24 alphabetic characters**. The contents of the α‑register are persistent. You can turn the calculator off and on again, they remain there until overwritten.

```
01♦LBL "S"         5 Bytes    global label requires 4 + (length of string) Bytes
02 CLA             1 Byte     clear contents of α‑register
03 AON             1 Byte     activate alpha‑keyboard
04 PROMPT          1 Byte     display α‑register and stop program execution
05 RTN             1 Byte     `RTN` does not affect local label search

```

The `CLA` (clear alpha) command clears the contents of the α‑register. This is necessary in case of *empty* input. The subsequent `PROMPT` command does not change the α‑register in case there is no input at all.

The `PROMPT` displays the contents of the alpha‑register, and *stops* the program. The user can enter a string now. Once the `R/S` (run/stop) key is pressed (≘ end‑of‑file indicator), program execution resumes with the command following the `PROMPT` command.

```
01♦LBL "R"         5 Bytes    "S" like "store", "R" like "retrieve"
02 AVIEW           1 Byte     select the α‑register as the current display
03 RTN             1 Byte     this is cheaper than an `END` (3 Bytes)

```

Keep in mind, if in your program further calculations follow, the `AVIEW` (alpha view) command *by itself* does not stop program execution and allow the user to read the display. The `AVIEW` command is therefore usually paired with other commands such as `STOP`.

Note, if flag 21 (printer enable) is set, but there is no printer or the printer is off, `AVIEW` *does* in fact stop program execution (so the user has a chance to *manually* record display contents). To resume operations press `R/S` (run/stop).

---

Note, *leading* `NULL` Bytes cannot be stored *and* retrieved to and from the α‑register. Moreover, another implementation could use *text files*. Text files permit storing *records* of **up to 254 alphabetic characters** each.
See also HP‑49G RPL submission, a different pocket calculator by the Hewlett‐Packard Company.

---
Tags: code-golf, stateful
---