44
\$\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>

\$\endgroup\$
  • 6
    \$\begingroup\$ Usually you should allow functions too, or you exclude a lot of languages (e.g. JavaScript). \$\endgroup\$ – wizzwizz4 Mar 22 '16 at 18:00
  • 8
    \$\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\$ – Dennis Mar 22 '16 at 21:22
  • 52
    \$\begingroup\$ That is not what fullwidth text is. \$\endgroup\$ – BlueRaja - Danny Pflughoeft Mar 22 '16 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\$ – Ludovic Frérot Mar 23 '16 at 9:27
  • 2
    \$\begingroup\$ @LudovicFrérot Actually, these are not ideograms, these are chinese english letters. \$\endgroup\$ – Erik the Outgolfer Jul 1 '16 at 8:29

128 Answers 128

2
\$\begingroup\$

Ruby, 24 15 bytes

gsub /./,'\0 '

Requires the -p flag (byte added).

Thanks to xsot for 9 bytes!

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

Pyth, 5 4 bytes

Thanks to @FryAmTheEggman for saving a byte.

s*zd

Try it online here.

\$\endgroup\$
  • \$\begingroup\$ Jesus hecking christ how the heck \$\endgroup\$ – Tornado547 Dec 14 '17 at 19:53
  • \$\begingroup\$ Alternative 4-byter: s+R; \$\endgroup\$ – Sok Feb 14 at 13:56
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
\$\endgroup\$
  • \$\begingroup\$ Wow, sleek usage of " and wrap-around \$\endgroup\$ – daniero Mar 23 '16 at 18:21
  • \$\begingroup\$ -1 Byte \$\endgroup\$ – Jo King Dec 19 '17 at 7:32
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.

\$\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 .
\$\endgroup\$
  • \$\begingroup\$ Nice answer, but i think you mean '/g/ in the test case not '/f'. +1 though. \$\endgroup\$ – Rɪᴋᴇʀ Mar 24 '16 at 2:47
  • \$\begingroup\$ Thank you, 'f' is right next to 'g' on the dvorak keyboard \$\endgroup\$ – Ben Perlin Mar 24 '16 at 3:37
  • \$\begingroup\$ My understanding is that a leading space is not permitted. \$\endgroup\$ – Neil Mar 24 '16 at 10:55
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=' '

.                          .                             .
.                          .                             .
.                          .                             .
\$\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 . "
\$\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)
\$\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

\$\endgroup\$
  • \$\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\$ – TheLethalCoder Jul 26 '17 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\$ – Kritixi Lithos Jul 26 '17 at 16:36
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\$
  • \$\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\$ – TheOutrageousZ Dec 14 '17 at 15:50
  • 2
    \$\begingroup\$ Welcome to PPCG! I don't know C, but this fails on words with spaces TIO \$\endgroup\$ – FantaC Dec 14 '17 at 15:53
  • \$\begingroup\$ @tfbninja Fixed. cin isn't particularly fond of strings containing spaces. \$\endgroup\$ – TheOutrageousZ Dec 14 '17 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\$
  • \$\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\$ – Mego Jul 1 '16 at 10:18
  • \$\begingroup\$ @Mego I think he needs to provide datatypes, and he cannot provide them otherwise. \$\endgroup\$ – Erik the Outgolfer Jul 1 '16 at 10:28
  • 1
    \$\begingroup\$ You should read the C# golfing tips thread. :) \$\endgroup\$ – aloisdg says Reinstate Monica Jul 6 '16 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
\$\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 "
\$\endgroup\$
  • \$\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\$ – pppery Aug 19 at 16:23
  • \$\begingroup\$ @pppery there is no stdin functionality within k \$\endgroup\$ – scrawl Aug 19 at 17:23
  • 1
    \$\begingroup\$ 0:"" reads from stdin \$\endgroup\$ – ngn Aug 20 at 15:13
  • \$\begingroup\$ @ngn TIL... i will update. thanks! \$\endgroup\$ – scrawl Aug 20 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\$ – ngn Aug 20 at 15:20
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.

\$\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
\$\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!

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

LiveScript, 17.

->"#{it/''*' '} "
\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

Ruby, 41 bytes

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

chomp eats trailing newlines.

\$\endgroup\$
  • 1
    \$\begingroup\$ There is no requirement to output the whole result at once. If you output it piece-by-piece, you can spare the .join call. Even more, if you not need to return the pieces from the code block, then you can spare the .map call too, as .chars also accepts code block. And there is no restriction against adding a space after the trailing newline too, if there is one. gets.chars{|e|$><<e+" "} \$\endgroup\$ – manatwork Mar 23 '16 at 10:47
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

C, 48 bytes

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

Try it online

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

Jolf, 7 bytes

Try it here!

p4i*li♣
p4       interweave
  i      the input
   *li♣  with a string of spaces with = length to the input
\$\endgroup\$
1
\$\begingroup\$

RETURN, 10 bytes

`""¨{' °},

Try it here.

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

\$\endgroup\$
1
\$\begingroup\$

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)))
\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Update this post later? \$\endgroup\$ – CalculatorFeline Mar 23 '16 at 2:25
  • \$\begingroup\$ @CatsAreFluffy oh, my bad, I forgot, will do now. \$\endgroup\$ – GamrCorps Mar 23 '16 at 2:38
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.