Outline words with their letters









up vote
14
down vote

favorite












For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces:



 oooooo 
onnnno
on -> on no
onnnno
oooooo


Task:



Given a list of words, consisting only of lowercase and/or uppercase English letters, outline each word and display all the resulting blocks next to each other horizontally, separated by a column of single space, vertically aligned at the centers of the blocks.



You can write a full program, or a function.



Input:



A list of words, or if you prefer - a space- or other symbol- delimited string



Output:



The ASCII representation of the blocks for the outlined words. Leading/trailing
whitespaces are permitted.



Test cases:



Input 1: ["code", "golf"] (or "code golf")
Output 1:

cccccccccccc gggggggggggg
cooooooooooc goooooooooog
coddddddddoc gollllllllog
codeeeeeedoc golfffffflog
code edoc golf flog
codeeeeeedoc golfffffflog
coddddddddoc gollllllllog
cooooooooooc goooooooooog
cccccccccccc gggggggggggg

Input 2: ["I", "am", "just", "a", "man"] (or "I am just a man")
Output 2:

jjjjjjjjjjjj
juuuuuuuuuuj mmmmmmmmm
aaaaaa jussssssssuj maaaaaaam
III ammmma justtttttsuj aaa mannnnnam
I I am ma just tsuj a a man nam
III ammmma justtttttsuj aaa mannnnnam
aaaaaa jussssssssuj maaaaaaam
juuuuuuuuuuj mmmmmmmmm
jjjjjjjjjjjj


Winning criteria:



The shortest code in bytes in each language wins. I will greatly appreciate if you comment/explain your code and approach.










share|improve this question





















  • Can we assume there is at least one word?
    – Pietu1998
    Nov 11 at 12:32










  • @Pietu1998 Yes, there always be at least one word
    – Galen Ivanov
    Nov 11 at 14:45






  • 1




    @Kevin Cruijssen Transpose?
    – Galen Ivanov
    Nov 13 at 18:34














up vote
14
down vote

favorite












For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces:



 oooooo 
onnnno
on -> on no
onnnno
oooooo


Task:



Given a list of words, consisting only of lowercase and/or uppercase English letters, outline each word and display all the resulting blocks next to each other horizontally, separated by a column of single space, vertically aligned at the centers of the blocks.



You can write a full program, or a function.



Input:



A list of words, or if you prefer - a space- or other symbol- delimited string



Output:



The ASCII representation of the blocks for the outlined words. Leading/trailing
whitespaces are permitted.



Test cases:



Input 1: ["code", "golf"] (or "code golf")
Output 1:

cccccccccccc gggggggggggg
cooooooooooc goooooooooog
coddddddddoc gollllllllog
codeeeeeedoc golfffffflog
code edoc golf flog
codeeeeeedoc golfffffflog
coddddddddoc gollllllllog
cooooooooooc goooooooooog
cccccccccccc gggggggggggg

Input 2: ["I", "am", "just", "a", "man"] (or "I am just a man")
Output 2:

jjjjjjjjjjjj
juuuuuuuuuuj mmmmmmmmm
aaaaaa jussssssssuj maaaaaaam
III ammmma justtttttsuj aaa mannnnnam
I I am ma just tsuj a a man nam
III ammmma justtttttsuj aaa mannnnnam
aaaaaa jussssssssuj maaaaaaam
juuuuuuuuuuj mmmmmmmmm
jjjjjjjjjjjj


Winning criteria:



The shortest code in bytes in each language wins. I will greatly appreciate if you comment/explain your code and approach.










share|improve this question





















  • Can we assume there is at least one word?
    – Pietu1998
    Nov 11 at 12:32










  • @Pietu1998 Yes, there always be at least one word
    – Galen Ivanov
    Nov 11 at 14:45






  • 1




    @Kevin Cruijssen Transpose?
    – Galen Ivanov
    Nov 13 at 18:34












up vote
14
down vote

favorite









