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

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>

• Usually you should allow functions too, or you exclude a lot of languages (e.g. JavaScript). – wizzwizz4 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). – Dennis Mar 22 '16 at 21:22
• Ｔｈａｔ　ｉｓ　ｎｏｔ　ｗｈａｔ　ｆｕｌｌｗｉｄｔｈ　ｔｅｘｔ　ｉｓ． – BlueRaja - Danny Pflughoeft 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 – Ludovic Frérot Mar 23 '16 at 9:27
• @LudovicFrérot Actually, these are not ideograms, these are chinese english letters. – Erik the Outgolfer Jul 1 '16 at 8:29

# 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);
}


# C#, 35 bytes

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


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

• This requires a using System.Linq derivative, which should either be included or the language marked as LinqPad or similar. – VisualMelon Jan 12 '17 at 11:07

## Python 3, 39 bytes

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

• You could just join with a " " rather than insert it with the comprehension. Then all you need to worry about is the trailing space at the end. print(" ".join(input())+" ") gets you down to 28 bytes – wnnmaw Mar 23 '16 at 16:15
• This is now exact duplicate of Raffi's answer, which reached this format 1 day 01:30:09 hour earlier. – manatwork Mar 24 '16 at 10:34
• @manatwork I see. Should I change my old answer back or something? Thanks for telling! – Yytsi Mar 24 '16 at 11:37
• Just improve it more. ;) In meantime I would revert to the previous version – it demonstrates the usage of a very popular Python feature, which has better chances for positive votes than a duplicate. – manatwork Mar 24 '16 at 12:17
• @manatwork Very good point! Reverted it. Back to 39 bytes :D – Yytsi Mar 24 '16 at 12:32

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

• You can cut one byte by removing the space after print. – Zach Gates Mar 22 '16 at 22:53
• Or just switch to Python 3 (and cut 3 bytes): print(' '.join(input)+' '). raw_input is more expensive than parens with print. – CalculatorFeline Mar 23 '16 at 2:31

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

• Welcome to the site! You can remove a byte by removing the space after the : as well as taking a look at these tips for Python golfing – caird coinheringaahing Jan 26 '18 at 16:26
• You could get this down to a one-liner: print(''.join(i+' 'for i in input()) – DJMcMayhem Jan 26 '18 at 16:41
• @DJMcMayhem, made it even shorter :) – Mercury Platinum Jan 26 '18 at 16:45
• Does this print a space after the last character? And do you need the list() part? – Jo King Jan 27 '18 at 5:36
• oh, one second. – Mercury Platinum Jan 27 '18 at 16:36

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

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

• You can remove the leading ｛ as it can be implicit for 3 bytes – dzaima Mar 6 '18 at 16:23

# 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

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

# Brainfuck, 23 2425 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.

• 24 bytes. The initialization part is taken from this page – ovs Jan 27 '18 at 10:13
• Cool, very nice. I have problems understanding your program though. Could you explain it to me? – Dust Jan 27 '18 at 10:21
• The code makes use of the fact that most brainfuck implementations use wrapping 8-bit cells. If you decrement a cell that is zero, you get to 255. Here is a simple example. – ovs Jan 27 '18 at 10:35
• The , should be at the end of the loop, otherwise you print an extra nul byte. Try it online! – Jo King Feb 12 '19 at 0:47
• 22 bytes – RezNesX Feb 12 at 7:34

# 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


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

• 7 bytes. Mostly because you can combine all the loops into one loop over the input – Jo King Feb 12 '19 at 0:29
• @JoKing Wow, that is really smart using the E function! Also I just realized that it only needs one space, and that I forgot to add spaces after the last characters, sorry! – KrystosTheOverlord Feb 12 '19 at 0:31
• @JoKing Almost managed 6 bytes, but it prints entirely backwards... iEH@ – KrystosTheOverlord Feb 12 '19 at 0:44

# PowerShell, 24 bytes

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


Try it online!

# 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


# Zsh, 21 bytes

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


Try it online!

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

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

## W, 4 bytes

 "+M


## Explanation

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


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

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

• Great! The codegolf allow you to use an char array instead of a string. Therefore, 8 bytes – mazzy Jan 2 '20 at 7:21
• @mazzy finally, a competitive PowerShell answer ;) thanks! – GMills Jan 2 '20 at 16:37

## Silicon, 7 bytes

Note that this is non-competing.

iSæ²jæ+


Explanation:

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

• Does Silicon have it's own encoding? Else, it would be 10 bytes in UTF-8 (and 7 chars). – Katenkyo Jul 6 '16 at 9:07

# VyxalṪ, 3 2 bytes

Ṅð


Try it Online!

Explanation:

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


## Vyxal S, 0 bytes

Try it Online!

Explanation:

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


Full program

alert(prompt().replace(/./g,"$& "))  # Javascript ES6, 24 chars Just a function s=>s.replace(/./g,"$& ")

• As we are using a leaderboard right now, would you mind modifying your title for just "Javascript", as it will actually be considered as an other language. – Katenkyo Mar 23 '16 at 9:50
• @Katenkyo, updated – Qwertiy Mar 23 '16 at 9:54

## Befunge-98, 21 bytes

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


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

# Japt, 5 bytes

U¬¸+S


Try it here.

# Matlab/Octave, 51 bytes

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


# Befunge-93, 18 bytes

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


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

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

# AHK, 37 bytes

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


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

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