# 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.

• Usually you should allow functions too, or you exclude a lot of languages (e.g. JavaScript). Mar 22 '16 at 18:00
• We have a few defaults for I/O that are based on community consensus. While you are entitled to override them, insisting on STDIN/STDOUT for I/O invalidates a bunch of answers (which assumed that the defaults apply) and make the task downright impossible in other languages (they don't have standard streams). Mar 22 '16 at 21:22
• Ｔｈａｔ　ｉｓ　ｎｏｔ　ｗｈａｔ　ｆｕｌｌｗｉｄｔｈ　ｔｅｘｔ　ｉｓ． Mar 22 '16 at 21:53
• @BlueRaja-DannyPflughoeft is right. Full Width text is about underlying character encoding ( 2 bytes encoded ) required by some language ( i.e. ideograms ). In Unicode the notion of half and full size is called Unicode block Mar 23 '16 at 9:27
• @LudovicFrérot Actually, these are not ideograms, these are chinese english letters. Jul 1 '16 at 8:29

## 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

## Ruby, 24 15 bytes

gsub /./,'\0 '

Requires the -p flag (byte added).

Thanks to xsot for 9 bytes!

• Using -p saves 8 bytes
– xsot
Mar 23 '16 at 1:03
• @xsot Thanks, I didn't even know that flag existed!
– Doorknob
Mar 23 '16 at 1:10
• I didn't realise you could omit the parentheses without confusing the interpreter. Looks like the comma operator isn't as overloaded the way I expected.
– xsot
Mar 23 '16 at 1:28
• @xsot Comma's not an operator in Ruby. Parenthesis are frequently optional, except in certain contexts.
– Doorknob
Mar 23 '16 at 1:29

## Befunge-93, 12 bytes

~:1+!#@_, ",

Tested using this online interpreter.

: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
• Wow, sleek usage of " and wrap-around Mar 23 '16 at 18:21
• -1 Byte
– Jo King
Dec 19 '17 at 7:32

## 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)
.          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.

# 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.

# C, 48 bytes

Try it online

## 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...

# 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.

# Jolf, 7 bytes

Try it here!

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

# RETURN, 10 bytes

`""¨{' °},

Try it here.

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