up vote
14
down vote

favorite











For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces:



 oooooo 
onnnno
on -> on no
onnnno
oooooo


Task:



Given a list of words, consisting only of lowercase and/or uppercase English letters, outline each word and display all the resulting blocks next to each other horizontally, separated by a column of single space, vertically aligned at the centers of the blocks.



You can write a full program, or a function.



Input:



A list of words, or if you prefer - a space- or other symbol- delimited string



Output:



The ASCII representation of the blocks for the outlined words. Leading/trailing
whitespaces are permitted.



Test cases:



Input 1: ["code", "golf"] (or "code golf")
Output 1:

cccccccccccc gggggggggggg
cooooooooooc goooooooooog
coddddddddoc gollllllllog
codeeeeeedoc golfffffflog
code edoc golf flog
codeeeeeedoc golfffffflog
coddddddddoc gollllllllog
cooooooooooc goooooooooog
cccccccccccc gggggggggggg

Input 2: ["I", "am", "just", "a", "man"] (or "I am just a man")
Output 2:

jjjjjjjjjjjj
juuuuuuuuuuj mmmmmmmmm
aaaaaa jussssssssuj maaaaaaam
III ammmma justtttttsuj aaa mannnnnam
I I am ma just tsuj a a man nam
III ammmma justtttttsuj aaa mannnnnam
aaaaaa jussssssssuj maaaaaaam
juuuuuuuuuuj mmmmmmmmm
jjjjjjjjjjjj


Winning criteria:



The shortest code in bytes in each language wins. I will greatly appreciate if you comment/explain your code and approach.










share|improve this question













For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces:



 oooooo 
onnnno
on -> on no
onnnno
oooooo


Task:



Given a list of words, consisting only of lowercase and/or uppercase English letters, outline each word and display all the resulting blocks next to each other horizontally, separated by a column of single space, vertically aligned at the centers of the blocks.



You can write a full program, or a function.



Input:



A list of words, or if you prefer - a space- or other symbol- delimited string



Output:



The ASCII representation of the blocks for the outlined words. Leading/trailing
whitespaces are permitted.



Test cases:



Input 1: ["code", "golf"] (or "code golf")
Output 1:

cccccccccccc gggggggggggg
cooooooooooc goooooooooog
coddddddddoc gollllllllog
codeeeeeedoc golfffffflog
code edoc golf flog
codeeeeeedoc golfffffflog
coddddddddoc gollllllllog
cooooooooooc goooooooooog
cccccccccccc gggggggggggg

Input 2: ["I", "am", "just", "a", "man"] (or "I am just a man")
Output 2:

jjjjjjjjjjjj
juuuuuuuuuuj mmmmmmmmm
aaaaaa jussssssssuj maaaaaaam
III ammmma justtttttsuj aaa mannnnnam
I I am ma just tsuj a a man nam
III ammmma justtttttsuj aaa mannnnnam
aaaaaa jussssssssuj maaaaaaam
juuuuuuuuuuj mmmmmmmmm
jjjjjjjjjjjj


Winning criteria:



The shortest code in bytes in each language wins. I will greatly appreciate if you comment/explain your code and approach.







code-golf ascii-art






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 8:48









Galen Ivanov

6,01211032




6,01211032











  • Can we assume there is at least one word?
    – Pietu1998
    Nov 11 at 12:32










  • @Pietu1998 Yes, there always be at least one word
    – Galen Ivanov
    Nov 11 at 14:45






  • 1




    @Kevin Cruijssen Transpose?
    – Galen Ivanov
    Nov 13 at 18:34
















  • Can we assume there is at least one word?
    – Pietu1998
    Nov 11 at 12:32










  • @Pietu1998 Yes, there always be at least one word
    – Galen Ivanov
    Nov 11 at 14:45






  • 1




    @Kevin Cruijssen Transpose?
    – Galen Ivanov
    Nov 13 at 18:34















