49
\$\begingroup\$

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>

Alex A.
24.8k5 gold badges39 silver badges120 bronze badges
asked Mar 22, 2016 at 17:45
\$\endgroup\$
10
  • 8
    \$\begingroup\$ Usually you should allow functions too, or you exclude a lot of languages (e.g. JavaScript). \$\endgroup\$ Commented Mar 22, 2016 at 18:00
  • 10
    \$\begingroup\$ 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). \$\endgroup\$ Commented Mar 22, 2016 at 21:22
  • 65
    \$\begingroup\$ That is not what fullwidth text is. \$\endgroup\$ Commented Mar 22, 2016 at 21:53
  • 4
    \$\begingroup\$ @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 \$\endgroup\$ Commented Mar 23, 2016 at 9:27
  • 3
    \$\begingroup\$ @LudovicFrérot Actually, these are not ideograms, these are chinese english letters. \$\endgroup\$ Commented Jul 1, 2016 at 8:29

151 Answers 151

3
\$\begingroup\$

R, 36 bytes

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

Example:

> cat(strsplit(readline(),"")[[1]],"")
Hello R!
H e l l o R ! 
answered Mar 22, 2016 at 20:39
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You don't need sep=" ", so this can be much shorter: Try it online! \$\endgroup\$ Commented Mar 9, 2018 at 16:50
3
\$\begingroup\$

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
answered Feb 12, 2019 at 0:53
\$\endgroup\$
2
\$\begingroup\$

Ruby, (削除) 24 (削除ここまで) 15 bytes

gsub /./,'0円 '

Requires the -p flag (byte added).

Thanks to xsot for 9 bytes!

answered Mar 22, 2016 at 22:25
\$\endgroup\$
4
  • \$\begingroup\$ Using -p saves 8 bytes \$\endgroup\$ Commented Mar 23, 2016 at 1:03
  • \$\begingroup\$ @xsot Thanks, I didn't even know that flag existed! \$\endgroup\$ Commented Mar 23, 2016 at 1:10
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Mar 23, 2016 at 1:28
  • 1
    \$\begingroup\$ @xsot Comma's not an operator in Ruby. Parenthesis are frequently optional, except in certain contexts. \$\endgroup\$ Commented Mar 23, 2016 at 1:29
2
\$\begingroup\$

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
answered Mar 23, 2016 at 16:28
\$\endgroup\$
2
  • \$\begingroup\$ Wow, sleek usage of " and wrap-around \$\endgroup\$ Commented Mar 23, 2016 at 18:21
  • \$\begingroup\$ -1 Byte \$\endgroup\$ Commented Dec 19, 2017 at 7:32
2
\$\begingroup\$

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.

answered Mar 23, 2016 at 16:52
\$\endgroup\$
2
\$\begingroup\$

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.

answered Mar 23, 2016 at 9:16
\$\endgroup\$
2
\$\begingroup\$

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 .
answered Mar 24, 2016 at 2:11
\$\endgroup\$
4
  • \$\begingroup\$ Nice answer, but i think you mean '/g/ in the test case not '/f'. +1 though. \$\endgroup\$ Commented Mar 24, 2016 at 2:47
  • \$\begingroup\$ Thank you, 'f' is right next to 'g' on the dvorak keyboard \$\endgroup\$ Commented Mar 24, 2016 at 3:37
  • 1
    \$\begingroup\$ My understanding is that a leading space is not permitted. \$\endgroup\$ Commented Mar 24, 2016 at 10:55
  • \$\begingroup\$ I concur with @Neil. The challenge specifically mentions a trailing space. Therefore the sed command must be something like s/./& /g, which is still 8 Bytes nevertheless. \$\endgroup\$ Commented Mar 15, 2024 at 14:54
2
\$\begingroup\$

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=' '
. . .
. . .
. . .
answered Mar 29, 2016 at 13:21
\$\endgroup\$
2
\$\begingroup\$

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 . "
answered Apr 18, 2016 at 3:02
\$\endgroup\$
2
\$\begingroup\$

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)
answered Mar 22, 2016 at 18:16
\$\endgroup\$
2
\$\begingroup\$

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

answered Mar 3, 2017 at 20:06
\$\endgroup\$
2
  • \$\begingroup\$ I just accidentally posted this solution without seeing yours. Is there no way to convert to array mode with A by splitting on nothing so Hi becomes [ "H", "i" ]? I though no argument would do it or a space but I was wrong. \$\endgroup\$ Commented Jul 26, 2017 at 16:26
  • \$\begingroup\$ @TheLethalCoder Another one of the reasons I am doing the rewrite of Carrot, the current interpreter does a terrible job of parsing and everything is just a bunch of hacks taped very loosely... In the new interpreter, A is planned take a string as an argument, where this string can be of any length, in which case what you are suggesting should work. \$\endgroup\$ Commented Jul 26, 2017 at 16:36
2
\$\begingroup\$

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 ! " 
answered Jun 4, 2017 at 17:53
\$\endgroup\$
2
\$\begingroup\$

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)

