As programers say: Strive to be lazyWord Spinner PuzzleLet's play countdown!A Mnemonic for Remembering 23940Play the word chainMake this code explanation pretty againCompounding englishFind the original string, without the repetition without the repetition in the middleDon't get your head in a spin!Use that goodn't memeMake a simple word wrapper

What are the ramifications of setting ARITHABORT ON for all connections in SQL Server?

Is Simic Ascendancy triggered by Awakening of Vitu-Ghazi?

Is it a Munchausen Number?

Drawing Quarter-Circle

Why use steam instead of just hot air?

How does Howard Stark know this?

Control variables and other independent variables

How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?

What does i386 mean on macOS Mojave?

Exception propagation: When to catch exceptions?

Is the homebrew weapon attack cantrip 'Arcane Strike' balanced?

How to make a language evolve quickly?

Can the sorting of a list be verified without comparing neighbors?

Why was this sacrifice sufficient?

Was there a contingency plan in place if Little Boy failed to detonate?

Is a vertical stabiliser needed for straight line flight in a glider?

Is the schwa sound consistent?

Help decide course of action for rotting windows

Washer drain pipe overflow

We are two immediate neighbors who forged our own powers to form concatenated relationship. Who are we?

Is there a faster way to calculate Abs[z]^2 numerically?

Ex-manager wants to stay in touch, I don't want to

Why was the Ancient One so hesitant to teach Dr. Strange the art of sorcery?

What is the best way for a skeleton to impersonate human without using magic?



As programers say: Strive to be lazy


Word Spinner PuzzleLet's play countdown!A Mnemonic for Remembering 23940Play the word chainMake this code explanation pretty againCompounding englishFind the original string, without the repetition without the repetition in the middleDon't get your head in a spin!Use that goodn't memeMake a simple word wrapper













1












$begingroup$


Story



Have you seen this post from 9gag?
Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that.



The submission



Your program will get an input string which it will return with quation marks as explained bellow.
Standard loopholes are forbidden. Output as list of lines is allowed. Trailing spaces, empty lines that doesn't break the output are allowed.



The rules of input



The input only contains printable ASCII characters.
The input may contain spaces. The words are determined with them.
If one word is given then the program has to return the string between quation marks.



Example of one word:



test -> "test"


If the input string has 2 or more words then it returns first with the whole input, but the first word in quation, on the second time, all the input but the second word between quation marks and so on.



In general, the program has to return as many lines, as many words are in the input.



Example of three words:



This is codegolf -> "This" is codegolf
This "is" codegolf
This is "codegolf"


The case of no input, or empty string doesn't matter.



Examples:



This is a significantly longer, but not the longest testcase -> "This" is a significantly longer, but not the longest testcase
This "is" a significantly longer, but not the longest testcase
This is "a" significantly longer, but not the longest testcase
This is a "significantly" longer, but not the longest testcase
This is a significantly "longer," but not the longest testcase
This is a significantly longer, "but" not the longest testcase
This is a significantly longer, but "not" the longest testcase
This is a significantly longer, but not "the" longest testcase
This is a significantly longer, but not the "longest" testcase
This is a significantly longer, but not the longest "testcase"

Here is an another one -> "Here" is an another one
Here "is" an another one
Here is "an" another one
Here is an "another" one
Here is an another "one"


This is codegolf, so the least byte answer wins!










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
    $endgroup$
    – FryAmTheEggman
    1 hour ago










  • $begingroup$
    @FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
    $endgroup$
    – krinistof
    1 hour ago










  • $begingroup$
    I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
    $endgroup$
    – FryAmTheEggman
    1 hour ago






  • 1




    $begingroup$
    @KGlasier Question updated
    $endgroup$
    – krinistof
    1 hour ago






  • 1




    $begingroup$
    Will there be duplicate words?
    $endgroup$
    – Embodiment of Ignorance
    25 mins ago















1












$begingroup$


Story



Have you seen this post from 9gag?
Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that.



The submission



Your program will get an input string which it will return with quation marks as explained bellow.
Standard loopholes are forbidden. Output as list of lines is allowed. Trailing spaces, empty lines that doesn't break the output are allowed.



The rules of input



The input only contains printable ASCII characters.
The input may contain spaces. The words are determined with them.
If one word is given then the program has to return the string between quation marks.



Example of one word:



test -> "test"


If the input string has 2 or more words then it returns first with the whole input, but the first word in quation, on the second time, all the input but the second word between quation marks and so on.



In general, the program has to return as many lines, as many words are in the input.