Can we assume there is at least one word?
– Pietu1998
Nov 11 at 12:32




Can we assume there is at least one word?
– Pietu1998
Nov 11 at 12:32












@Pietu1998 Yes, there always be at least one word
– Galen Ivanov
Nov 11 at 14:45




@Pietu1998 Yes, there always be at least one word
– Galen Ivanov
Nov 11 at 14:45




1




1




@Kevin Cruijssen Transpose?
– Galen Ivanov
Nov 13 at 18:34




@Kevin Cruijssen Transpose?
– Galen Ivanov
Nov 13 at 18:34










8 Answers
8






active

oldest

votes

















up vote
7
down vote














Canvas, 22 20 bytes



l *;±21*{;l└*e⟳} ]r⤢


Try it here!



Explanation:



improve this answer





















    share|improve this answer






















      Your Answer





      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
      );
      );
      , "mathjax-editing");

      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',
      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%2f175694%2foutline-words-with-their-letters%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      8 Answers
      8






      active

      oldest

      votes








      8 Answers
      8






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      7
      down vote














      Canvas, 22 20 bytes



      l *;±21*{;l└*e⟳} ]r⤢


      Try it here!



      Explanation:



       ] map over the inputs
      l * array of length spaces - the canvas of the current word
      ; get the word back on top
      ± reverse it
      21* repeat each character twice
      for each character
      ;l└ push the height of the item below (the canvas)
      * repeat the character that many times vertically
      e and encase the canvas in that char column
      ⟳ and rotate it clockwise for encasing the next time
      ∙ push another space as the separator of words
      r center the words
      ⤢ and transpose the final output (as everything was built vertically)





      share # Close outer map
      ¶« # Append a newline after each (for the space delimiters)
      » # Join everything by newlines
      .C # Centralize it horizontally
      # (too bad a centralize vertically isn't available..)
      .B # Split on newlines again
      €S # Convert each line to a list of characters
      ζ # Zip, swapping rows/columns (with space filler by default)
      J # Join the loose characters of every line to a string again
      » # Join the lines by newlines (and output implicitly)





      share|improve this answer


























        up vote
        1
        down vote














        05AB1E, 46 bytes



        εg©;ò<Uyη央∍«®>∍}y𫩪®Xиª˜».º.∊}¶«».C.B€SζJ»


        Not too happy about it, but I'm glad it's working.



        Try it online or verify all test cases.



        Explanation:





        ε # Map `y` over the (implicit) input-list
        g # Take the length of the current item
        © # Store it in the register (without popping)
        ; # Halve it
        ò # Ceil and cast to integer at the same time
        < # Decrease it by 1
        U # Pop and store it in variable `X`
        yη # Take the prefixes of the current string `y`
        ε } # Map over these prefixes:
        ¤ # Take the last character of the string
        ®× # Increase it to a size equal to the length from the register
        « # Append it to the current prefix
        ®> # Take the length from the register, and add 1
        ∍ # Shorten the string to that size
        y # Push the string `y` again
        ð« # Append a space
        © # Store it in the register (without popping)
        ª # Append it at the end of the list of modified prefixes
        ® # Push the string with space from the register again
        Xи # Repeat it `X` amount of times
        ª # Append them to the list
        ˜ # Flatten to remove the empty appended list if `X` was 0
        » # Join by newlines
        .º.∊ # Intersect mirror both horizontally and vertically
        } # Close outer map
        ¶« # Append a newline after each (for the space delimiters)
        » # Join everything by newlines
        .C # Centralize it horizontally
        # (too bad a centralize vertically isn't available..)
        .B # Split on newlines again
        €S # Convert each line to a list of characters
        ζ # Zip, swapping rows/columns (with space filler by default)
        J # Join the loose characters of every line to a string again
        » # Join the lines by newlines (and output implicitly)





        share|improve this answer
























          up vote
          1
          down vote










          up vote
          1
          down vote










          05AB1E, 46 bytes



          εg©;ò<Uyη央∍«®>∍}y𫩪®Xиª˜».º.∊}¶«».C.B€SζJ»


          Not too happy about it, but I'm glad it's working.



          Try it online or verify all test cases.



          Explanation:





          ε # Map `y` over the (implicit) input-list
          g # Take the length of the current item
          © # Store it in the register (without popping)
          ; # Halve it
          ò # Ceil and cast to integer at the same time
          < # Decrease it by 1
          U # Pop and store it in variable `X`
          yη # Take the prefixes of the current string `y`
          ε } # Map over these prefixes:
          ¤ # Take the last character of the string
          ®× # Increase it to a size equal to the length from the register
          « # Append it to the current prefix
          ®> # Take the length from the register, and add 1
          ∍ # Shorten the string to that size
          y # Push the string `y` again
          ð« # Append a space
          © # Store it in the register (without popping)
          ª # Append it at the end of the list of modified prefixes
          ® # Push the string with space from the register again
          Xи # Repeat it `X` amount of times
          ª # Append them to the list
          ˜ # Flatten to remove the empty appended list if `X` was 0
          » # Join by newlines
          .º.∊ # Intersect mirror both horizontally and vertically
          } # Close outer map
          ¶« # Append a newline after each (for the space delimiters)
          » # Join everything by newlines
          .C # Centralize it horizontally
          # (too bad a centralize vertically isn't available..)
          .B # Split on newlines again
          €S # Convert each line to a list of characters
          ζ # Zip, swapping rows/columns (with space filler by default)
          J # Join the loose characters of every line to a string again
          » # Join the lines by newlines (and output implicitly)





          share|improve this answer















          05AB1E, 46 bytes



          εg©;ò<Uyη央∍«®>∍}y𫩪®Xиª˜».º.∊}¶«».C.B€SζJ»


          Not too happy about it, but I'm glad it's working.



          Try it online or verify all test cases.



          Explanation:





          ε # Map `y` over the (implicit) input-list
          g # Take the length of the current item
          © # Store it in the register (without popping)
          ; # Halve it
          ò # Ceil and cast to integer at the same time
          < # Decrease it by 1
          U # Pop and store it in variable `X`
          yη # Take the prefixes of the current string `y`
          ε } # Map over these prefixes:
          ¤ # Take the last character of the string
          ®× # Increase it to a size equal to the length from the register
          « # Append it to the current prefix
          ®> # Take the length from the register, and add 1
          ∍ # Shorten the string to that size
          y # Push the string `y` again
          ð« # Append a space
          © # Store it in the register (without popping)
          ª # Append it at the end of the list of modified prefixes
          ® # Push the string with space from the register again
          Xи # Repeat it `X` amount of times
          ª # Append them to the list
          ˜ # Flatten to remove the empty appended list if `X` was 0
          » # Join by newlines
          .º.∊ # Intersect mirror both horizontally and vertically
          } # Close outer map
          ¶« # Append a newline after each (for the space delimiters)
          » # Join everything by newlines
          .C # Centralize it horizontally
          # (too bad a centralize vertically isn't available..)
          .B # Split on newlines again
          €S # Convert each line to a list of characters
          ζ # Zip, swapping rows/columns (with space filler by default)
          J # Join the loose characters of every line to a string again
          » # Join the lines by newlines (and output implicitly)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 at 11:07

























          answered Nov 14 at 10:20









          Kevin Cruijssen

          34.9k554184




          34.9k554184



























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





              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


              Please pay close attention to the following guidance:


              • Please be sure to answer the question. Provide details and share your research!

              But avoid


              • Asking for help, clarification, or responding to other answers.

              • Making statements based on opinion; back them up with references or personal experience.

              To learn more, see our tips on writing great answers.




              draft saved


              draft discarded














              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175694%2foutline-words-with-their-letters%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

              27

              Top Tejano songwriter Luis Silva dead of heart attack at 64

              Category:Rhetoric