answered Jul 26, 2017 at 14:50
\$\endgroup\$
4
  • \$\begingroup\$ Can you explain why this needs to be encoded in UTF-8? \$\endgroup\$ Commented Jul 26, 2017 at 16:01
  • \$\begingroup\$ @Zacharý Does it? Is ⎕AVU no good? \$\endgroup\$ Commented Jul 26, 2017 at 16:03
  • \$\begingroup\$ Clarification: Why this is 12 bytes and not 4? \$\endgroup\$ Commented Jul 26, 2017 at 16:06
  • \$\begingroup\$ @Zacharý Ah, simple mistake. \$\endgroup\$ Commented Jul 26, 2017 at 16:30
2
\$\begingroup\$

Julia, 31 bytes

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

Try it online!

answered Dec 17, 2017 at 17:24
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ Commented Dec 17, 2017 at 17:43
  • \$\begingroup\$ 30 bytes \$\endgroup\$ Commented Apr 19, 2021 at 14:48
2
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Oh well, that's embarassing. I wrote the same amount of bytes as another answer and that one has got five downvotes. Oops. \$\endgroup\$ Commented Dec 14, 2017 at 15:50
  • 2
    \$\begingroup\$ Welcome to PPCG! I don't know C, but this fails on words with spaces TIO \$\endgroup\$ Commented Dec 14, 2017 at 15:53
  • \$\begingroup\$ @tfbninja Fixed. cin isn't particularly fond of strings containing spaces. \$\endgroup\$ Commented Dec 14, 2017 at 17:28
2
\$\begingroup\$

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

\$\endgroup\$
3
  • \$\begingroup\$ It's been a while since I've used C#, but I don't believe you need the Func<string,string>f= part - we allow anonymous functions, so long as they can be captured and called. \$\endgroup\$ Commented Jul 1, 2016 at 10:18
  • \$\begingroup\$ @Mego I think he needs to provide datatypes, and he cannot provide them otherwise. \$\endgroup\$ Commented Jul 1, 2016 at 10:28
  • 1
    \$\begingroup\$ You should read the C# golfing tips thread. :) \$\endgroup\$ Commented Jul 6, 2016 at 18:48
2
\$\begingroup\$

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
answered Apr 16, 2016 at 18:02
\$\endgroup\$
0
2
\$\begingroup\$

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

answered Mar 9, 2018 at 12:50
\$\endgroup\$
2
\$\begingroup\$

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 
answered Feb 13, 2019 at 9:21
\$\endgroup\$
2
\$\begingroup\$

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 "
answered Aug 19, 2019 at 16:20
\$\endgroup\$
8
  • \$\begingroup\$ Unless ngn/k is completely incapable of taking input any other way, you are not allowed to take input by adding it to your source code, even ignoring this challenge's explicit requirement to use STDIN. \$\endgroup\$ Commented Aug 19, 2019 at 16:23
  • \$\begingroup\$ @pppery there is no stdin functionality within k \$\endgroup\$ Commented Aug 19, 2019 at 17:23
  • 1
    \$\begingroup\$ 0:"" reads from stdin \$\endgroup\$ Commented Aug 20, 2019 at 15:13
  • \$\begingroup\$ @ngn TIL... i will update. thanks! \$\endgroup\$ Commented Aug 20, 2019 at 15:16
  • \$\begingroup\$ by the way, it's 0:` in k7 (shakti), i'll add that as an alternative next time i update ngn/k \$\endgroup\$ Commented Aug 20, 2019 at 15:20
2
\$\begingroup\$

W, 4 bytes

 "+M

Explanation

 M % Foreach the input list:
 + % Join the current item with ...
 " % ... A space character
answered Dec 28, 2019 at 14:56
\$\endgroup\$
2
\$\begingroup\$

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.

answered Jan 2, 2020 at 7:25
\$\endgroup\$
2
\$\begingroup\$

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.

answered Apr 8, 2021 at 20:44
\$\endgroup\$
3
  • \$\begingroup\$ This looks really cool! I've got a bounty for interesting new languages, and I think this would count as one. If you want I can give this a +100 bounty, or if you want to post another answer that shows off more language features I could award it to that one \$\endgroup\$ Commented Apr 8, 2021 at 20:49
  • \$\begingroup\$ @RedwolfPrograms Thanks! I'm glad you like it! I think I'll try and find another challenge so I can show off the features more, especially the register. \$\endgroup\$ Commented Apr 8, 2021 at 21:23
  • \$\begingroup\$ @RedwolfPrograms I think this answer would be a good one for the bounty. \$\endgroup\$ Commented Apr 12, 2021 at 16:56
2
\$\begingroup\$

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
```
answered Sep 25, 2021 at 0:35
\$\endgroup\$
2
\$\begingroup\$

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).
Kai Burghardt
1,2042 gold badges11 silver badges15 bronze badges
answered Mar 23, 2016 at 1:21
\$\endgroup\$
2
\$\begingroup\$

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:`.

answered Mar 15, 2024 at 19:10
\$\endgroup\$
2
\$\begingroup\$

Bespoke, 99 bytes

spacing expands width of my text
it gets enhanced,and it prints better
we see it,and we prefer it

It's too bad spaces delimit words in Bespoke (and take up extra bytes); it would've been really fun to write this in full-width style.

answered Mar 17 at 5:46
\$\endgroup\$
1
\$\begingroup\$

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.

answered Mar 22, 2016 at 18:05
\$\endgroup\$
1
\$\begingroup\$

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
answered Mar 22, 2016 at 18:43
\$\endgroup\$
1
\$\begingroup\$

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!

answered Mar 22, 2016 at 20:18
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.