Example of three words:



This is codegolf -> "This" is codegolf
This "is" codegolf
This is "codegolf"


The case of no input, or empty string doesn't matter.



Examples:



This is a significantly longer, but not the longest testcase -> "This" is a significantly longer, but not the longest testcase
This "is" a significantly longer, but not the longest testcase
This is "a" significantly longer, but not the longest testcase
This is a "significantly" longer, but not the longest testcase
This is a significantly "longer," but not the longest testcase
This is a significantly longer, "but" not the longest testcase
This is a significantly longer, but "not" the longest testcase
This is a significantly longer, but not "the" longest testcase
This is a significantly longer, but not the "longest" testcase
This is a significantly longer, but not the longest "testcase"

Here is an another one -> "Here" is an another one
Here "is" an another one
Here is "an" another one
Here is an "another" one
Here is an another "one"


This is codegolf, so the least byte answer wins!










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
    $endgroup$
    – FryAmTheEggman
    1 hour ago










  • $begingroup$
    @FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
    $endgroup$
    – krinistof
    1 hour ago










  • $begingroup$
    I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
    $endgroup$
    – FryAmTheEggman
    1 hour ago






  • 1




    $begingroup$
    @KGlasier Question updated
    $endgroup$
    – krinistof
    1 hour ago






  • 1




    $begingroup$
    Will there be duplicate words?
    $endgroup$
    – Embodiment of Ignorance
    25 mins ago













1












1








1





$begingroup$


Story



Have you seen this post from 9gag?
Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that.



The submission



Your program will get an input string which it will return with quation marks as explained bellow.
Standard loopholes are forbidden. Output as list of lines is allowed. Trailing spaces, empty lines that doesn't break the output are allowed.



The rules of input



The input only contains printable ASCII characters.
The input may contain spaces. The words are determined with them.
If one word is given then the program has to return the string between quation marks.



Example of one word:



test -> "test"


If the input string has 2 or more words then it returns first with the whole input, but the first word in quation, on the second time, all the input but the second word between quation marks and so on.



In general, the program has to return as many lines, as many words are in the input.



Example of three words:



This is codegolf -> "This" is codegolf
This "is" codegolf
This is "codegolf"


The case of no input, or empty string doesn't matter.



Examples:



This is a significantly longer, but not the longest testcase -> "This" is a significantly longer, but not the longest testcase
This "is" a significantly longer, but not the longest testcase
This is "a" significantly longer, but not the longest testcase
This is a "significantly" longer, but not the longest testcase
This is a significantly "longer," but not the longest testcase
This is a significantly longer, "but" not the longest testcase
This is a significantly longer, but "not" the longest testcase
This is a significantly longer, but not "the" longest testcase
This is a significantly longer, but not the "longest" testcase
This is a significantly longer, but not the longest "testcase"

Here is an another one -> "Here" is an another one
Here "is" an another one
Here is "an" another one
Here is an "another" one
Here is an another "one"


This is codegolf, so the least byte answer wins!










share|improve this question











$endgroup$




Story



Have you seen this post from 9gag?
Maybe you got the feeling to make your own sentences. But then you realize that you could just golf a script in half an hour, and you will never have to deal time with that.



The submission



Your program will get an input string which it will return with quation marks as explained bellow.
Standard loopholes are forbidden. Output as list of lines is allowed. Trailing spaces, empty lines that doesn't break the output are allowed.



The rules of input



The input only contains printable ASCII characters.
The input may contain spaces. The words are determined with them.
If one word is given then the program has to return the string between quation marks.



Example of one word:



test -> "test"


If the input string has 2 or more words then it returns first with the whole input, but the first word in quation, on the second time, all the input but the second word between quation marks and so on.



In general, the program has to return as many lines, as many words are in the input.



Example of three words:



This is codegolf -> "This" is codegolf
This "is" codegolf
This is "codegolf"


The case of no input, or empty string doesn't matter.



Examples:



This is a significantly longer, but not the longest testcase -> "This" is a significantly longer, but not the longest testcase
This "is" a significantly longer, but not the longest testcase
This is "a" significantly longer, but not the longest testcase
This is a "significantly" longer, but not the longest testcase
This is a significantly "longer," but not the longest testcase
This is a significantly longer, "but" not the longest testcase
This is a significantly longer, but "not" the longest testcase
This is a significantly longer, but not "the" longest testcase
This is a significantly longer, but not the "longest" testcase
This is a significantly longer, but not the longest "testcase"

Here is an another one -> "Here" is an another one
Here "is" an another one
Here is "an" another one
Here is an "another" one
Here is an another "one"


This is codegolf, so the least byte answer wins!







code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago







krinistof

















asked 1 hour ago









krinistofkrinistof

666




666







  • 1




    $begingroup$
    Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
    $endgroup$
    – FryAmTheEggman
    1 hour ago










  • $begingroup$
    @FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
    $endgroup$
    – krinistof
    1 hour ago










  • $begingroup$
    I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
    $endgroup$
    – FryAmTheEggman
    1 hour ago






  • 1




    $begingroup$
    @KGlasier Question updated
    $endgroup$
    – krinistof
    1 hour ago






  • 1




    $begingroup$
    Will there be duplicate words?
    $endgroup$
    – Embodiment of Ignorance
    25 mins ago












  • 1




    $begingroup$
    Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
    $endgroup$
    – FryAmTheEggman
    1 hour ago










  • $begingroup$
    @FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
    $endgroup$
    – krinistof
    1 hour ago










  • $begingroup$
    I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
    $endgroup$
    – FryAmTheEggman
    1 hour ago






  • 1




    $begingroup$
    @KGlasier Question updated
    $endgroup$
    – krinistof
    1 hour ago






  • 1




    $begingroup$
    Will there be duplicate words?
    $endgroup$
    – Embodiment of Ignorance
    25 mins ago







1




1




$begingroup$
Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
$endgroup$
– FryAmTheEggman
1 hour ago




$begingroup$
Unless I missed it, you should specify what a word is and which characters will be in the input. Particularly if you want to include non-ASCII you should have a test case with them (though I assume from what you have that you just want printable ASCII?)
$endgroup$
– FryAmTheEggman
1 hour ago












$begingroup$
@FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
$endgroup$
– krinistof
1 hour ago




$begingroup$
@FryAmTheEggman Word is already defined in The rules of input. ASCII printable added.
$endgroup$
– krinistof
1 hour ago












$begingroup$
I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
$endgroup$
– FryAmTheEggman
1 hour ago




$begingroup$
I don't think your definition of word covers something like "se7en", basically numbers and punctuation in general.
$endgroup$
– FryAmTheEggman
1 hour ago




1




1




$begingroup$
@KGlasier Question updated
$endgroup$
– krinistof
1 hour ago




$begingroup$
@KGlasier Question updated
$endgroup$
– krinistof
1 hour ago




1




1




$begingroup$
Will there be duplicate words?
$endgroup$
– Embodiment of Ignorance
25 mins ago




$begingroup$
Will there be duplicate words?
$endgroup$
– Embodiment of Ignorance
25 mins ago










5 Answers
5






active

oldest

votes


















1












$begingroup$


Retina 0.8.2, 17 bytes



 
" $'¶$` "
^|$
"


Try it online! Link includes test suite. Explanation:



 
" $'¶$` "


Expand each space by duplicating the line and then inserting quotation marks.



^|$
"


Fix the first and last lines.






share|improve this answer









$endgroup$




















    1












    $begingroup$


    PowerShell, 70 65 bytes





    param($a)$a.Split()|%$a-replace[regex]"( 


    Try it online!



    Has test suite in trial. Has 1 leading space on first row, and 1 trailing space on last row. Attempting to refactor.






    share|improve this answer









    $endgroup$




















      1












      $begingroup$


      Charcoal, 19 bytes



      E⪪θ ⪫E⪪θ ⎇⁼κμ⪫""λλ 


      Try it online! Link is to verbose version of code. Note: Trailing space. Explanation:



       θ Input string
      ⪪ Split on literal space
      E Map over words
      θ Input string
      ⪪ Split on literal space
      E Map over words
      μ Inner index
      ⁼ Equals
      κ Outer index
      ⎇ If true then
      "" Literal string `""`
      ⪫ Joined i.e. wrapping
      λ Current word
      λ Otherwise current word
      ⪫ Joined with literal space
      Implicitly print each result on its own line





      share|improve this answer









      $endgroup$




















        0












        $begingroup$


        05AB1E, 14 bytes



        #©v®y…"ÿ"Nǝðý=


        Try it online!






        share|improve this answer









        $endgroup$




















          0












          $begingroup$


          R, 94 bytes



          m=matrix(s<-scan(t=scan(,a<-'"'),w=a),n<-length(s),n)
          diag(m)=paste0(a,s,a)
          cat(rbind(m,"n"))


          Try it online!



          I can't get it to work on TIO yet, because of the scan(scan()) business. On my machine, it takes in e.g. This is codegolf and outputs correctly



          "This" is codegolf 
          This "is" codegolf
          This is "codegolf"


          It uses a matrix format to easily change the diagonal entries. Note that usually, in R code-golf, strings are read in with scan(,""), but any string can be used instead of the empty string as second parameter. Using a (defined as '"') which will also be needed afterwards saves 1 byte.



          Explanation of ungolfed version:



          a <- '"' # string made of a single quote
          s <- scan(t=scan(,a),w=a) # read in input and separate by spaces
          n <- length(s) # number of words
          m = matrix(s, n, n) # fill a matrix, one word per entry, each column corresponds to the whole sentence. The sentence is repeated n times.
          diag(m) = paste0(a, s, a) # replace diagonal entries with the corresponding word surrounded by quotes
          cat(rbind(m,"n")) # add a n at the end of each column, then print column-wise





          share|improve this answer









          $endgroup$













            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "200"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185414%2fas-programers-say-strive-to-be-lazy%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1












            $begingroup$


            Retina 0.8.2, 17 bytes



             
            " $'¶$` "
            ^|$
            "


            Try it online! Link includes test suite. Explanation:



             
            " $'¶$` "


            Expand each space by duplicating the line and then inserting quotation marks.



            ^|$
            "


            Fix the first and last lines.






            share|improve this answer









            $endgroup$

















              1












              $begingroup$


              Retina 0.8.2, 17 bytes



               
              " $'¶$` "
              ^|$
              "


              Try it online! Link includes test suite. Explanation:



               
              " $'¶$` "


              Expand each space by duplicating the line and then inserting quotation marks.



              ^|$
              "


              Fix the first and last lines.






              share|improve this answer









              $endgroup$















                1












                1








                1





                $begingroup$


                Retina 0.8.2, 17 bytes



                 
                " $'¶$` "
                ^|$
                "


                Try it online! Link includes test suite. Explanation:



                 
                " $'¶$` "


                Expand each space by duplicating the line and then inserting quotation marks.



                ^|$
                "


                Fix the first and last lines.






                share|improve this answer









                $endgroup$




                Retina 0.8.2, 17 bytes



                 
                " $'¶$` "
                ^|$
                "


                Try it online! Link includes test suite. Explanation:



                 
                " $'¶$` "


                Expand each space by duplicating the line and then inserting quotation marks.



                ^|$
                "


                Fix the first and last lines.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                NeilNeil

                83.7k845180




                83.7k845180





















                    1












                    $begingroup$


                    PowerShell, 70 65 bytes





                    param($a)$a.Split()|%$a-replace[regex]"( 


                    Try it online!



                    Has test suite in trial. Has 1 leading space on first row, and 1 trailing space on last row. Attempting to refactor.






                    share|improve this answer









                    $endgroup$

















                      1












                      $begingroup$


                      PowerShell, 70 65 bytes





                      param($a)$a.Split()|%$a-replace[regex]"( 


                      Try it online!



                      Has test suite in trial. Has 1 leading space on first row, and 1 trailing space on last row. Attempting to refactor.






                      share|improve this answer









                      $endgroup$















                        1












                        1








                        1





                        $begingroup$


                        PowerShell, 70 65 bytes





                        param($a)$a.Split()|%$a-replace[regex]"( 


                        Try it online!



                        Has test suite in trial. Has 1 leading space on first row, and 1 trailing space on last row. Attempting to refactor.






                        share|improve this answer









                        $endgroup$




                        PowerShell, 70 65 bytes





                        param($a)$a.Split()|%$a-replace[regex]"( 


                        Try it online!



                        Has test suite in trial. Has 1 leading space on first row, and 1 trailing space on last row. Attempting to refactor.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 1 hour ago









                        KGlasierKGlasier

                        2016




                        2016





















                            1












                            $begingroup$


                            Charcoal, 19 bytes



                            E⪪θ ⪫E⪪θ ⎇⁼κμ⪫""λλ 


                            Try it online! Link is to verbose version of code. Note: Trailing space. Explanation:



                             θ Input string
                            ⪪ Split on literal space
                            E Map over words
                            θ Input string
                            ⪪ Split on literal space
                            E Map over words
                            μ Inner index
                            ⁼ Equals
                            κ Outer index
                            ⎇ If true then
                            "" Literal string `""`
                            ⪫ Joined i.e. wrapping
                            λ Current word
                            λ Otherwise current word
                            ⪫ Joined with literal space
                            Implicitly print each result on its own line





                            share|improve this answer









                            $endgroup$

















                              1












                              $begingroup$


                              Charcoal, 19 bytes



                              E⪪θ ⪫E⪪θ ⎇⁼κμ⪫""λλ 


                              Try it online! Link is to verbose version of code. Note: Trailing space. Explanation:



                               θ Input string
                              ⪪ Split on literal space
                              E Map over words
                              θ Input string
                              ⪪ Split on literal space
                              E Map over words
                              μ Inner index
                              ⁼ Equals
                              κ Outer index
                              ⎇ If true then
                              "" Literal string `""`
                              ⪫ Joined i.e. wrapping
                              λ Current word
                              λ Otherwise current word
                              ⪫ Joined with literal space
                              Implicitly print each result on its own line





                              share|improve this answer









                              $endgroup$















                                1












                                1








                                1





                                $begingroup$


                                Charcoal, 19 bytes



                                E⪪θ ⪫E⪪θ ⎇⁼κμ⪫""λλ 


                                Try it online! Link is to verbose version of code. Note: Trailing space. Explanation:



                                 θ Input string
                                ⪪ Split on literal space
                                E Map over words
                                θ Input string
                                ⪪ Split on literal space
                                E Map over words
                                μ Inner index
                                ⁼ Equals
                                κ Outer index
                                ⎇ If true then
                                "" Literal string `""`
                                ⪫ Joined i.e. wrapping
                                λ Current word
                                λ Otherwise current word
                                ⪫ Joined with literal space
                                Implicitly print each result on its own line





                                share|improve this answer









                                $endgroup$




                                Charcoal, 19 bytes



                                E⪪θ ⪫E⪪θ ⎇⁼κμ⪫""λλ 


                                Try it online! Link is to verbose version of code. Note: Trailing space. Explanation:



                                 θ Input string
                                ⪪ Split on literal space
                                E Map over words
                                θ Input string
                                ⪪ Split on literal space
                                E Map over words
                                μ Inner index
                                ⁼ Equals
                                κ Outer index
                                ⎇ If true then
                                "" Literal string `""`
                                ⪫ Joined i.e. wrapping
                                λ Current word
                                λ Otherwise current word
                                ⪫ Joined with literal space
                                Implicitly print each result on its own line






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 1 hour ago









                                NeilNeil

                                83.7k845180




                                83.7k845180





















                                    0












                                    $begingroup$


                                    05AB1E, 14 bytes



                                    #©v®y…"ÿ"Nǝðý=


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$

















                                      0












                                      $begingroup$


                                      05AB1E, 14 bytes



                                      #©v®y…"ÿ"Nǝðý=


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$















                                        0












                                        0








                                        0





                                        $begingroup$


                                        05AB1E, 14 bytes



                                        #©v®y…"ÿ"Nǝðý=


                                        Try it online!






                                        share|improve this answer









                                        $endgroup$




                                        05AB1E, 14 bytes



                                        #©v®y…"ÿ"Nǝðý=


                                        Try it online!







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 24 mins ago









                                        Magic Octopus UrnMagic Octopus Urn

                                        13k444126




                                        13k444126





















                                            0












                                            $begingroup$


                                            R, 94 bytes



                                            m=matrix(s<-scan(t=scan(,a<-'"'),w=a),n<-length(s),n)
                                            diag(m)=paste0(a,s,a)
                                            cat(rbind(m,"n"))


                                            Try it online!



                                            I can't get it to work on TIO yet, because of the scan(scan()) business. On my machine, it takes in e.g. This is codegolf and outputs correctly



                                            "This" is codegolf 
                                            This "is" codegolf
                                            This is "codegolf"


                                            It uses a matrix format to easily change the diagonal entries. Note that usually, in R code-golf, strings are read in with scan(,""), but any string can be used instead of the empty string as second parameter. Using a (defined as '"') which will also be needed afterwards saves 1 byte.



                                            Explanation of ungolfed version:



                                            a <- '"' # string made of a single quote
                                            s <- scan(t=scan(,a),w=a) # read in input and separate by spaces
                                            n <- length(s) # number of words
                                            m = matrix(s, n, n) # fill a matrix, one word per entry, each column corresponds to the whole sentence. The sentence is repeated n times.
                                            diag(m) = paste0(a, s, a) # replace diagonal entries with the corresponding word surrounded by quotes
                                            cat(rbind(m,"n")) # add a n at the end of each column, then print column-wise





                                            share|improve this answer









                                            $endgroup$

















                                              0












                                              $begingroup$


                                              R, 94 bytes



                                              m=matrix(s<-scan(t=scan(,a<-'"'),w=a),n<-length(s),n)
                                              diag(m)=paste0(a,s,a)
                                              cat(rbind(m,"n"))


                                              Try it online!



                                              I can't get it to work on TIO yet, because of the scan(scan()) business. On my machine, it takes in e.g. This is codegolf and outputs correctly



                                              "This" is codegolf 
                                              This "is" codegolf
                                              This is "codegolf"


                                              It uses a matrix format to easily change the diagonal entries. Note that usually, in R code-golf, strings are read in with scan(,""), but any string can be used instead of the empty string as second parameter. Using a (defined as '"') which will also be needed afterwards saves 1 byte.



                                              Explanation of ungolfed version:



                                              a <- '"' # string made of a single quote
                                              s <- scan(t=scan(,a),w=a) # read in input and separate by spaces
                                              n <- length(s) # number of words
                                              m = matrix(s, n, n) # fill a matrix, one word per entry, each column corresponds to the whole sentence. The sentence is repeated n times.
                                              diag(m) = paste0(a, s, a) # replace diagonal entries with the corresponding word surrounded by quotes
                                              cat(rbind(m,"n")) # add a n at the end of each column, then print column-wise





                                              share|improve this answer









                                              $endgroup$















                                                0












                                                0








                                                0





                                                $begingroup$


                                                R, 94 bytes



                                                m=matrix(s<-scan(t=scan(,a<-'"'),w=a),n<-length(s),n)
                                                diag(m)=paste0(a,s,a)
                                                cat(rbind(m,"n"))


                                                Try it online!



                                                I can't get it to work on TIO yet, because of the scan(scan()) business. On my machine, it takes in e.g. This is codegolf and outputs correctly



                                                "This" is codegolf 
                                                This "is" codegolf
                                                This is "codegolf"


                                                It uses a matrix format to easily change the diagonal entries. Note that usually, in R code-golf, strings are read in with scan(,""), but any string can be used instead of the empty string as second parameter. Using a (defined as '"') which will also be needed afterwards saves 1 byte.



                                                Explanation of ungolfed version:



                                                a <- '"' # string made of a single quote
                                                s <- scan(t=scan(,a),w=a) # read in input and separate by spaces
                                                n <- length(s) # number of words
                                                m = matrix(s, n, n) # fill a matrix, one word per entry, each column corresponds to the whole sentence. The sentence is repeated n times.
                                                diag(m) = paste0(a, s, a) # replace diagonal entries with the corresponding word surrounded by quotes
                                                cat(rbind(m,"n")) # add a n at the end of each column, then print column-wise





                                                share|improve this answer









                                                $endgroup$




                                                R, 94 bytes



                                                m=matrix(s<-scan(t=scan(,a<-'"'),w=a),n<-length(s),n)
                                                diag(m)=paste0(a,s,a)
                                                cat(rbind(m,"n"))


                                                Try it online!



                                                I can't get it to work on TIO yet, because of the scan(scan()) business. On my machine, it takes in e.g. This is codegolf and outputs correctly



                                                "This" is codegolf 
                                                This "is" codegolf
                                                This is "codegolf"


                                                It uses a matrix format to easily change the diagonal entries. Note that usually, in R code-golf, strings are read in with scan(,""), but any string can be used instead of the empty string as second parameter. Using a (defined as '"') which will also be needed afterwards saves 1 byte.



                                                Explanation of ungolfed version:



                                                a <- '"' # string made of a single quote
                                                s <- scan(t=scan(,a),w=a) # read in input and separate by spaces
                                                n <- length(s) # number of words
                                                m = matrix(s, n, n) # fill a matrix, one word per entry, each column corresponds to the whole sentence. The sentence is repeated n times.
                                                diag(m) = paste0(a, s, a) # replace diagonal entries with the corresponding word surrounded by quotes
                                                cat(rbind(m,"n")) # add a n at the end of each column, then print column-wise






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 11 mins ago









                                                Robin RyderRobin Ryder

                                                1,109114




                                                1,109114



























                                                    draft saved

                                                    draft discarded
















































                                                    If this is an answer to a challenge…



                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                    More generally…



                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185414%2fas-programers-say-strive-to-be-lazy%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Siegen Nawigatsjuun

                                                    Log på Navigationsmenu

                                                    Log på Navigationsmenu