It took me a lot of time to make this, pls like. (YouTube Comments #1)Tips for golfing in PythonSpell out the...

Where was Karl Mordo in Infinity War?

How do I make a gun alignment to camera matrix in OpenGL GLSL?

What do these brackets mean?

By American Standards

For Loop and Sum

Is the theory of the category of topological spaces computable?

Avoiding morning and evening handshakes

How do you enable SQL Server 2019's result set caching?

Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?

Wanted: 5.25 floppy to usb adapter

Is 45 min enough time to catch my next flight

Do objects in the public view need licencing?

How would an AI self awareness kill switch work?

Linux File Manager: Restore previous open session (folders and tab)

If I delete my router's history can my ISP still provide it to my parents?

Could be quantum mechanics necessary to analyze some biology scenarios?

Metadata API deployments are failing in Spring '19

Emit zero-width bash prompt sequence from external binary

Table enclosed in curly brackets

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

How can I introduce myself to a party without saying that I am a rogue?

Eww, those bytes are gross



It took me a lot of time to make this, pls like. (YouTube Comments #1)


Tips for golfing in PythonSpell out the Revu'acrossed out 44 is still regular 44 ;(Interpret /// (pronounced 'slashes')Do you want to code a snowman?Generate fractals from bit patterns in ASCII“Hello world” that creates a different “Hello world” programCount common Game of Life patternsGeneralization of abbreviationsDraw an indexed fractalUniversal Spooky Meme TranslatorFigure Out the Android Lock PatternOne more LUL and I'm out













64












$begingroup$


Hold up..... this isn't trolling.





Background



These days on YouTube, comment sections are littered with such patterns:



S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S


where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like or something, and often the OP succeeds in amassing a number of likes.





The Task



Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.



Simply put, your task is to take a string, say s, and output 2*s.length - 1 substrings of s, delimited by a newline, so as to comply with the following pattern:



(for s = "Hello")



H
He
Hel
Hell
Hello
Hell
Hel
He
H




Input



A single string s. Input defaults of the community apply.





Output



Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.





Test Case



A multi-word test case:



Input => "Oh yeah yeah"

Output =>

O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O


Note that there are apparent distortions in the above test case's output's shape (for instance, line two and line three of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.





Winning Criterion



This is code-golf, so the shortest code in bytes in each language wins!










share|improve this question











$endgroup$








  • 16




    $begingroup$
    I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
    $endgroup$
    – Arjun
    Feb 27 at 10:31






  • 1




    $begingroup$
    Is returning a array of lines allowed?
    $endgroup$
    – someone
    Feb 27 at 11:00






  • 2




    $begingroup$
    Can we take input as an array of characters and return an array of arrays of characters?
    $endgroup$
    – Shaggy
    Feb 27 at 11:43






  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    Feb 27 at 15:49






  • 3




    $begingroup$
    Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
    $endgroup$
    – AdmBorkBork
    Feb 27 at 20:41
















64












$begingroup$


Hold up..... this isn't trolling.





Background



These days on YouTube, comment sections are littered with such patterns:



S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S


where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like or something, and often the OP succeeds in amassing a number of likes.





The Task



Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.



Simply put, your task is to take a string, say s, and output 2*s.length - 1 substrings of s, delimited by a newline, so as to comply with the following pattern:



(for s = "Hello")



H
He
Hel
Hell
Hello
Hell
Hel
He
H




Input



A single string s. Input defaults of the community apply.





Output



Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.





Test Case



A multi-word test case:



Input => "Oh yeah yeah"

Output =>

O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O


Note that there are apparent distortions in the above test case's output's shape (for instance, line two and line three of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.





Winning Criterion



This is code-golf, so the shortest code in bytes in each language wins!










share|improve this question











$endgroup$








  • 16




    $begingroup$
    I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
    $endgroup$
    – Arjun
    Feb 27 at 10:31






  • 1




    $begingroup$
    Is returning a array of lines allowed?
    $endgroup$
    – someone
    Feb 27 at 11:00






  • 2




    $begingroup$
    Can we take input as an array of characters and return an array of arrays of characters?
    $endgroup$
    – Shaggy
    Feb 27 at 11:43






  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    Feb 27 at 15:49






  • 3




    $begingroup$
    Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
    $endgroup$
    – AdmBorkBork
    Feb 27 at 20:41














64












64








64


3



$begingroup$


Hold up..... this isn't trolling.





Background



These days on YouTube, comment sections are littered with such patterns:



S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S


where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like or something, and often the OP succeeds in amassing a number of likes.





The Task



Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.



Simply put, your task is to take a string, say s, and output 2*s.length - 1 substrings of s, delimited by a newline, so as to comply with the following pattern:



(for s = "Hello")



H
He
Hel
Hell
Hello
Hell
Hel
He
H




Input



A single string s. Input defaults of the community apply.





Output



Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.





Test Case



A multi-word test case:



Input => "Oh yeah yeah"

Output =>

O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O


Note that there are apparent distortions in the above test case's output's shape (for instance, line two and line three of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.





Winning Criterion



This is code-golf, so the shortest code in bytes in each language wins!










share|improve this question











$endgroup$




Hold up..... this isn't trolling.





Background



These days on YouTube, comment sections are littered with such patterns:



S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S


where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like or something, and often the OP succeeds in amassing a number of likes.





The Task



Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.



Simply put, your task is to take a string, say s, and output 2*s.length - 1 substrings of s, delimited by a newline, so as to comply with the following pattern:



(for s = "Hello")



H
He
Hel
Hell
Hello
Hell
Hel
He
H




Input



A single string s. Input defaults of the community apply.





Output



Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.





Test Case



A multi-word test case:



Input => "Oh yeah yeah"

Output =>

O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O


Note that there are apparent distortions in the above test case's output's shape (for instance, line two and line three of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.





Winning Criterion



This is code-golf, so the shortest code in bytes in each language wins!







code-golf string ascii-art






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 28 at 21:48









Russell McMahon

1032




1032










asked Feb 27 at 10:29









ArjunArjun

2,95811651




2,95811651








  • 16




    $begingroup$
    I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
    $endgroup$
    – Arjun
    Feb 27 at 10:31






  • 1




    $begingroup$
    Is returning a array of lines allowed?
    $endgroup$
    – someone
    Feb 27 at 11:00






  • 2




    $begingroup$
    Can we take input as an array of characters and return an array of arrays of characters?
    $endgroup$
    – Shaggy
    Feb 27 at 11:43






  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    Feb 27 at 15:49






  • 3




    $begingroup$
    Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
    $endgroup$
    – AdmBorkBork
    Feb 27 at 20:41














  • 16




    $begingroup$
    I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
    $endgroup$
    – Arjun
    Feb 27 at 10:31






  • 1




    $begingroup$
    Is returning a array of lines allowed?
    $endgroup$
    – someone
    Feb 27 at 11:00






  • 2




    $begingroup$
    Can we take input as an array of characters and return an array of arrays of characters?
    $endgroup$
    – Shaggy
    Feb 27 at 11:43






  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    Feb 27 at 15:49






  • 3




    $begingroup$
    Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
    $endgroup$
    – AdmBorkBork
    Feb 27 at 20:41








16




16




$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
$endgroup$
– Arjun
Feb 27 at 10:31




$begingroup$
I am planning to make some more YouTube comments related challenges in the future; hence the YouTube Comments #1 in the title.
$endgroup$
– Arjun
Feb 27 at 10:31




1




1




$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
Feb 27 at 11:00




$begingroup$
Is returning a array of lines allowed?
$endgroup$
– someone
Feb 27 at 11:00




2




2




$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
Feb 27 at 11:43




$begingroup$
Can we take input as an array of characters and return an array of arrays of characters?
$endgroup$
– Shaggy
Feb 27 at 11:43




3




3




$begingroup$
Closely related
$endgroup$
– Giuseppe
Feb 27 at 15:49




$begingroup$
Closely related
$endgroup$
– Giuseppe
Feb 27 at 15:49




3




3




$begingroup$
Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
$endgroup$
– AdmBorkBork
Feb 27 at 20:41




$begingroup$
Can the input be ""? What about a single character like "H"? If so, what should be the output for both of those cases?
$endgroup$
– AdmBorkBork
Feb 27 at 20:41










58 Answers
58






active

oldest

votes













1 2
next












67












$begingroup$


brainfuck, 32 bytes



,[[<]>[.>]++++++++++.,[>>]<[-]<]


Try it online!



The same loop is used for both halves of the pattern.



Explanation:



,             Take first input character as initial line
[ Until line to output is empty:
[<]> Move to beginning of line
[.>] Output all characters in line
++++++++++. Output newline
, Input next character
[>>] Move two cells right if input character nonzero
<[-] Otherwise remove last character in line
< Move to new last character in line
]





share|improve this answer











$endgroup$









  • 1




    $begingroup$
    That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
    $endgroup$
    – ElPedro
    Feb 27 at 22:09








  • 20




    $begingroup$
    Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
    $endgroup$
    – Question Marks
    Feb 28 at 18:01



















41












$begingroup$

JavaScript (ES6), 36 bytes





f=([c,...r],s=`
`)=>c?s+f(r,s+c)+s:s


Try it online!



Commented



f = (             // f is a recursive function taking:
// the input string split into:
[c, // c = next character (may be undefined if we've reached the end)
...r], // r[] = array of remaining characters
s = `n` // the output string s, initialized to a linefeed
) => //
c ? // if c is defined:
s + // append s (top of the ASCII art)
f(r, s + c) + // append the result of a recursive call to f, using r[] and s + c
s // append s again (bottom of the ASCII art)
: // else:
s // append s just once (this is the final middle row) and stop recursion





share|improve this answer











$endgroup$









  • 2




    $begingroup$
    very nice answer :D
    $endgroup$
    – lois6b
    Feb 27 at 15:38








  • 9




    $begingroup$
    @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
    $endgroup$
    – Arnauld
    Feb 27 at 17:00






  • 2




    $begingroup$
    Awesome! Can you write an explanation for this for those who are complete newbies to JS?
    $endgroup$
    – Akhoy
    2 days ago






  • 2




    $begingroup$
    @Akhoy I've added a commented version.
    $endgroup$
    – Arnauld
    2 days ago






  • 3




    $begingroup$
    Thank you. A lot clearer now.
    $endgroup$
    – Akhoy
    2 days ago



















37












$begingroup$


05AB1E (legacy),  4  3 bytes



Crossed out &nbsp;4&nbsp; is no longer 4 :)



η.∊


Try it online or verify all test cases.



Explanation:





η     # Get the prefixes of the (implicit) input-string
.∊ # Vertically mirror everything with the last line overlapping
# (which implicitly joins by newlines in the legacy version of 05AB1E)
# (and output the result implicitly)


In the new version of 05AB1E, and explicit » is required after the η, which is why I use the legacy version of 05AB1E here to save a byte.






share|improve this answer











$endgroup$









  • 7




    $begingroup$
    Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
    $endgroup$
    – rubenvb
    Feb 28 at 17:22






  • 9




    $begingroup$
    @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
    $endgroup$
    – Kevin Cruijssen
    Feb 28 at 17:30












  • $begingroup$
    All right, fair enough :).
    $endgroup$
    – rubenvb
    Feb 28 at 17:31










  • $begingroup$
    @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
    $endgroup$
    – hanshenrik
    yesterday






  • 4




    $begingroup$
    @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
    $endgroup$
    – Adnan
    yesterday



















16












$begingroup$


Python 2, 60 52 bytes





f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]


Try it online!




Python 3.8 (pre-release), 50 bytes





f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]


Try it online!






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    Does this depend on a forthcoming feature of 3.8? Which feature?
    $endgroup$
    – alexis
    Feb 27 at 17:58






  • 5




    $begingroup$
    @alexis This is using an assignment expression: x:=s[:n].
    $endgroup$
    – Arnauld
    Feb 27 at 19:35








  • 1




    $begingroup$
    Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
    $endgroup$
    – alexis
    Feb 28 at 7:37












  • $begingroup$
    These don't print the output though. They just make the array, right?
    $endgroup$
    – Jaden Travnik
    7 hours ago



















14












$begingroup$


J, 11 bytes



Anonymous tacit prefix function. Returns a space-padded character matrix.



[:(}:,|.)]


Try it online!



] the list of prefixes



[:() apply the following function to that list



|. the reverse list



, prepended with



}: the curtailed (without last item) list






share|improve this answer











$endgroup$









  • 11




    $begingroup$
    [:( and }:,| look so sad…
    $endgroup$
    – Adám
    Feb 27 at 11:57



















10












$begingroup$


Perl 6, 31 bytes





{[~](@_)[0...@_-1...0]}o*.comb


Try it online!



Anonymous code block that takes a string and returns a list of lines.






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    It's funny that these days even golfed Perl is among the most readable contestants.
    $endgroup$
    – ceased to turn counterclockwis
    2 days ago






  • 3




    $begingroup$
    @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
    $endgroup$
    – Jo King
    2 days ago



















10












$begingroup$


MATL, 8 bytes



nZv"G@:)


Try it online!



Please like this post for the smiley :) in the code it took me a lot of time to make.



n  % Length of the input string
Zv % Symmetric range ([1 2 ... n ... 1])
" % For each k in above range
G % Push input
@: % Push [1 2 ... k]
) % Index





share|improve this answer









$endgroup$





















    9












    $begingroup$

    Haskell, 57 bytes



    import Data.List
    unlines.((++)<*>tail.reverse).tail.inits





    share|improve this answer










    New contributor




    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






    $endgroup$













    • $begingroup$
      Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
      $endgroup$
      – Sriotchilism O'Zaic
      Feb 27 at 21:16










    • $begingroup$
      @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
      $endgroup$
      – Joseph Sible
      Feb 27 at 22:04






    • 3




      $begingroup$
      Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
      $endgroup$
      – Sriotchilism O'Zaic
      Feb 27 at 22:21






    • 1




      $begingroup$
      I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
      $endgroup$
      – Axman6
      Feb 28 at 5:05





















    9












    $begingroup$


    Japt -R, 4 bytes



    å+ ê


    Cumulative reduce on a string.



    -1 byte thanks to @Shaggy



    Try it online!






    share|improve this answer











    $endgroup$













    • $begingroup$
      Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
      $endgroup$
      – Flying Thunder
      Feb 27 at 14:58






    • 3




      $begingroup$
      @FlyingThunder Be a skeptic no more :) see here
      $endgroup$
      – Quintec
      Feb 27 at 15:11










    • $begingroup$
      @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
      $endgroup$
      – Shaggy
      Feb 27 at 18:02






    • 1




      $begingroup$
      Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
      $endgroup$
      – ASCII-only
      2 days ago












    • $begingroup$
      @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
      $endgroup$
      – Quintec
      2 days ago



















    8












    $begingroup$

    Perl 5 (-p), 26 bytes



    s,.,$=$`.$/.$;"$`$&
    ",ge


    TIO






    share|improve this answer









    $endgroup$





















      8





      +300







      $begingroup$


      Japt -R, 9 7 bytes



      -2 bytes thanks to Shaggy



      Êõ@¯XÃê


      Try it online!






      share|improve this answer











      $endgroup$













      • $begingroup$
        7 bytes
        $endgroup$
        – Shaggy
        Feb 27 at 11:43






      • 1




        $begingroup$
        @Shaggy oh wait... Ã is a thing
        $endgroup$
        – ASCII-only
        Feb 27 at 11:47










      • $begingroup$
        Another 300 rep on its way as soon as this question is eligible for a bounty.
        $endgroup$
        – Shaggy
        Feb 27 at 13:06






      • 1




        $begingroup$
        5 bytes? (different approach)
        $endgroup$
        – Quintec
        Feb 27 at 14:14












      • $begingroup$
        @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
        $endgroup$
        – Shaggy
        Feb 27 at 14:38





















      8












      $begingroup$


      R, 79 65 62 58 bytes





      write(substring(s<-scan(,""),1,c(1:(r=nchar(s)),r-1:r)),1)


      Try it online!



      -14 by Giuseppe's superior function knowledge



      -3 with cleaner indexing



      -4 thanks to Nick Kennedy and Giuseppe's move to scan and write



      Avoiding loops (and substr) is nice.






      share|improve this answer











      $endgroup$









      • 1




        $begingroup$
        loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
        $endgroup$
        – Giuseppe
        Feb 27 at 15:53








      • 1




        $begingroup$
        Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
        $endgroup$
        – CriminallyVulgar
        Feb 27 at 16:01






      • 1




        $begingroup$
        Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
        $endgroup$
        – Giuseppe
        Feb 27 at 16:06






      • 2




        $begingroup$
        How about Try it online! using scan and write? Only 59 bytes!
        $endgroup$
        – Nick Kennedy
        Feb 27 at 18:49






      • 1




        $begingroup$
        @NickKennedy 58 bytes if you replace "" with 1.
        $endgroup$
        – Giuseppe
        Feb 27 at 19:10



















      6












      $begingroup$


      Python 3.8 (pre-release), 48 bytes





      lambda s,r='':(l:=[r:=r+c for c in s])+l[-2::-1]


      Try it online!



      Uses assignment expressions with := to accumulate a list of prefixes and then again to save the result to concatenate its reverse (without the first char).




      Python 2, 51 bytes





      f=lambda s,l=[]:s and f(s[:-1],[s]+l)or l+l[-2::-1]


      Try it online!



      We almost have the following nice 45-byte solution, but it has the original string twice and I don't see a short way to fix this.





      f=lambda s,l=[]:s and f(s[:-1],[s]+l+[s])or l


      Try it online!






      share|improve this answer











      $endgroup$













      • $begingroup$
        Wouldn't you need to add some newline and print to get the desired output?
        $endgroup$
        – Jaden Travnik
        7 hours ago










      • $begingroup$
        Something like print('n'.join(f(s))) ?
        $endgroup$
        – Jaden Travnik
        7 hours ago












      • $begingroup$
        @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
        $endgroup$
        – xnor
        6 hours ago












      • $begingroup$
        Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
        $endgroup$
        – Jaden Travnik
        6 hours ago










      • $begingroup$
        @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
        $endgroup$
        – xnor
        6 hours ago





















      5












      $begingroup$


      Charcoal, 5 bytes



      G^Lθθ


      Try it online! Link is to verbose version of code. Explanation: draws a filled polygon, ^ specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ specifies the length of those sides as being the length of the original input and the final θ specifies the fill string.






      share|improve this answer









      $endgroup$





















        5












        $begingroup$


        C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes



        Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)



        a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))


        Try it online!






        share|improve this answer











        $endgroup$





















          5












          $begingroup$

          PowerShell, 89 87 66 bytes



          -2 bytes thanks to @AdmBorkBork



          param($a)0..($d=$a.Length-1)|%{$b+=,-join$a[0..$_]};$b+$b[--$d..0]


          Try it online!



          It actually didn't work as specified before, sorry about that! I've edited it and also managed to shave some bytes off.






          share|improve this answer











          $endgroup$













          • $begingroup$
            You can --$d instead of ($d-1) to save a couple at the end.
            $endgroup$
            – AdmBorkBork
            Feb 27 at 16:14










          • $begingroup$
            @AdmBorkBork Thanks.
            $endgroup$
            – Gabriel Mills
            Feb 27 at 22:19










          • $begingroup$
            This doesn't work for single-character input, sadly.
            $endgroup$
            – AdmBorkBork
            Feb 28 at 15:09



















          5












          $begingroup$


          Jelly, 5 4 bytes



          -1 byte thanks to @JonathanAllan!



          ¹ƤŒḄ


          Try it online! I think this is my second Jelly answer? I don't know if this is optimal. I am more convinced of it being optimal. Returns an array of lines.



          Explanation



          ¹ƤŒḄ     input: "Hi!"
          ¹Ƥ prefixes of the input: [["H"], ["H", "i"], ["H", "i", "!"]]
          ŒḄ bounce, using each array: [["H"], ["H", "i"], ["H", "i", "!"], ["H", "i"], ["H"]]


          Another approach, proposed by @JonathanAllan, is ;ŒḄ, which cumulatively reduces () concatenation (;), which is another way to generate prefixes.






          share|improve this answer











          $endgroup$













          • $begingroup$
            We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
            $endgroup$
            – Jonathan Allan
            Feb 28 at 13:50












          • $begingroup$
            @JonathanAllan thanks! very interesting :)
            $endgroup$
            – Conor O'Brien
            Feb 28 at 17:15



















          5












          $begingroup$

          IBM PC DOS, 8088 assembly, 44 bytes



          be80 00ad 8bd6 b409 488a f88a c8d0 e149 b324 3acf 7d02 
          4e4e 4686 1ccd 2186 1c52 ba29 01cd 215a e2ea c30d 0a24


          Unassembled:



              MOV  SI, 80H            ; point SI to DOS PSP
          LODSW ; load arg length into AL, advance SI to 82H
          MOV DX, SI ; save start of string pointer
          MOV AH, 9 ; DOS API display string function
          DEC AX ; remove leading space from string length
          MOV BH, AL ; save string len in BH (AL gets mangled by INT 21H,9)
          MOV CL, AL ; set up loop counter in CL
          SHL CL, 1 ; number of lines = 2 * string length - 1
          DEC CX
          MOV BL, '$' ; end of string marker
          LINE_LOOP:
          CMP CL, BH ; if CL >= string length, ascend
          JGE ASCEND
          DEC SI ; descend by backing up two places (always increments)
          DEC SI ; (this is fewer bytes than 'SUB SI, 2' or two branches)
          ASCEND:
          INC SI ; increment current string position
          XCHG BL, [SI] ; swap current string byte with end of string delimiter
          INT 21H ; write substring to console
          XCHG BL, [SI] ; restore string byte
          PUSH DX ; save output string pointer
          MOV DX, OFFSET CRLF ; load CRLF string
          INT 21H ; write to console
          POP DX ; restore output string pointer
          LOOP LINE_LOOP ; move to next line
          RET
          CRLF DB 0DH,0AH,'$'


          Explanation



          Loop 2 * input length - 1 for each row. The DOS API's string display function (INT 21H,9) writes a $-terminated string to the screen, so each time through the loop the character after the last to be displayed is swapped with the end-of-string terminator.



          The loop counter is compared with the string length, and if it's greater (meaning the ascending part of the output) the string/swap position is incremented, otherwise it's decremented (actually it's -1-1+1 which is fewer bytes than an if/else branching structure).



          Standalone executable program, takes input string from command line.



          Output



          enter image description here



          Download YT.COM






          share|improve this answer











          $endgroup$





















            4












            $begingroup$


            APL (Dyalog Unicode), 9 bytesSBCS





            Anonymous tacit prefix function. Returns list of strings.



            (⊢,1↓⌽),


            Try it online!



            , the list of prefixes (lit, the cumulative concatenation)



            () apply the following function to that list:



             the reversed list



            1↓ drop the first item



            , prepend



             the unmodified list






            share|improve this answer











            $endgroup$





















              4












              $begingroup$


              Ruby, 51 42 40 bytes





              f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}


              Try it online!



              Thanks to Doorknob for -2 bytes.






              share|improve this answer











              $endgroup$









              • 1




                $begingroup$
                You can save 2 bytes by replacing ... with ,
                $endgroup$
                – Doorknob
                Feb 27 at 13:17



















              4












              $begingroup$


              JavaScript (Node.js), 90 bytes



              This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!





              s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}


              Try it online!






              share|improve this answer









              $endgroup$





















                4












                $begingroup$


                Attache, 15 bytes



                Bounce@Prefixes


                Try it online!



                Pretty simple. Bounces (appends reverse without center) the Prefixes of the input.



                Alternatively, 21 bytes: Bounce@{_[0..0:~-#_]}, re-implementing prefix.






                share|improve this answer









                $endgroup$





















                  4












                  $begingroup$


                  F# (.NET Core), 67 61 bytes





                  let l=s.Length
                  [1..l*2-1]|>Seq.map(fun i->s.[..l-abs(i-l)-1])


                  Try it online!



                  Input is a string and output is a seq<string>



                  Another solution could be let f(s:string)=for i=1 to s.Length*2-1 do printfn"%s"s.[..s.Length-abs(i-s.Length)-1] for 80ish bytes... I am not sure that it is worth looking into.






                  share|improve this answer











                  $endgroup$





















                    4












                    $begingroup$


                    PowerShell, 46 bytes





                    ($l=$args|% t*y|%{($s+=$_);++$i})+$l[$i..0]|gu


                    Try it online!






                    PowerShell, 42 bytes (YouTube special, dirty)



                    It is known that the maximum length of a comment on youtube is 10,000 characters. Ok, use this as the upper limit.





                    ($l=$args|% t*y|%{($s+=$_)})+$l[1e4..0]|gu


                    Try it online!






                    share|improve this answer











                    $endgroup$





















                      4












                      $begingroup$


                      C (gcc), 68 67 + 3 bytes





                      i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}


                      Try it online!



                      if you want reusable version, it is below.



                      i,j,t;f(char*s){for(j=0;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
                      ^^^


                      Try it online!






                      share|improve this answer











                      $endgroup$













                      • $begingroup$
                        Does not appear to be reusable.
                        $endgroup$
                        – gastropner
                        Feb 28 at 12:50










                      • $begingroup$
                        @gastropner what do you mean, not reusable?
                        $endgroup$
                        – Baldrickk
                        Feb 28 at 17:12










                      • $begingroup$
                        @Baldrickk If you call the function again with a new string, it doesn't work.
                        $endgroup$
                        – gastropner
                        Feb 28 at 17:13










                      • $begingroup$
                        @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                        $endgroup$
                        – Baldrickk
                        Feb 28 at 17:16








                      • 3




                        $begingroup$
                        @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                        $endgroup$
                        – gastropner
                        Feb 28 at 18:32



















                      4












                      $begingroup$


                      J, 12 bytes



                      ],[:}.@|.]


                      Try it online!



                      Still 1 byte longer than Adám's




                      K (oK), 12 11 bytes



                      -1 byte thanks to ngn



                      {x,1_|x}@,


                      Try it online!






                      share|improve this answer











                      $endgroup$









                      • 2




                        $begingroup$
                        Did I outgolf the master‽
                        $endgroup$
                        – Adám
                        Feb 27 at 11:56










                      • $begingroup$
                        @Adám I'm far from being a J master :) There are many J coders here better than I am.
                        $endgroup$
                        – Galen Ivanov
                        Feb 27 at 12:00






                      • 1




                        $begingroup$
                        -1 byte for oK: {x,1_|x}@,
                        $endgroup$
                        – ngn
                        Feb 28 at 22:31












                      • $begingroup$
                        @ngn Thank you!
                        $endgroup$
                        – Galen Ivanov
                        2 days ago



















                      3












                      $begingroup$


                      Octave, 58 bytes





                      for k=1:(n=nnz(s=input(''))*2)-1
                      disp(s(1:min(k,n-k)))
                      end


                      Try it online!






                      share|improve this answer









                      $endgroup$









                      • 1




                        $begingroup$
                        I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                        $endgroup$
                        – Wolfie
                        2 days ago










                      • $begingroup$
                        @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                        $endgroup$
                        – Luis Mendo
                        2 days ago



















                      3












                      $begingroup$


                      SNOBOL4 (CSNOBOL4), 118 bytes



                      	N =INPUT
                      L =1
                      1 X =LT(X,SIZE(N)) X + 1 :F(D)
                      O N ARB . OUTPUT POS(X) :($L)
                      D X =GT(X) X - 1 :F(END)
                      L ='D' :(O)
                      END


                      Try it online!



                      There appears to be a bug in this implementation of SNOBOL; attempting to replace the label D with the label 2 causes an error, although the manual for Vanilla SNOBOL indicates that (emphasis added)




                      If a label is present, it must begin with the first character of the line. Labels provide a name for the statement, and serve as the target for transfer of control from the GOTO field of any statement. Labels must begin with a letter or digit, optionally followed by an arbitrary string of characters. The label field is terminated by the character blank, tab, or semicolon. If the first character of a line is blank or tab, the label field is absent.




                      My supposition is that the CSNOBOL interpreter only supports a single label that begins with an integer.






                      share|improve this answer









                      $endgroup$





















                        3












                        $begingroup$


                        Brachylog (v2), 6 bytes



                        a₀ᶠ⊆.↔


                        Try it online!



                        Function submission, returning an array of lines. Loosely based on @Fatalize's answer.



                        Explanation



                        a₀ᶠ⊆.↔
                        .↔ Find a palindrome
                        ⊆ that contains, in order,
                        ᶠ all
                        a₀ prefixes of {the input}


                        Tiebreak order here is set by the , which, when used with this flow pattern, prefers the shortest possible output, tiebroken by placing the given elements as early as possible. The shortest possible output is what we want here (due to it not being possible to have any duplicate prefixes), and placing the given elements (i.e. the prefixes) as early as possible will place them in the first half (rounded up) of the output. Given that we're also requiring them to be placed in the same order, we happen to get exactly the pattern we need even though the description we gave Brachylog is very general; the tiebreaks happen to work out exactly right, causing Brachylog to pick the output we want rather than some other output that obeys the description.






                        share|improve this answer











                        $endgroup$





















                          3












                          $begingroup$

                          APL+WIN, 31 bytes



                          Prompts for input of string:



                           ⊃((⍳n),1↓⌽⍳n)↑¨(¯1+2×n←⍴s)⍴⊂s←⎕


                          Explanation:



                          (¯1+2×n←⍴s)⍴⊂s create a nested vector of the string of length =1+2x length of string

                          ((⍳n),1↓⌽⍳n)↑¨ progressively select elements from each element of the nested vector
                          following the pattern 1 2 ...to n to n-1 ... 1

                          ⊃ convert nested vector into a 2d array.





                          share|improve this answer









                          $endgroup$

















                            1 2
                            next


                            protected by Community Feb 28 at 17:45



                            Thank you for your interest in this question.
                            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                            Would you like to answer one of these unanswered questions instead?














                            58 Answers
                            58






                            active

                            oldest

                            votes








                            58 Answers
                            58






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes








                            1 2
                            next










                            67












                            $begingroup$


                            brainfuck, 32 bytes



                            ,[[<]>[.>]++++++++++.,[>>]<[-]<]


                            Try it online!



                            The same loop is used for both halves of the pattern.



                            Explanation:



                            ,             Take first input character as initial line
                            [ Until line to output is empty:
                            [<]> Move to beginning of line
                            [.>] Output all characters in line
                            ++++++++++. Output newline
                            , Input next character
                            [>>] Move two cells right if input character nonzero
                            <[-] Otherwise remove last character in line
                            < Move to new last character in line
                            ]





                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                              $endgroup$
                              – ElPedro
                              Feb 27 at 22:09








                            • 20




                              $begingroup$
                              Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                              $endgroup$
                              – Question Marks
                              Feb 28 at 18:01
















                            67












                            $begingroup$


                            brainfuck, 32 bytes



                            ,[[<]>[.>]++++++++++.,[>>]<[-]<]


                            Try it online!



                            The same loop is used for both halves of the pattern.



                            Explanation:



                            ,             Take first input character as initial line
                            [ Until line to output is empty:
                            [<]> Move to beginning of line
                            [.>] Output all characters in line
                            ++++++++++. Output newline
                            , Input next character
                            [>>] Move two cells right if input character nonzero
                            <[-] Otherwise remove last character in line
                            < Move to new last character in line
                            ]





                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                              $endgroup$
                              – ElPedro
                              Feb 27 at 22:09








                            • 20




                              $begingroup$
                              Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                              $endgroup$
                              – Question Marks
                              Feb 28 at 18:01














                            67












                            67








                            67





                            $begingroup$


                            brainfuck, 32 bytes



                            ,[[<]>[.>]++++++++++.,[>>]<[-]<]


                            Try it online!



                            The same loop is used for both halves of the pattern.



                            Explanation:



                            ,             Take first input character as initial line
                            [ Until line to output is empty:
                            [<]> Move to beginning of line
                            [.>] Output all characters in line
                            ++++++++++. Output newline
                            , Input next character
                            [>>] Move two cells right if input character nonzero
                            <[-] Otherwise remove last character in line
                            < Move to new last character in line
                            ]





                            share|improve this answer











                            $endgroup$




                            brainfuck, 32 bytes



                            ,[[<]>[.>]++++++++++.,[>>]<[-]<]


                            Try it online!



                            The same loop is used for both halves of the pattern.



                            Explanation:



                            ,             Take first input character as initial line
                            [ Until line to output is empty:
                            [<]> Move to beginning of line
                            [.>] Output all characters in line
                            ++++++++++. Output newline
                            , Input next character
                            [>>] Move two cells right if input character nonzero
                            <[-] Otherwise remove last character in line
                            < Move to new last character in line
                            ]






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 28 at 5:50

























                            answered Feb 27 at 19:18









                            NitrodonNitrodon

                            7,6011923




                            7,6011923








                            • 1




                              $begingroup$
                              That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                              $endgroup$
                              – ElPedro
                              Feb 27 at 22:09








                            • 20




                              $begingroup$
                              Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                              $endgroup$
                              – Question Marks
                              Feb 28 at 18:01














                            • 1




                              $begingroup$
                              That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                              $endgroup$
                              – ElPedro
                              Feb 27 at 22:09








                            • 20




                              $begingroup$
                              Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                              $endgroup$
                              – Question Marks
                              Feb 28 at 18:01








                            1




                            1




                            $begingroup$
                            That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                            $endgroup$
                            – ElPedro
                            Feb 27 at 22:09






                            $begingroup$
                            That's just plain awesome. I was trying to do something in brainfuck but it came out about 10 times this long and still didn't work properly.
                            $endgroup$
                            – ElPedro
                            Feb 27 at 22:09






                            20




                            20




                            $begingroup$
                            Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                            $endgroup$
                            – Question Marks
                            Feb 28 at 18:01




                            $begingroup$
                            Never thought I'd see a challenge where the brainfuck answer was actually scoring competitively, awesome work!
                            $endgroup$
                            – Question Marks
                            Feb 28 at 18:01











                            41












                            $begingroup$

                            JavaScript (ES6), 36 bytes





                            f=([c,...r],s=`
                            `)=>c?s+f(r,s+c)+s:s


                            Try it online!



                            Commented



                            f = (             // f is a recursive function taking:
                            // the input string split into:
                            [c, // c = next character (may be undefined if we've reached the end)
                            ...r], // r[] = array of remaining characters
                            s = `n` // the output string s, initialized to a linefeed
                            ) => //
                            c ? // if c is defined:
                            s + // append s (top of the ASCII art)
                            f(r, s + c) + // append the result of a recursive call to f, using r[] and s + c
                            s // append s again (bottom of the ASCII art)
                            : // else:
                            s // append s just once (this is the final middle row) and stop recursion





                            share|improve this answer











                            $endgroup$









                            • 2




                              $begingroup$
                              very nice answer :D
                              $endgroup$
                              – lois6b
                              Feb 27 at 15:38








                            • 9




                              $begingroup$
                              @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                              $endgroup$
                              – Arnauld
                              Feb 27 at 17:00






                            • 2




                              $begingroup$
                              Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                              $endgroup$
                              – Akhoy
                              2 days ago






                            • 2




                              $begingroup$
                              @Akhoy I've added a commented version.
                              $endgroup$
                              – Arnauld
                              2 days ago






                            • 3




                              $begingroup$
                              Thank you. A lot clearer now.
                              $endgroup$
                              – Akhoy
                              2 days ago
















                            41












                            $begingroup$

                            JavaScript (ES6), 36 bytes





                            f=([c,...r],s=`
                            `)=>c?s+f(r,s+c)+s:s


                            Try it online!



                            Commented



                            f = (             // f is a recursive function taking:
                            // the input string split into:
                            [c, // c = next character (may be undefined if we've reached the end)
                            ...r], // r[] = array of remaining characters
                            s = `n` // the output string s, initialized to a linefeed
                            ) => //
                            c ? // if c is defined:
                            s + // append s (top of the ASCII art)
                            f(r, s + c) + // append the result of a recursive call to f, using r[] and s + c
                            s // append s again (bottom of the ASCII art)
                            : // else:
                            s // append s just once (this is the final middle row) and stop recursion





                            share|improve this answer











                            $endgroup$









                            • 2




                              $begingroup$
                              very nice answer :D
                              $endgroup$
                              – lois6b
                              Feb 27 at 15:38








                            • 9




                              $begingroup$
                              @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                              $endgroup$
                              – Arnauld
                              Feb 27 at 17:00






                            • 2




                              $begingroup$
                              Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                              $endgroup$
                              – Akhoy
                              2 days ago






                            • 2




                              $begingroup$
                              @Akhoy I've added a commented version.
                              $endgroup$
                              – Arnauld
                              2 days ago






                            • 3




                              $begingroup$
                              Thank you. A lot clearer now.
                              $endgroup$
                              – Akhoy
                              2 days ago














                            41












                            41








                            41





                            $begingroup$

                            JavaScript (ES6), 36 bytes





                            f=([c,...r],s=`
                            `)=>c?s+f(r,s+c)+s:s


                            Try it online!



                            Commented



                            f = (             // f is a recursive function taking:
                            // the input string split into:
                            [c, // c = next character (may be undefined if we've reached the end)
                            ...r], // r[] = array of remaining characters
                            s = `n` // the output string s, initialized to a linefeed
                            ) => //
                            c ? // if c is defined:
                            s + // append s (top of the ASCII art)
                            f(r, s + c) + // append the result of a recursive call to f, using r[] and s + c
                            s // append s again (bottom of the ASCII art)
                            : // else:
                            s // append s just once (this is the final middle row) and stop recursion





                            share|improve this answer











                            $endgroup$



                            JavaScript (ES6), 36 bytes





                            f=([c,...r],s=`
                            `)=>c?s+f(r,s+c)+s:s


                            Try it online!



                            Commented



                            f = (             // f is a recursive function taking:
                            // the input string split into:
                            [c, // c = next character (may be undefined if we've reached the end)
                            ...r], // r[] = array of remaining characters
                            s = `n` // the output string s, initialized to a linefeed
                            ) => //
                            c ? // if c is defined:
                            s + // append s (top of the ASCII art)
                            f(r, s + c) + // append the result of a recursive call to f, using r[] and s + c
                            s // append s again (bottom of the ASCII art)
                            : // else:
                            s // append s just once (this is the final middle row) and stop recursion






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 2 days ago

























                            answered Feb 27 at 10:46









                            ArnauldArnauld

                            77.6k694325




                            77.6k694325








                            • 2




                              $begingroup$
                              very nice answer :D
                              $endgroup$
                              – lois6b
                              Feb 27 at 15:38








                            • 9




                              $begingroup$
                              @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                              $endgroup$
                              – Arnauld
                              Feb 27 at 17:00






                            • 2




                              $begingroup$
                              Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                              $endgroup$
                              – Akhoy
                              2 days ago






                            • 2




                              $begingroup$
                              @Akhoy I've added a commented version.
                              $endgroup$
                              – Arnauld
                              2 days ago






                            • 3




                              $begingroup$
                              Thank you. A lot clearer now.
                              $endgroup$
                              – Akhoy
                              2 days ago














                            • 2




                              $begingroup$
                              very nice answer :D
                              $endgroup$
                              – lois6b
                              Feb 27 at 15:38








                            • 9




                              $begingroup$
                              @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                              $endgroup$
                              – Arnauld
                              Feb 27 at 17:00






                            • 2




                              $begingroup$
                              Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                              $endgroup$
                              – Akhoy
                              2 days ago






                            • 2




                              $begingroup$
                              @Akhoy I've added a commented version.
                              $endgroup$
                              – Arnauld
                              2 days ago






                            • 3




                              $begingroup$
                              Thank you. A lot clearer now.
                              $endgroup$
                              – Akhoy
                              2 days ago








                            2




                            2




                            $begingroup$
                            very nice answer :D
                            $endgroup$
                            – lois6b
                            Feb 27 at 15:38






                            $begingroup$
                            very nice answer :D
                            $endgroup$
                            – lois6b
                            Feb 27 at 15:38






                            9




                            9




                            $begingroup$
                            @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                            $endgroup$
                            – Arnauld
                            Feb 27 at 17:00




                            $begingroup$
                            @MartinBarker On Windows, I'm using Notepad++ with the default Line Ending turned to Unix (LF). Problem solved once and for all. :)
                            $endgroup$
                            – Arnauld
                            Feb 27 at 17:00




                            2




                            2




                            $begingroup$
                            Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                            $endgroup$
                            – Akhoy
                            2 days ago




                            $begingroup$
                            Awesome! Can you write an explanation for this for those who are complete newbies to JS?
                            $endgroup$
                            – Akhoy
                            2 days ago




                            2




                            2




                            $begingroup$
                            @Akhoy I've added a commented version.
                            $endgroup$
                            – Arnauld
                            2 days ago




                            $begingroup$
                            @Akhoy I've added a commented version.
                            $endgroup$
                            – Arnauld
                            2 days ago




                            3




                            3




                            $begingroup$
                            Thank you. A lot clearer now.
                            $endgroup$
                            – Akhoy
                            2 days ago




                            $begingroup$
                            Thank you. A lot clearer now.
                            $endgroup$
                            – Akhoy
                            2 days ago











                            37












                            $begingroup$


                            05AB1E (legacy),  4  3 bytes



                            Crossed out &nbsp;4&nbsp; is no longer 4 :)



                            η.∊


                            Try it online or verify all test cases.



                            Explanation:





                            η     # Get the prefixes of the (implicit) input-string
                            .∊ # Vertically mirror everything with the last line overlapping
                            # (which implicitly joins by newlines in the legacy version of 05AB1E)
                            # (and output the result implicitly)


                            In the new version of 05AB1E, and explicit » is required after the η, which is why I use the legacy version of 05AB1E here to save a byte.






                            share|improve this answer











                            $endgroup$









                            • 7




                              $begingroup$
                              Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:22






                            • 9




                              $begingroup$
                              @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                              $endgroup$
                              – Kevin Cruijssen
                              Feb 28 at 17:30












                            • $begingroup$
                              All right, fair enough :).
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:31










                            • $begingroup$
                              @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                              $endgroup$
                              – hanshenrik
                              yesterday






                            • 4




                              $begingroup$
                              @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                              $endgroup$
                              – Adnan
                              yesterday
















                            37












                            $begingroup$


                            05AB1E (legacy),  4  3 bytes



                            Crossed out &nbsp;4&nbsp; is no longer 4 :)



                            η.∊


                            Try it online or verify all test cases.



                            Explanation:





                            η     # Get the prefixes of the (implicit) input-string
                            .∊ # Vertically mirror everything with the last line overlapping
                            # (which implicitly joins by newlines in the legacy version of 05AB1E)
                            # (and output the result implicitly)


                            In the new version of 05AB1E, and explicit » is required after the η, which is why I use the legacy version of 05AB1E here to save a byte.






                            share|improve this answer











                            $endgroup$









                            • 7




                              $begingroup$
                              Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:22






                            • 9




                              $begingroup$
                              @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                              $endgroup$
                              – Kevin Cruijssen
                              Feb 28 at 17:30












                            • $begingroup$
                              All right, fair enough :).
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:31










                            • $begingroup$
                              @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                              $endgroup$
                              – hanshenrik
                              yesterday






                            • 4




                              $begingroup$
                              @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                              $endgroup$
                              – Adnan
                              yesterday














                            37












                            37








                            37





                            $begingroup$


                            05AB1E (legacy),  4  3 bytes



                            Crossed out &nbsp;4&nbsp; is no longer 4 :)



                            η.∊


                            Try it online or verify all test cases.



                            Explanation:





                            η     # Get the prefixes of the (implicit) input-string
                            .∊ # Vertically mirror everything with the last line overlapping
                            # (which implicitly joins by newlines in the legacy version of 05AB1E)
                            # (and output the result implicitly)


                            In the new version of 05AB1E, and explicit » is required after the η, which is why I use the legacy version of 05AB1E here to save a byte.






                            share|improve this answer











                            $endgroup$




                            05AB1E (legacy),  4  3 bytes



                            Crossed out &nbsp;4&nbsp; is no longer 4 :)



                            η.∊


                            Try it online or verify all test cases.



                            Explanation:





                            η     # Get the prefixes of the (implicit) input-string
                            .∊ # Vertically mirror everything with the last line overlapping
                            # (which implicitly joins by newlines in the legacy version of 05AB1E)
                            # (and output the result implicitly)


                            In the new version of 05AB1E, and explicit » is required after the η, which is why I use the legacy version of 05AB1E here to save a byte.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 27 at 10:59

























                            answered Feb 27 at 10:54









                            Kevin CruijssenKevin Cruijssen

                            39.3k560203




                            39.3k560203








                            • 7




                              $begingroup$
                              Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:22






                            • 9




                              $begingroup$
                              @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                              $endgroup$
                              – Kevin Cruijssen
                              Feb 28 at 17:30












                            • $begingroup$
                              All right, fair enough :).
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:31










                            • $begingroup$
                              @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                              $endgroup$
                              – hanshenrik
                              yesterday






                            • 4




                              $begingroup$
                              @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                              $endgroup$
                              – Adnan
                              yesterday














                            • 7




                              $begingroup$
                              Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:22






                            • 9




                              $begingroup$
                              @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                              $endgroup$
                              – Kevin Cruijssen
                              Feb 28 at 17:30












                            • $begingroup$
                              All right, fair enough :).
                              $endgroup$
                              – rubenvb
                              Feb 28 at 17:31










                            • $begingroup$
                              @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                              $endgroup$
                              – hanshenrik
                              yesterday






                            • 4




                              $begingroup$
                              @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                              $endgroup$
                              – Adnan
                              yesterday








                            7




                            7




                            $begingroup$
                            Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                            $endgroup$
                            – rubenvb
                            Feb 28 at 17:22




                            $begingroup$
                            Hmm, this seems to 6 bytes in UTF8: xcexb7x2exe2x88x8a
                            $endgroup$
                            – rubenvb
                            Feb 28 at 17:22




                            9




                            9




                            $begingroup$
                            @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                            $endgroup$
                            – Kevin Cruijssen
                            Feb 28 at 17:30






                            $begingroup$
                            @rubenvb In UTF-8 it's indeed more. 05AB1E uses, just like some some of the programming languages used in other answers (i.e. Jelly; Japt; Charcoal) it's own source code (which is CP-1252 in the case of 05AB1E), where each of the 256 characters it knows is a single byte.
                            $endgroup$
                            – Kevin Cruijssen
                            Feb 28 at 17:30














                            $begingroup$
                            All right, fair enough :).
                            $endgroup$
                            – rubenvb
                            Feb 28 at 17:31




                            $begingroup$
                            All right, fair enough :).
                            $endgroup$
                            – rubenvb
                            Feb 28 at 17:31












                            $begingroup$
                            @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                            $endgroup$
                            – hanshenrik
                            yesterday




                            $begingroup$
                            @KevinCruijssen PHP seems to think that these characters are invalid for CP-1252, but could just be a PHP bug: 3v4l.org/UC1QE
                            $endgroup$
                            – hanshenrik
                            yesterday




                            4




                            4




                            $begingroup$
                            @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                            $endgroup$
                            – Adnan
                            yesterday




                            $begingroup$
                            @hanshenrik Good question. It is indeed not CP-1252, but in fact the 05AB1E encoding, which is the custom encoding it uses. The bytes of this code in hex are 08 2e 17, which you can run and verify with the --osabie flag: tio.run/…
                            $endgroup$
                            – Adnan
                            yesterday











                            16












                            $begingroup$


                            Python 2, 60 52 bytes





                            f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]


                            Try it online!




                            Python 3.8 (pre-release), 50 bytes





                            f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]


                            Try it online!






                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              Does this depend on a forthcoming feature of 3.8? Which feature?
                              $endgroup$
                              – alexis
                              Feb 27 at 17:58






                            • 5




                              $begingroup$
                              @alexis This is using an assignment expression: x:=s[:n].
                              $endgroup$
                              – Arnauld
                              Feb 27 at 19:35








                            • 1




                              $begingroup$
                              Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                              $endgroup$
                              – alexis
                              Feb 28 at 7:37












                            • $begingroup$
                              These don't print the output though. They just make the array, right?
                              $endgroup$
                              – Jaden Travnik
                              7 hours ago
















                            16












                            $begingroup$


                            Python 2, 60 52 bytes





                            f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]


                            Try it online!




                            Python 3.8 (pre-release), 50 bytes





                            f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]


                            Try it online!






                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              Does this depend on a forthcoming feature of 3.8? Which feature?
                              $endgroup$
                              – alexis
                              Feb 27 at 17:58






                            • 5




                              $begingroup$
                              @alexis This is using an assignment expression: x:=s[:n].
                              $endgroup$
                              – Arnauld
                              Feb 27 at 19:35








                            • 1




                              $begingroup$
                              Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                              $endgroup$
                              – alexis
                              Feb 28 at 7:37












                            • $begingroup$
                              These don't print the output though. They just make the array, right?
                              $endgroup$
                              – Jaden Travnik
                              7 hours ago














                            16












                            16








                            16





                            $begingroup$


                            Python 2, 60 52 bytes





                            f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]


                            Try it online!




                            Python 3.8 (pre-release), 50 bytes





                            f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]


                            Try it online!






                            share|improve this answer











                            $endgroup$




                            Python 2, 60 52 bytes





                            f=lambda s,n=1:s[n:]and[s[:n]]+f(s,n+1)+[s[:n]]or[s]


                            Try it online!




                            Python 3.8 (pre-release), 50 bytes





                            f=lambda s,n=1:s>(x:=s[:n])and[x,*f(s,n+1),x]or[s]


                            Try it online!







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 27 at 10:55

























                            answered Feb 27 at 10:40









                            TFeldTFeld

                            15.5k21247




                            15.5k21247








                            • 1




                              $begingroup$
                              Does this depend on a forthcoming feature of 3.8? Which feature?
                              $endgroup$
                              – alexis
                              Feb 27 at 17:58






                            • 5




                              $begingroup$
                              @alexis This is using an assignment expression: x:=s[:n].
                              $endgroup$
                              – Arnauld
                              Feb 27 at 19:35








                            • 1




                              $begingroup$
                              Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                              $endgroup$
                              – alexis
                              Feb 28 at 7:37












                            • $begingroup$
                              These don't print the output though. They just make the array, right?
                              $endgroup$
                              – Jaden Travnik
                              7 hours ago














                            • 1




                              $begingroup$
                              Does this depend on a forthcoming feature of 3.8? Which feature?
                              $endgroup$
                              – alexis
                              Feb 27 at 17:58






                            • 5




                              $begingroup$
                              @alexis This is using an assignment expression: x:=s[:n].
                              $endgroup$
                              – Arnauld
                              Feb 27 at 19:35








                            • 1




                              $begingroup$
                              Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                              $endgroup$
                              – alexis
                              Feb 28 at 7:37












                            • $begingroup$
                              These don't print the output though. They just make the array, right?
                              $endgroup$
                              – Jaden Travnik
                              7 hours ago








                            1




                            1




                            $begingroup$
                            Does this depend on a forthcoming feature of 3.8? Which feature?
                            $endgroup$
                            – alexis
                            Feb 27 at 17:58




                            $begingroup$
                            Does this depend on a forthcoming feature of 3.8? Which feature?
                            $endgroup$
                            – alexis
                            Feb 27 at 17:58




                            5




                            5




                            $begingroup$
                            @alexis This is using an assignment expression: x:=s[:n].
                            $endgroup$
                            – Arnauld
                            Feb 27 at 19:35






                            $begingroup$
                            @alexis This is using an assignment expression: x:=s[:n].
                            $endgroup$
                            – Arnauld
                            Feb 27 at 19:35






                            1




                            1




                            $begingroup$
                            Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                            $endgroup$
                            – alexis
                            Feb 28 at 7:37






                            $begingroup$
                            Ah, I see it now thanks :-) I've read about the feature before, looking forward to it. Still miss it from my C days...
                            $endgroup$
                            – alexis
                            Feb 28 at 7:37














                            $begingroup$
                            These don't print the output though. They just make the array, right?
                            $endgroup$
                            – Jaden Travnik
                            7 hours ago




                            $begingroup$
                            These don't print the output though. They just make the array, right?
                            $endgroup$
                            – Jaden Travnik
                            7 hours ago











                            14












                            $begingroup$


                            J, 11 bytes



                            Anonymous tacit prefix function. Returns a space-padded character matrix.



                            [:(}:,|.)]


                            Try it online!



                            ] the list of prefixes



                            [:() apply the following function to that list



                            |. the reverse list



                            , prepended with



                            }: the curtailed (without last item) list






                            share|improve this answer











                            $endgroup$









                            • 11




                              $begingroup$
                              [:( and }:,| look so sad…
                              $endgroup$
                              – Adám
                              Feb 27 at 11:57
















                            14












                            $begingroup$


                            J, 11 bytes



                            Anonymous tacit prefix function. Returns a space-padded character matrix.



                            [:(}:,|.)]


                            Try it online!



                            ] the list of prefixes



                            [:() apply the following function to that list



                            |. the reverse list



                            , prepended with



                            }: the curtailed (without last item) list






                            share|improve this answer











                            $endgroup$









                            • 11




                              $begingroup$
                              [:( and }:,| look so sad…
                              $endgroup$
                              – Adám
                              Feb 27 at 11:57














                            14












                            14








                            14





                            $begingroup$


                            J, 11 bytes



                            Anonymous tacit prefix function. Returns a space-padded character matrix.



                            [:(}:,|.)]


                            Try it online!



                            ] the list of prefixes



                            [:() apply the following function to that list



                            |. the reverse list



                            , prepended with



                            }: the curtailed (without last item) list






                            share|improve this answer











                            $endgroup$




                            J, 11 bytes



                            Anonymous tacit prefix function. Returns a space-padded character matrix.



                            [:(}:,|.)]


                            Try it online!



                            ] the list of prefixes



                            [:() apply the following function to that list



                            |. the reverse list



                            , prepended with



                            }: the curtailed (without last item) list







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 28 at 22:49

























                            answered Feb 27 at 11:43









                            AdámAdám

                            29k276204




                            29k276204








                            • 11




                              $begingroup$
                              [:( and }:,| look so sad…
                              $endgroup$
                              – Adám
                              Feb 27 at 11:57














                            • 11




                              $begingroup$
                              [:( and }:,| look so sad…
                              $endgroup$
                              – Adám
                              Feb 27 at 11:57








                            11




                            11




                            $begingroup$
                            [:( and }:,| look so sad…
                            $endgroup$
                            – Adám
                            Feb 27 at 11:57




                            $begingroup$
                            [:( and }:,| look so sad…
                            $endgroup$
                            – Adám
                            Feb 27 at 11:57











                            10












                            $begingroup$


                            Perl 6, 31 bytes





                            {[~](@_)[0...@_-1...0]}o*.comb


                            Try it online!



                            Anonymous code block that takes a string and returns a list of lines.






                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              It's funny that these days even golfed Perl is among the most readable contestants.
                              $endgroup$
                              – ceased to turn counterclockwis
                              2 days ago






                            • 3




                              $begingroup$
                              @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                              $endgroup$
                              – Jo King
                              2 days ago
















                            10












                            $begingroup$


                            Perl 6, 31 bytes





                            {[~](@_)[0...@_-1...0]}o*.comb


                            Try it online!



                            Anonymous code block that takes a string and returns a list of lines.






                            share|improve this answer











                            $endgroup$









                            • 1




                              $begingroup$
                              It's funny that these days even golfed Perl is among the most readable contestants.
                              $endgroup$
                              – ceased to turn counterclockwis
                              2 days ago






                            • 3




                              $begingroup$
                              @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                              $endgroup$
                              – Jo King
                              2 days ago














                            10












                            10








                            10





                            $begingroup$


                            Perl 6, 31 bytes





                            {[~](@_)[0...@_-1...0]}o*.comb


                            Try it online!



                            Anonymous code block that takes a string and returns a list of lines.






                            share|improve this answer











                            $endgroup$




                            Perl 6, 31 bytes





                            {[~](@_)[0...@_-1...0]}o*.comb


                            Try it online!



                            Anonymous code block that takes a string and returns a list of lines.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 27 at 11:11

























                            answered Feb 27 at 11:02









                            Jo KingJo King

                            24.1k357124




                            24.1k357124








                            • 1




                              $begingroup$
                              It's funny that these days even golfed Perl is among the most readable contestants.
                              $endgroup$
                              – ceased to turn counterclockwis
                              2 days ago






                            • 3




                              $begingroup$
                              @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                              $endgroup$
                              – Jo King
                              2 days ago














                            • 1




                              $begingroup$
                              It's funny that these days even golfed Perl is among the most readable contestants.
                              $endgroup$
                              – ceased to turn counterclockwis
                              2 days ago






                            • 3




                              $begingroup$
                              @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                              $endgroup$
                              – Jo King
                              2 days ago








                            1




                            1




                            $begingroup$
                            It's funny that these days even golfed Perl is among the most readable contestants.
                            $endgroup$
                            – ceased to turn counterclockwis
                            2 days ago




                            $begingroup$
                            It's funny that these days even golfed Perl is among the most readable contestants.
                            $endgroup$
                            – ceased to turn counterclockwis
                            2 days ago




                            3




                            3




                            $begingroup$
                            @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                            $endgroup$
                            – Jo King
                            2 days ago




                            $begingroup$
                            @ceasedtoturncounterclockwis Well, this is Perl 6. The Perl 5 answer is still unreadable
                            $endgroup$
                            – Jo King
                            2 days ago











                            10












                            $begingroup$


                            MATL, 8 bytes



                            nZv"G@:)


                            Try it online!



                            Please like this post for the smiley :) in the code it took me a lot of time to make.



                            n  % Length of the input string
                            Zv % Symmetric range ([1 2 ... n ... 1])
                            " % For each k in above range
                            G % Push input
                            @: % Push [1 2 ... k]
                            ) % Index





                            share|improve this answer









                            $endgroup$


















                              10












                              $begingroup$


                              MATL, 8 bytes



                              nZv"G@:)


                              Try it online!



                              Please like this post for the smiley :) in the code it took me a lot of time to make.



                              n  % Length of the input string
                              Zv % Symmetric range ([1 2 ... n ... 1])
                              " % For each k in above range
                              G % Push input
                              @: % Push [1 2 ... k]
                              ) % Index





                              share|improve this answer









                              $endgroup$
















                                10












                                10








                                10





                                $begingroup$


                                MATL, 8 bytes



                                nZv"G@:)


                                Try it online!



                                Please like this post for the smiley :) in the code it took me a lot of time to make.



                                n  % Length of the input string
                                Zv % Symmetric range ([1 2 ... n ... 1])
                                " % For each k in above range
                                G % Push input
                                @: % Push [1 2 ... k]
                                ) % Index





                                share|improve this answer









                                $endgroup$




                                MATL, 8 bytes



                                nZv"G@:)


                                Try it online!



                                Please like this post for the smiley :) in the code it took me a lot of time to make.



                                n  % Length of the input string
                                Zv % Symmetric range ([1 2 ... n ... 1])
                                " % For each k in above range
                                G % Push input
                                @: % Push [1 2 ... k]
                                ) % Index






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Feb 27 at 12:19









                                SanchisesSanchises

                                6,12712352




                                6,12712352























                                    9












                                    $begingroup$

                                    Haskell, 57 bytes



                                    import Data.List
                                    unlines.((++)<*>tail.reverse).tail.inits





                                    share|improve this answer










                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    $endgroup$













                                    • $begingroup$
                                      Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 21:16










                                    • $begingroup$
                                      @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                      $endgroup$
                                      – Joseph Sible
                                      Feb 27 at 22:04






                                    • 3




                                      $begingroup$
                                      Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 22:21






                                    • 1




                                      $begingroup$
                                      I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                      $endgroup$
                                      – Axman6
                                      Feb 28 at 5:05


















                                    9












                                    $begingroup$

                                    Haskell, 57 bytes



                                    import Data.List
                                    unlines.((++)<*>tail.reverse).tail.inits





                                    share|improve this answer










                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    $endgroup$













                                    • $begingroup$
                                      Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 21:16










                                    • $begingroup$
                                      @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                      $endgroup$
                                      – Joseph Sible
                                      Feb 27 at 22:04






                                    • 3




                                      $begingroup$
                                      Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 22:21






                                    • 1




                                      $begingroup$
                                      I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                      $endgroup$
                                      – Axman6
                                      Feb 28 at 5:05
















                                    9












                                    9








                                    9





                                    $begingroup$

                                    Haskell, 57 bytes



                                    import Data.List
                                    unlines.((++)<*>tail.reverse).tail.inits





                                    share|improve this answer










                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    $endgroup$



                                    Haskell, 57 bytes



                                    import Data.List
                                    unlines.((++)<*>tail.reverse).tail.inits






                                    share|improve this answer










                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    share|improve this answer



                                    share|improve this answer








                                    edited Feb 27 at 22:02





















                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    answered Feb 27 at 20:51









                                    Joseph SibleJoseph Sible

                                    1954




                                    1954




                                    New contributor




                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





                                    New contributor





                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    Joseph Sible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.












                                    • $begingroup$
                                      Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 21:16










                                    • $begingroup$
                                      @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                      $endgroup$
                                      – Joseph Sible
                                      Feb 27 at 22:04






                                    • 3




                                      $begingroup$
                                      Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 22:21






                                    • 1




                                      $begingroup$
                                      I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                      $endgroup$
                                      – Axman6
                                      Feb 28 at 5:05




















                                    • $begingroup$
                                      Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 21:16










                                    • $begingroup$
                                      @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                      $endgroup$
                                      – Joseph Sible
                                      Feb 27 at 22:04






                                    • 3




                                      $begingroup$
                                      Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                      $endgroup$
                                      – Sriotchilism O'Zaic
                                      Feb 27 at 22:21






                                    • 1




                                      $begingroup$
                                      I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                      $endgroup$
                                      – Axman6
                                      Feb 28 at 5:05


















                                    $begingroup$
                                    Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                    $endgroup$
                                    – Sriotchilism O'Zaic
                                    Feb 27 at 21:16




                                    $begingroup$
                                    Welcome to the site. inits requires an import to be used so you are going to need to add import Data.List or something similar.
                                    $endgroup$
                                    – Sriotchilism O'Zaic
                                    Feb 27 at 21:16












                                    $begingroup$
                                    @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                    $endgroup$
                                    – Joseph Sible
                                    Feb 27 at 22:04




                                    $begingroup$
                                    @SriotchilismO'Zaic Wasn't sure if that was necessary to count or not. Added, thanks!
                                    $endgroup$
                                    – Joseph Sible
                                    Feb 27 at 22:04




                                    3




                                    3




                                    $begingroup$
                                    Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                    $endgroup$
                                    – Sriotchilism O'Zaic
                                    Feb 27 at 22:21




                                    $begingroup$
                                    Also I should mention we have a chat room for talking Haskell golfing. If you have any thoughts or questions that's a great place.
                                    $endgroup$
                                    – Sriotchilism O'Zaic
                                    Feb 27 at 22:21




                                    1




                                    1




                                    $begingroup$
                                    I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                    $endgroup$
                                    – Axman6
                                    Feb 28 at 5:05






                                    $begingroup$
                                    I can't believe you came up with exactly what I was going to post: import Data.List putStr.unlines.((++)<*>reverse.init).tail.inits
                                    $endgroup$
                                    – Axman6
                                    Feb 28 at 5:05













                                    9












                                    $begingroup$


                                    Japt -R, 4 bytes



                                    å+ ê


                                    Cumulative reduce on a string.



                                    -1 byte thanks to @Shaggy



                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                      $endgroup$
                                      – Flying Thunder
                                      Feb 27 at 14:58






                                    • 3




                                      $begingroup$
                                      @FlyingThunder Be a skeptic no more :) see here
                                      $endgroup$
                                      – Quintec
                                      Feb 27 at 15:11










                                    • $begingroup$
                                      @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                      $endgroup$
                                      – Shaggy
                                      Feb 27 at 18:02






                                    • 1




                                      $begingroup$
                                      Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                      $endgroup$
                                      – ASCII-only
                                      2 days ago












                                    • $begingroup$
                                      @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                      $endgroup$
                                      – Quintec
                                      2 days ago
















                                    9












                                    $begingroup$


                                    Japt -R, 4 bytes



                                    å+ ê


                                    Cumulative reduce on a string.



                                    -1 byte thanks to @Shaggy



                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                      $endgroup$
                                      – Flying Thunder
                                      Feb 27 at 14:58






                                    • 3




                                      $begingroup$
                                      @FlyingThunder Be a skeptic no more :) see here
                                      $endgroup$
                                      – Quintec
                                      Feb 27 at 15:11










                                    • $begingroup$
                                      @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                      $endgroup$
                                      – Shaggy
                                      Feb 27 at 18:02






                                    • 1




                                      $begingroup$
                                      Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                      $endgroup$
                                      – ASCII-only
                                      2 days ago












                                    • $begingroup$
                                      @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                      $endgroup$
                                      – Quintec
                                      2 days ago














                                    9












                                    9








                                    9





                                    $begingroup$


                                    Japt -R, 4 bytes



                                    å+ ê


                                    Cumulative reduce on a string.



                                    -1 byte thanks to @Shaggy



                                    Try it online!






                                    share|improve this answer











                                    $endgroup$




                                    Japt -R, 4 bytes



                                    å+ ê


                                    Cumulative reduce on a string.



                                    -1 byte thanks to @Shaggy



                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 2 days ago

























                                    answered Feb 27 at 14:40









                                    QuintecQuintec

                                    1,9181724




                                    1,9181724












                                    • $begingroup$
                                      Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                      $endgroup$
                                      – Flying Thunder
                                      Feb 27 at 14:58






                                    • 3




                                      $begingroup$
                                      @FlyingThunder Be a skeptic no more :) see here
                                      $endgroup$
                                      – Quintec
                                      Feb 27 at 15:11










                                    • $begingroup$
                                      @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                      $endgroup$
                                      – Shaggy
                                      Feb 27 at 18:02






                                    • 1




                                      $begingroup$
                                      Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                      $endgroup$
                                      – ASCII-only
                                      2 days ago












                                    • $begingroup$
                                      @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                      $endgroup$
                                      – Quintec
                                      2 days ago


















                                    • $begingroup$
                                      Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                      $endgroup$
                                      – Flying Thunder
                                      Feb 27 at 14:58






                                    • 3




                                      $begingroup$
                                      @FlyingThunder Be a skeptic no more :) see here
                                      $endgroup$
                                      – Quintec
                                      Feb 27 at 15:11










                                    • $begingroup$
                                      @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                      $endgroup$
                                      – Shaggy
                                      Feb 27 at 18:02






                                    • 1




                                      $begingroup$
                                      Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                      $endgroup$
                                      – ASCII-only
                                      2 days ago












                                    • $begingroup$
                                      @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                      $endgroup$
                                      – Quintec
                                      2 days ago
















                                    $begingroup$
                                    Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                    $endgroup$
                                    – Flying Thunder
                                    Feb 27 at 14:58




                                    $begingroup$
                                    Sceptic about the "-R" that has to be included in the string (without it the output doesnt work)
                                    $endgroup$
                                    – Flying Thunder
                                    Feb 27 at 14:58




                                    3




                                    3




                                    $begingroup$
                                    @FlyingThunder Be a skeptic no more :) see here
                                    $endgroup$
                                    – Quintec
                                    Feb 27 at 15:11




                                    $begingroup$
                                    @FlyingThunder Be a skeptic no more :) see here
                                    $endgroup$
                                    – Quintec
                                    Feb 27 at 15:11












                                    $begingroup$
                                    @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                    $endgroup$
                                    – Shaggy
                                    Feb 27 at 18:02




                                    $begingroup$
                                    @Quintec, I've taken to linking the flags in my solution headers to that meta post to try to preempt these sorts of comments.
                                    $endgroup$
                                    – Shaggy
                                    Feb 27 at 18:02




                                    1




                                    1




                                    $begingroup$
                                    Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                    $endgroup$
                                    – ASCII-only
                                    2 days ago






                                    $begingroup$
                                    Pretty sure convention is <language> + -flag or <language> -flag. Also, :| I forgot cumulative reduce was a thing, I swear I skipped over it every time I saw it
                                    $endgroup$
                                    – ASCII-only
                                    2 days ago














                                    $begingroup$
                                    @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                    $endgroup$
                                    – Quintec
                                    2 days ago




                                    $begingroup$
                                    @ASCII-only Same, I only remembered it because I was thinking how I would solve this in APL and said "I wonder if Japt has this builtin". Also, didn't I use <language> -flag?
                                    $endgroup$
                                    – Quintec
                                    2 days ago











                                    8












                                    $begingroup$

                                    Perl 5 (-p), 26 bytes



                                    s,.,$=$`.$/.$;"$`$&
                                    ",ge


                                    TIO






                                    share|improve this answer









                                    $endgroup$


















                                      8












                                      $begingroup$

                                      Perl 5 (-p), 26 bytes



                                      s,.,$=$`.$/.$;"$`$&
                                      ",ge


                                      TIO






                                      share|improve this answer









                                      $endgroup$
















                                        8












                                        8








                                        8





                                        $begingroup$

                                        Perl 5 (-p), 26 bytes



                                        s,.,$=$`.$/.$;"$`$&
                                        ",ge


                                        TIO






                                        share|improve this answer









                                        $endgroup$



                                        Perl 5 (-p), 26 bytes



                                        s,.,$=$`.$/.$;"$`$&
                                        ",ge


                                        TIO







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Feb 27 at 12:00









                                        Nahuel FouilleulNahuel Fouilleul

                                        2,63529




                                        2,63529























                                            8





                                            +300







                                            $begingroup$


                                            Japt -R, 9 7 bytes



                                            -2 bytes thanks to Shaggy



                                            Êõ@¯XÃê


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$













                                            • $begingroup$
                                              7 bytes
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 11:43






                                            • 1




                                              $begingroup$
                                              @Shaggy oh wait... Ã is a thing
                                              $endgroup$
                                              – ASCII-only
                                              Feb 27 at 11:47










                                            • $begingroup$
                                              Another 300 rep on its way as soon as this question is eligible for a bounty.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 13:06






                                            • 1




                                              $begingroup$
                                              5 bytes? (different approach)
                                              $endgroup$
                                              – Quintec
                                              Feb 27 at 14:14












                                            • $begingroup$
                                              @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 14:38


















                                            8





                                            +300







                                            $begingroup$


                                            Japt -R, 9 7 bytes



                                            -2 bytes thanks to Shaggy



                                            Êõ@¯XÃê


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$













                                            • $begingroup$
                                              7 bytes
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 11:43






                                            • 1




                                              $begingroup$
                                              @Shaggy oh wait... Ã is a thing
                                              $endgroup$
                                              – ASCII-only
                                              Feb 27 at 11:47










                                            • $begingroup$
                                              Another 300 rep on its way as soon as this question is eligible for a bounty.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 13:06






                                            • 1




                                              $begingroup$
                                              5 bytes? (different approach)
                                              $endgroup$
                                              – Quintec
                                              Feb 27 at 14:14












                                            • $begingroup$
                                              @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 14:38
















                                            8





                                            +300







                                            8





                                            +300



                                            8




                                            +300



                                            $begingroup$


                                            Japt -R, 9 7 bytes



                                            -2 bytes thanks to Shaggy



                                            Êõ@¯XÃê


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$




                                            Japt -R, 9 7 bytes



                                            -2 bytes thanks to Shaggy



                                            Êõ@¯XÃê


                                            Try it online!







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Feb 27 at 21:44

























                                            answered Feb 27 at 10:32









                                            ASCII-onlyASCII-only

                                            4,2281237




                                            4,2281237












                                            • $begingroup$
                                              7 bytes
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 11:43






                                            • 1




                                              $begingroup$
                                              @Shaggy oh wait... Ã is a thing
                                              $endgroup$
                                              – ASCII-only
                                              Feb 27 at 11:47










                                            • $begingroup$
                                              Another 300 rep on its way as soon as this question is eligible for a bounty.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 13:06






                                            • 1




                                              $begingroup$
                                              5 bytes? (different approach)
                                              $endgroup$
                                              – Quintec
                                              Feb 27 at 14:14












                                            • $begingroup$
                                              @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 14:38




















                                            • $begingroup$
                                              7 bytes
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 11:43






                                            • 1




                                              $begingroup$
                                              @Shaggy oh wait... Ã is a thing
                                              $endgroup$
                                              – ASCII-only
                                              Feb 27 at 11:47










                                            • $begingroup$
                                              Another 300 rep on its way as soon as this question is eligible for a bounty.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 13:06






                                            • 1




                                              $begingroup$
                                              5 bytes? (different approach)
                                              $endgroup$
                                              – Quintec
                                              Feb 27 at 14:14












                                            • $begingroup$
                                              @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                              $endgroup$
                                              – Shaggy
                                              Feb 27 at 14:38


















                                            $begingroup$
                                            7 bytes
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 11:43




                                            $begingroup$
                                            7 bytes
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 11:43




                                            1




                                            1




                                            $begingroup$
                                            @Shaggy oh wait... Ã is a thing
                                            $endgroup$
                                            – ASCII-only
                                            Feb 27 at 11:47




                                            $begingroup$
                                            @Shaggy oh wait... Ã is a thing
                                            $endgroup$
                                            – ASCII-only
                                            Feb 27 at 11:47












                                            $begingroup$
                                            Another 300 rep on its way as soon as this question is eligible for a bounty.
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 13:06




                                            $begingroup$
                                            Another 300 rep on its way as soon as this question is eligible for a bounty.
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 13:06




                                            1




                                            1




                                            $begingroup$
                                            5 bytes? (different approach)
                                            $endgroup$
                                            – Quintec
                                            Feb 27 at 14:14






                                            $begingroup$
                                            5 bytes? (different approach)
                                            $endgroup$
                                            – Quintec
                                            Feb 27 at 14:14














                                            $begingroup$
                                            @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 14:38






                                            $begingroup$
                                            @Quintec, cumulative reduce works on strings, too, so you don't need to split at the start. I'd also say that's different enough to warrant posting it yourself.
                                            $endgroup$
                                            – Shaggy
                                            Feb 27 at 14:38













                                            8












                                            $begingroup$


                                            R, 79 65 62 58 bytes





                                            write(substring(s<-scan(,""),1,c(1:(r=nchar(s)),r-1:r)),1)


                                            Try it online!



                                            -14 by Giuseppe's superior function knowledge



                                            -3 with cleaner indexing



                                            -4 thanks to Nick Kennedy and Giuseppe's move to scan and write



                                            Avoiding loops (and substr) is nice.






                                            share|improve this answer











                                            $endgroup$









                                            • 1




                                              $begingroup$
                                              loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 15:53








                                            • 1




                                              $begingroup$
                                              Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                              $endgroup$
                                              – CriminallyVulgar
                                              Feb 27 at 16:01






                                            • 1




                                              $begingroup$
                                              Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 16:06






                                            • 2




                                              $begingroup$
                                              How about Try it online! using scan and write? Only 59 bytes!
                                              $endgroup$
                                              – Nick Kennedy
                                              Feb 27 at 18:49






                                            • 1




                                              $begingroup$
                                              @NickKennedy 58 bytes if you replace "" with 1.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 19:10
















                                            8












                                            $begingroup$


                                            R, 79 65 62 58 bytes





                                            write(substring(s<-scan(,""),1,c(1:(r=nchar(s)),r-1:r)),1)


                                            Try it online!



                                            -14 by Giuseppe's superior function knowledge



                                            -3 with cleaner indexing



                                            -4 thanks to Nick Kennedy and Giuseppe's move to scan and write



                                            Avoiding loops (and substr) is nice.






                                            share|improve this answer











                                            $endgroup$









                                            • 1




                                              $begingroup$
                                              loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 15:53








                                            • 1




                                              $begingroup$
                                              Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                              $endgroup$
                                              – CriminallyVulgar
                                              Feb 27 at 16:01






                                            • 1




                                              $begingroup$
                                              Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 16:06






                                            • 2




                                              $begingroup$
                                              How about Try it online! using scan and write? Only 59 bytes!
                                              $endgroup$
                                              – Nick Kennedy
                                              Feb 27 at 18:49






                                            • 1




                                              $begingroup$
                                              @NickKennedy 58 bytes if you replace "" with 1.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 19:10














                                            8












                                            8








                                            8





                                            $begingroup$


                                            R, 79 65 62 58 bytes





                                            write(substring(s<-scan(,""),1,c(1:(r=nchar(s)),r-1:r)),1)


                                            Try it online!



                                            -14 by Giuseppe's superior function knowledge



                                            -3 with cleaner indexing



                                            -4 thanks to Nick Kennedy and Giuseppe's move to scan and write



                                            Avoiding loops (and substr) is nice.






                                            share|improve this answer











                                            $endgroup$




                                            R, 79 65 62 58 bytes





                                            write(substring(s<-scan(,""),1,c(1:(r=nchar(s)),r-1:r)),1)


                                            Try it online!



                                            -14 by Giuseppe's superior function knowledge



                                            -3 with cleaner indexing



                                            -4 thanks to Nick Kennedy and Giuseppe's move to scan and write



                                            Avoiding loops (and substr) is nice.







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Feb 28 at 10:34

























                                            answered Feb 27 at 15:49









                                            CriminallyVulgarCriminallyVulgar

                                            37115




                                            37115








                                            • 1




                                              $begingroup$
                                              loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 15:53








                                            • 1




                                              $begingroup$
                                              Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                              $endgroup$
                                              – CriminallyVulgar
                                              Feb 27 at 16:01






                                            • 1




                                              $begingroup$
                                              Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 16:06






                                            • 2




                                              $begingroup$
                                              How about Try it online! using scan and write? Only 59 bytes!
                                              $endgroup$
                                              – Nick Kennedy
                                              Feb 27 at 18:49






                                            • 1




                                              $begingroup$
                                              @NickKennedy 58 bytes if you replace "" with 1.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 19:10














                                            • 1




                                              $begingroup$
                                              loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 15:53








                                            • 1




                                              $begingroup$
                                              Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                              $endgroup$
                                              – CriminallyVulgar
                                              Feb 27 at 16:01






                                            • 1




                                              $begingroup$
                                              Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 16:06






                                            • 2




                                              $begingroup$
                                              How about Try it online! using scan and write? Only 59 bytes!
                                              $endgroup$
                                              – Nick Kennedy
                                              Feb 27 at 18:49






                                            • 1




                                              $begingroup$
                                              @NickKennedy 58 bytes if you replace "" with 1.
                                              $endgroup$
                                              – Giuseppe
                                              Feb 27 at 19:10








                                            1




                                            1




                                            $begingroup$
                                            loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 15:53






                                            $begingroup$
                                            loops are thoroughly unnecessary, as is sapply -- substring will do what you want (with an additional trailing empty line), and for 65 bytes! I definitely wouldn't have thought of substring if I hadn't seen your nice use of substr here.
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 15:53






                                            1




                                            1




                                            $begingroup$
                                            Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                            $endgroup$
                                            – CriminallyVulgar
                                            Feb 27 at 16:01




                                            $begingroup$
                                            Haha, good catch! I think I've learned more about alternate functions for the same job from your edits than anywhere else at this point.
                                            $endgroup$
                                            – CriminallyVulgar
                                            Feb 27 at 16:01




                                            1




                                            1




                                            $begingroup$
                                            Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 16:06




                                            $begingroup$
                                            Haha, R has a stupid amount of synonyms with subtle differences. Every time I feel like I know the best tool for the job, I find something else that's slightly better in a weird edge case...
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 16:06




                                            2




                                            2




                                            $begingroup$
                                            How about Try it online! using scan and write? Only 59 bytes!
                                            $endgroup$
                                            – Nick Kennedy
                                            Feb 27 at 18:49




                                            $begingroup$
                                            How about Try it online! using scan and write? Only 59 bytes!
                                            $endgroup$
                                            – Nick Kennedy
                                            Feb 27 at 18:49




                                            1




                                            1




                                            $begingroup$
                                            @NickKennedy 58 bytes if you replace "" with 1.
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 19:10




                                            $begingroup$
                                            @NickKennedy 58 bytes if you replace "" with 1.
                                            $endgroup$
                                            – Giuseppe
                                            Feb 27 at 19:10











                                            6












                                            $begingroup$


                                            Python 3.8 (pre-release), 48 bytes





                                            lambda s,r='':(l:=[r:=r+c for c in s])+l[-2::-1]


                                            Try it online!



                                            Uses assignment expressions with := to accumulate a list of prefixes and then again to save the result to concatenate its reverse (without the first char).




                                            Python 2, 51 bytes





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l)or l+l[-2::-1]


                                            Try it online!



                                            We almost have the following nice 45-byte solution, but it has the original string twice and I don't see a short way to fix this.





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l+[s])or l


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$













                                            • $begingroup$
                                              Wouldn't you need to add some newline and print to get the desired output?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago










                                            • $begingroup$
                                              Something like print('n'.join(f(s))) ?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago












                                            • $begingroup$
                                              @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                              $endgroup$
                                              – xnor
                                              6 hours ago












                                            • $begingroup$
                                              Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                              $endgroup$
                                              – Jaden Travnik
                                              6 hours ago










                                            • $begingroup$
                                              @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                              $endgroup$
                                              – xnor
                                              6 hours ago


















                                            6












                                            $begingroup$


                                            Python 3.8 (pre-release), 48 bytes





                                            lambda s,r='':(l:=[r:=r+c for c in s])+l[-2::-1]


                                            Try it online!



                                            Uses assignment expressions with := to accumulate a list of prefixes and then again to save the result to concatenate its reverse (without the first char).




                                            Python 2, 51 bytes





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l)or l+l[-2::-1]


                                            Try it online!



                                            We almost have the following nice 45-byte solution, but it has the original string twice and I don't see a short way to fix this.





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l+[s])or l


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$













                                            • $begingroup$
                                              Wouldn't you need to add some newline and print to get the desired output?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago










                                            • $begingroup$
                                              Something like print('n'.join(f(s))) ?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago












                                            • $begingroup$
                                              @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                              $endgroup$
                                              – xnor
                                              6 hours ago












                                            • $begingroup$
                                              Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                              $endgroup$
                                              – Jaden Travnik
                                              6 hours ago










                                            • $begingroup$
                                              @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                              $endgroup$
                                              – xnor
                                              6 hours ago
















                                            6












                                            6








                                            6





                                            $begingroup$


                                            Python 3.8 (pre-release), 48 bytes





                                            lambda s,r='':(l:=[r:=r+c for c in s])+l[-2::-1]


                                            Try it online!



                                            Uses assignment expressions with := to accumulate a list of prefixes and then again to save the result to concatenate its reverse (without the first char).




                                            Python 2, 51 bytes





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l)or l+l[-2::-1]


                                            Try it online!



                                            We almost have the following nice 45-byte solution, but it has the original string twice and I don't see a short way to fix this.





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l+[s])or l


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$




                                            Python 3.8 (pre-release), 48 bytes





                                            lambda s,r='':(l:=[r:=r+c for c in s])+l[-2::-1]


                                            Try it online!



                                            Uses assignment expressions with := to accumulate a list of prefixes and then again to save the result to concatenate its reverse (without the first char).




                                            Python 2, 51 bytes





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l)or l+l[-2::-1]


                                            Try it online!



                                            We almost have the following nice 45-byte solution, but it has the original string twice and I don't see a short way to fix this.





                                            f=lambda s,l=[]:s and f(s[:-1],[s]+l+[s])or l


                                            Try it online!







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited 2 days ago

























                                            answered Feb 27 at 15:33









                                            xnorxnor

                                            91.5k18187443




                                            91.5k18187443












                                            • $begingroup$
                                              Wouldn't you need to add some newline and print to get the desired output?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago










                                            • $begingroup$
                                              Something like print('n'.join(f(s))) ?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago












                                            • $begingroup$
                                              @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                              $endgroup$
                                              – xnor
                                              6 hours ago












                                            • $begingroup$
                                              Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                              $endgroup$
                                              – Jaden Travnik
                                              6 hours ago










                                            • $begingroup$
                                              @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                              $endgroup$
                                              – xnor
                                              6 hours ago




















                                            • $begingroup$
                                              Wouldn't you need to add some newline and print to get the desired output?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago










                                            • $begingroup$
                                              Something like print('n'.join(f(s))) ?
                                              $endgroup$
                                              – Jaden Travnik
                                              7 hours ago












                                            • $begingroup$
                                              @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                              $endgroup$
                                              – xnor
                                              6 hours ago












                                            • $begingroup$
                                              Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                              $endgroup$
                                              – Jaden Travnik
                                              6 hours ago










                                            • $begingroup$
                                              @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                              $endgroup$
                                              – xnor
                                              6 hours ago


















                                            $begingroup$
                                            Wouldn't you need to add some newline and print to get the desired output?
                                            $endgroup$
                                            – Jaden Travnik
                                            7 hours ago




                                            $begingroup$
                                            Wouldn't you need to add some newline and print to get the desired output?
                                            $endgroup$
                                            – Jaden Travnik
                                            7 hours ago












                                            $begingroup$
                                            Something like print('n'.join(f(s))) ?
                                            $endgroup$
                                            – Jaden Travnik
                                            7 hours ago






                                            $begingroup$
                                            Something like print('n'.join(f(s))) ?
                                            $endgroup$
                                            – Jaden Travnik
                                            7 hours ago














                                            $begingroup$
                                            @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                            $endgroup$
                                            – xnor
                                            6 hours ago






                                            $begingroup$
                                            @JadenTravnik The community defaults (which this challenge follows) allow for functions in addition to programs. And the challenge author said in the comments that they are OK with a list of strings within joining as allowed by default, though I myself don't like this as a default and have downvoted it. See also the Python rules summary.
                                            $endgroup$
                                            – xnor
                                            6 hours ago














                                            $begingroup$
                                            Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                            $endgroup$
                                            – Jaden Travnik
                                            6 hours ago




                                            $begingroup$
                                            Huh. Ok, thanks for pointing that out. Im new ¯_(ツ)_/¯. If thats the case, here is a competing 45-byte solution: x=[s[:i+1]for i in range(len(s))];x+x[-2::-1]
                                            $endgroup$
                                            – Jaden Travnik
                                            6 hours ago












                                            $begingroup$
                                            @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                            $endgroup$
                                            – xnor
                                            6 hours ago






                                            $begingroup$
                                            @JadenTravnik No problem, the rules are unfortunately scattered over the place. Your example though is a snippet which are not allowed. It needs to do input and output like s=input();x=[s[:i+1]for i in range(len(s))];print x+x[-2::-1]. See the examples at the top here.
                                            $endgroup$
                                            – xnor
                                            6 hours ago













                                            5












                                            $begingroup$


                                            Charcoal, 5 bytes



                                            G^Lθθ


                                            Try it online! Link is to verbose version of code. Explanation: draws a filled polygon, ^ specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ specifies the length of those sides as being the length of the original input and the final θ specifies the fill string.






                                            share|improve this answer









                                            $endgroup$


















                                              5












                                              $begingroup$


                                              Charcoal, 5 bytes



                                              G^Lθθ


                                              Try it online! Link is to verbose version of code. Explanation: draws a filled polygon, ^ specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ specifies the length of those sides as being the length of the original input and the final θ specifies the fill string.






                                              share|improve this answer









                                              $endgroup$
















                                                5












                                                5








                                                5





                                                $begingroup$


                                                Charcoal, 5 bytes



                                                G^Lθθ


                                                Try it online! Link is to verbose version of code. Explanation: draws a filled polygon, ^ specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ specifies the length of those sides as being the length of the original input and the final θ specifies the fill string.






                                                share|improve this answer









                                                $endgroup$




                                                Charcoal, 5 bytes



                                                G^Lθθ


                                                Try it online! Link is to verbose version of code. Explanation: draws a filled polygon, ^ specifies that the sides are down right and down left (the polygon then automatically closes itself), Lθ specifies the length of those sides as being the length of the original input and the final θ specifies the fill string.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Feb 27 at 11:52









                                                NeilNeil

                                                81.3k745178




                                                81.3k745178























                                                    5












                                                    $begingroup$


                                                    C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes



                                                    Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)



                                                    a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))


                                                    Try it online!






                                                    share|improve this answer











                                                    $endgroup$


















                                                      5












                                                      $begingroup$


                                                      C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes



                                                      Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)



                                                      a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))


                                                      Try it online!






                                                      share|improve this answer











                                                      $endgroup$
















                                                        5












                                                        5








                                                        5





                                                        $begingroup$


                                                        C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes



                                                        Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)



                                                        a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))


                                                        Try it online!






                                                        share|improve this answer











                                                        $endgroup$




                                                        C# (Visual C# Interactive Compiler), 123 109 94 84 74 bytes



                                                        Assumes we can return a char array array (I believe we can, as a char array is a valid representation for a string and a string array is a valid representation for multiple lines)



                                                        a=>new int[a.Length*2-1].Select((b,i)=>a.SkipLast(Math.Abs(a.Length-i-1)))


                                                        Try it online!







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Feb 27 at 12:28

























                                                        answered Feb 27 at 11:12









                                                        someonesomeone

                                                        542417




                                                        542417























                                                            5












                                                            $begingroup$

                                                            PowerShell, 89 87 66 bytes



                                                            -2 bytes thanks to @AdmBorkBork



                                                            param($a)0..($d=$a.Length-1)|%{$b+=,-join$a[0..$_]};$b+$b[--$d..0]


                                                            Try it online!



                                                            It actually didn't work as specified before, sorry about that! I've edited it and also managed to shave some bytes off.






                                                            share|improve this answer











                                                            $endgroup$













                                                            • $begingroup$
                                                              You can --$d instead of ($d-1) to save a couple at the end.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 27 at 16:14










                                                            • $begingroup$
                                                              @AdmBorkBork Thanks.
                                                              $endgroup$
                                                              – Gabriel Mills
                                                              Feb 27 at 22:19










                                                            • $begingroup$
                                                              This doesn't work for single-character input, sadly.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 28 at 15:09
















                                                            5












                                                            $begingroup$

                                                            PowerShell, 89 87 66 bytes



                                                            -2 bytes thanks to @AdmBorkBork



                                                            param($a)0..($d=$a.Length-1)|%{$b+=,-join$a[0..$_]};$b+$b[--$d..0]


                                                            Try it online!



                                                            It actually didn't work as specified before, sorry about that! I've edited it and also managed to shave some bytes off.






                                                            share|improve this answer











                                                            $endgroup$













                                                            • $begingroup$
                                                              You can --$d instead of ($d-1) to save a couple at the end.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 27 at 16:14










                                                            • $begingroup$
                                                              @AdmBorkBork Thanks.
                                                              $endgroup$
                                                              – Gabriel Mills
                                                              Feb 27 at 22:19










                                                            • $begingroup$
                                                              This doesn't work for single-character input, sadly.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 28 at 15:09














                                                            5












                                                            5








                                                            5





                                                            $begingroup$

                                                            PowerShell, 89 87 66 bytes



                                                            -2 bytes thanks to @AdmBorkBork



                                                            param($a)0..($d=$a.Length-1)|%{$b+=,-join$a[0..$_]};$b+$b[--$d..0]


                                                            Try it online!



                                                            It actually didn't work as specified before, sorry about that! I've edited it and also managed to shave some bytes off.






                                                            share|improve this answer











                                                            $endgroup$



                                                            PowerShell, 89 87 66 bytes



                                                            -2 bytes thanks to @AdmBorkBork



                                                            param($a)0..($d=$a.Length-1)|%{$b+=,-join$a[0..$_]};$b+$b[--$d..0]


                                                            Try it online!



                                                            It actually didn't work as specified before, sorry about that! I've edited it and also managed to shave some bytes off.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Feb 27 at 22:19

























                                                            answered Feb 27 at 14:43









                                                            Gabriel MillsGabriel Mills

                                                            544212




                                                            544212












                                                            • $begingroup$
                                                              You can --$d instead of ($d-1) to save a couple at the end.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 27 at 16:14










                                                            • $begingroup$
                                                              @AdmBorkBork Thanks.
                                                              $endgroup$
                                                              – Gabriel Mills
                                                              Feb 27 at 22:19










                                                            • $begingroup$
                                                              This doesn't work for single-character input, sadly.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 28 at 15:09


















                                                            • $begingroup$
                                                              You can --$d instead of ($d-1) to save a couple at the end.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 27 at 16:14










                                                            • $begingroup$
                                                              @AdmBorkBork Thanks.
                                                              $endgroup$
                                                              – Gabriel Mills
                                                              Feb 27 at 22:19










                                                            • $begingroup$
                                                              This doesn't work for single-character input, sadly.
                                                              $endgroup$
                                                              – AdmBorkBork
                                                              Feb 28 at 15:09
















                                                            $begingroup$
                                                            You can --$d instead of ($d-1) to save a couple at the end.
                                                            $endgroup$
                                                            – AdmBorkBork
                                                            Feb 27 at 16:14




                                                            $begingroup$
                                                            You can --$d instead of ($d-1) to save a couple at the end.
                                                            $endgroup$
                                                            – AdmBorkBork
                                                            Feb 27 at 16:14












                                                            $begingroup$
                                                            @AdmBorkBork Thanks.
                                                            $endgroup$
                                                            – Gabriel Mills
                                                            Feb 27 at 22:19




                                                            $begingroup$
                                                            @AdmBorkBork Thanks.
                                                            $endgroup$
                                                            – Gabriel Mills
                                                            Feb 27 at 22:19












                                                            $begingroup$
                                                            This doesn't work for single-character input, sadly.
                                                            $endgroup$
                                                            – AdmBorkBork
                                                            Feb 28 at 15:09




                                                            $begingroup$
                                                            This doesn't work for single-character input, sadly.
                                                            $endgroup$
                                                            – AdmBorkBork
                                                            Feb 28 at 15:09











                                                            5












                                                            $begingroup$


                                                            Jelly, 5 4 bytes



                                                            -1 byte thanks to @JonathanAllan!



                                                            ¹ƤŒḄ


                                                            Try it online! I think this is my second Jelly answer? I don't know if this is optimal. I am more convinced of it being optimal. Returns an array of lines.



                                                            Explanation



                                                            ¹ƤŒḄ     input: "Hi!"
                                                            ¹Ƥ prefixes of the input: [["H"], ["H", "i"], ["H", "i", "!"]]
                                                            ŒḄ bounce, using each array: [["H"], ["H", "i"], ["H", "i", "!"], ["H", "i"], ["H"]]


                                                            Another approach, proposed by @JonathanAllan, is ;ŒḄ, which cumulatively reduces () concatenation (;), which is another way to generate prefixes.






                                                            share|improve this answer











                                                            $endgroup$













                                                            • $begingroup$
                                                              We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                              $endgroup$
                                                              – Jonathan Allan
                                                              Feb 28 at 13:50












                                                            • $begingroup$
                                                              @JonathanAllan thanks! very interesting :)
                                                              $endgroup$
                                                              – Conor O'Brien
                                                              Feb 28 at 17:15
















                                                            5












                                                            $begingroup$


                                                            Jelly, 5 4 bytes



                                                            -1 byte thanks to @JonathanAllan!



                                                            ¹ƤŒḄ


                                                            Try it online! I think this is my second Jelly answer? I don't know if this is optimal. I am more convinced of it being optimal. Returns an array of lines.



                                                            Explanation



                                                            ¹ƤŒḄ     input: "Hi!"
                                                            ¹Ƥ prefixes of the input: [["H"], ["H", "i"], ["H", "i", "!"]]
                                                            ŒḄ bounce, using each array: [["H"], ["H", "i"], ["H", "i", "!"], ["H", "i"], ["H"]]


                                                            Another approach, proposed by @JonathanAllan, is ;ŒḄ, which cumulatively reduces () concatenation (;), which is another way to generate prefixes.






                                                            share|improve this answer











                                                            $endgroup$













                                                            • $begingroup$
                                                              We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                              $endgroup$
                                                              – Jonathan Allan
                                                              Feb 28 at 13:50












                                                            • $begingroup$
                                                              @JonathanAllan thanks! very interesting :)
                                                              $endgroup$
                                                              – Conor O'Brien
                                                              Feb 28 at 17:15














                                                            5












                                                            5








                                                            5





                                                            $begingroup$


                                                            Jelly, 5 4 bytes



                                                            -1 byte thanks to @JonathanAllan!



                                                            ¹ƤŒḄ


                                                            Try it online! I think this is my second Jelly answer? I don't know if this is optimal. I am more convinced of it being optimal. Returns an array of lines.



                                                            Explanation



                                                            ¹ƤŒḄ     input: "Hi!"
                                                            ¹Ƥ prefixes of the input: [["H"], ["H", "i"], ["H", "i", "!"]]
                                                            ŒḄ bounce, using each array: [["H"], ["H", "i"], ["H", "i", "!"], ["H", "i"], ["H"]]


                                                            Another approach, proposed by @JonathanAllan, is ;ŒḄ, which cumulatively reduces () concatenation (;), which is another way to generate prefixes.






                                                            share|improve this answer











                                                            $endgroup$




                                                            Jelly, 5 4 bytes



                                                            -1 byte thanks to @JonathanAllan!



                                                            ¹ƤŒḄ


                                                            Try it online! I think this is my second Jelly answer? I don't know if this is optimal. I am more convinced of it being optimal. Returns an array of lines.



                                                            Explanation



                                                            ¹ƤŒḄ     input: "Hi!"
                                                            ¹Ƥ prefixes of the input: [["H"], ["H", "i"], ["H", "i", "!"]]
                                                            ŒḄ bounce, using each array: [["H"], ["H", "i"], ["H", "i", "!"], ["H", "i"], ["H"]]


                                                            Another approach, proposed by @JonathanAllan, is ;ŒḄ, which cumulatively reduces () concatenation (;), which is another way to generate prefixes.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Feb 28 at 17:14

























                                                            answered Feb 27 at 15:34









                                                            Conor O'BrienConor O'Brien

                                                            30.2k264162




                                                            30.2k264162












                                                            • $begingroup$
                                                              We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                              $endgroup$
                                                              – Jonathan Allan
                                                              Feb 28 at 13:50












                                                            • $begingroup$
                                                              @JonathanAllan thanks! very interesting :)
                                                              $endgroup$
                                                              – Conor O'Brien
                                                              Feb 28 at 17:15


















                                                            • $begingroup$
                                                              We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                              $endgroup$
                                                              – Jonathan Allan
                                                              Feb 28 at 13:50












                                                            • $begingroup$
                                                              @JonathanAllan thanks! very interesting :)
                                                              $endgroup$
                                                              – Conor O'Brien
                                                              Feb 28 at 17:15
















                                                            $begingroup$
                                                            We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                            $endgroup$
                                                            – Jonathan Allan
                                                            Feb 28 at 13:50






                                                            $begingroup$
                                                            We are allowed to yield an array of lines, so you can bump Y out of the code (I'd make the footer either ÇY or ÇŒṘ to avoid a full-program's implicit smashing print). On a side-note this is also equivalently implemented as ;ŒḄ for the same byte-count (also you can pass the argument as"blah" as Jelly interprets this as a list of characters - yours is actually a list of lists of characters, as you'll see if you make the footer ÇŒṘ)
                                                            $endgroup$
                                                            – Jonathan Allan
                                                            Feb 28 at 13:50














                                                            $begingroup$
                                                            @JonathanAllan thanks! very interesting :)
                                                            $endgroup$
                                                            – Conor O'Brien
                                                            Feb 28 at 17:15




                                                            $begingroup$
                                                            @JonathanAllan thanks! very interesting :)
                                                            $endgroup$
                                                            – Conor O'Brien
                                                            Feb 28 at 17:15











                                                            5












                                                            $begingroup$

                                                            IBM PC DOS, 8088 assembly, 44 bytes



                                                            be80 00ad 8bd6 b409 488a f88a c8d0 e149 b324 3acf 7d02 
                                                            4e4e 4686 1ccd 2186 1c52 ba29 01cd 215a e2ea c30d 0a24


                                                            Unassembled:



                                                                MOV  SI, 80H            ; point SI to DOS PSP
                                                            LODSW ; load arg length into AL, advance SI to 82H
                                                            MOV DX, SI ; save start of string pointer
                                                            MOV AH, 9 ; DOS API display string function
                                                            DEC AX ; remove leading space from string length
                                                            MOV BH, AL ; save string len in BH (AL gets mangled by INT 21H,9)
                                                            MOV CL, AL ; set up loop counter in CL
                                                            SHL CL, 1 ; number of lines = 2 * string length - 1
                                                            DEC CX
                                                            MOV BL, '$' ; end of string marker
                                                            LINE_LOOP:
                                                            CMP CL, BH ; if CL >= string length, ascend
                                                            JGE ASCEND
                                                            DEC SI ; descend by backing up two places (always increments)
                                                            DEC SI ; (this is fewer bytes than 'SUB SI, 2' or two branches)
                                                            ASCEND:
                                                            INC SI ; increment current string position
                                                            XCHG BL, [SI] ; swap current string byte with end of string delimiter
                                                            INT 21H ; write substring to console
                                                            XCHG BL, [SI] ; restore string byte
                                                            PUSH DX ; save output string pointer
                                                            MOV DX, OFFSET CRLF ; load CRLF string
                                                            INT 21H ; write to console
                                                            POP DX ; restore output string pointer
                                                            LOOP LINE_LOOP ; move to next line
                                                            RET
                                                            CRLF DB 0DH,0AH,'$'


                                                            Explanation



                                                            Loop 2 * input length - 1 for each row. The DOS API's string display function (INT 21H,9) writes a $-terminated string to the screen, so each time through the loop the character after the last to be displayed is swapped with the end-of-string terminator.



                                                            The loop counter is compared with the string length, and if it's greater (meaning the ascending part of the output) the string/swap position is incremented, otherwise it's decremented (actually it's -1-1+1 which is fewer bytes than an if/else branching structure).



                                                            Standalone executable program, takes input string from command line.



                                                            Output



                                                            enter image description here



                                                            Download YT.COM






                                                            share|improve this answer











                                                            $endgroup$


















                                                              5












                                                              $begingroup$

                                                              IBM PC DOS, 8088 assembly, 44 bytes



                                                              be80 00ad 8bd6 b409 488a f88a c8d0 e149 b324 3acf 7d02 
                                                              4e4e 4686 1ccd 2186 1c52 ba29 01cd 215a e2ea c30d 0a24


                                                              Unassembled:



                                                                  MOV  SI, 80H            ; point SI to DOS PSP
                                                              LODSW ; load arg length into AL, advance SI to 82H
                                                              MOV DX, SI ; save start of string pointer
                                                              MOV AH, 9 ; DOS API display string function
                                                              DEC AX ; remove leading space from string length
                                                              MOV BH, AL ; save string len in BH (AL gets mangled by INT 21H,9)
                                                              MOV CL, AL ; set up loop counter in CL
                                                              SHL CL, 1 ; number of lines = 2 * string length - 1
                                                              DEC CX
                                                              MOV BL, '$' ; end of string marker
                                                              LINE_LOOP:
                                                              CMP CL, BH ; if CL >= string length, ascend
                                                              JGE ASCEND
                                                              DEC SI ; descend by backing up two places (always increments)
                                                              DEC SI ; (this is fewer bytes than 'SUB SI, 2' or two branches)
                                                              ASCEND:
                                                              INC SI ; increment current string position
                                                              XCHG BL, [SI] ; swap current string byte with end of string delimiter
                                                              INT 21H ; write substring to console
                                                              XCHG BL, [SI] ; restore string byte
                                                              PUSH DX ; save output string pointer
                                                              MOV DX, OFFSET CRLF ; load CRLF string
                                                              INT 21H ; write to console
                                                              POP DX ; restore output string pointer
                                                              LOOP LINE_LOOP ; move to next line
                                                              RET
                                                              CRLF DB 0DH,0AH,'$'


                                                              Explanation



                                                              Loop 2 * input length - 1 for each row. The DOS API's string display function (INT 21H,9) writes a $-terminated string to the screen, so each time through the loop the character after the last to be displayed is swapped with the end-of-string terminator.



                                                              The loop counter is compared with the string length, and if it's greater (meaning the ascending part of the output) the string/swap position is incremented, otherwise it's decremented (actually it's -1-1+1 which is fewer bytes than an if/else branching structure).



                                                              Standalone executable program, takes input string from command line.



                                                              Output



                                                              enter image description here



                                                              Download YT.COM






                                                              share|improve this answer











                                                              $endgroup$
















                                                                5












                                                                5








                                                                5





                                                                $begingroup$

                                                                IBM PC DOS, 8088 assembly, 44 bytes



                                                                be80 00ad 8bd6 b409 488a f88a c8d0 e149 b324 3acf 7d02 
                                                                4e4e 4686 1ccd 2186 1c52 ba29 01cd 215a e2ea c30d 0a24


                                                                Unassembled:



                                                                    MOV  SI, 80H            ; point SI to DOS PSP
                                                                LODSW ; load arg length into AL, advance SI to 82H
                                                                MOV DX, SI ; save start of string pointer
                                                                MOV AH, 9 ; DOS API display string function
                                                                DEC AX ; remove leading space from string length
                                                                MOV BH, AL ; save string len in BH (AL gets mangled by INT 21H,9)
                                                                MOV CL, AL ; set up loop counter in CL
                                                                SHL CL, 1 ; number of lines = 2 * string length - 1
                                                                DEC CX
                                                                MOV BL, '$' ; end of string marker
                                                                LINE_LOOP:
                                                                CMP CL, BH ; if CL >= string length, ascend
                                                                JGE ASCEND
                                                                DEC SI ; descend by backing up two places (always increments)
                                                                DEC SI ; (this is fewer bytes than 'SUB SI, 2' or two branches)
                                                                ASCEND:
                                                                INC SI ; increment current string position
                                                                XCHG BL, [SI] ; swap current string byte with end of string delimiter
                                                                INT 21H ; write substring to console
                                                                XCHG BL, [SI] ; restore string byte
                                                                PUSH DX ; save output string pointer
                                                                MOV DX, OFFSET CRLF ; load CRLF string
                                                                INT 21H ; write to console
                                                                POP DX ; restore output string pointer
                                                                LOOP LINE_LOOP ; move to next line
                                                                RET
                                                                CRLF DB 0DH,0AH,'$'


                                                                Explanation



                                                                Loop 2 * input length - 1 for each row. The DOS API's string display function (INT 21H,9) writes a $-terminated string to the screen, so each time through the loop the character after the last to be displayed is swapped with the end-of-string terminator.



                                                                The loop counter is compared with the string length, and if it's greater (meaning the ascending part of the output) the string/swap position is incremented, otherwise it's decremented (actually it's -1-1+1 which is fewer bytes than an if/else branching structure).



                                                                Standalone executable program, takes input string from command line.



                                                                Output



                                                                enter image description here



                                                                Download YT.COM






                                                                share|improve this answer











                                                                $endgroup$



                                                                IBM PC DOS, 8088 assembly, 44 bytes



                                                                be80 00ad 8bd6 b409 488a f88a c8d0 e149 b324 3acf 7d02 
                                                                4e4e 4686 1ccd 2186 1c52 ba29 01cd 215a e2ea c30d 0a24


                                                                Unassembled:



                                                                    MOV  SI, 80H            ; point SI to DOS PSP
                                                                LODSW ; load arg length into AL, advance SI to 82H
                                                                MOV DX, SI ; save start of string pointer
                                                                MOV AH, 9 ; DOS API display string function
                                                                DEC AX ; remove leading space from string length
                                                                MOV BH, AL ; save string len in BH (AL gets mangled by INT 21H,9)
                                                                MOV CL, AL ; set up loop counter in CL
                                                                SHL CL, 1 ; number of lines = 2 * string length - 1
                                                                DEC CX
                                                                MOV BL, '$' ; end of string marker
                                                                LINE_LOOP:
                                                                CMP CL, BH ; if CL >= string length, ascend
                                                                JGE ASCEND
                                                                DEC SI ; descend by backing up two places (always increments)
                                                                DEC SI ; (this is fewer bytes than 'SUB SI, 2' or two branches)
                                                                ASCEND:
                                                                INC SI ; increment current string position
                                                                XCHG BL, [SI] ; swap current string byte with end of string delimiter
                                                                INT 21H ; write substring to console
                                                                XCHG BL, [SI] ; restore string byte
                                                                PUSH DX ; save output string pointer
                                                                MOV DX, OFFSET CRLF ; load CRLF string
                                                                INT 21H ; write to console
                                                                POP DX ; restore output string pointer
                                                                LOOP LINE_LOOP ; move to next line
                                                                RET
                                                                CRLF DB 0DH,0AH,'$'


                                                                Explanation



                                                                Loop 2 * input length - 1 for each row. The DOS API's string display function (INT 21H,9) writes a $-terminated string to the screen, so each time through the loop the character after the last to be displayed is swapped with the end-of-string terminator.



                                                                The loop counter is compared with the string length, and if it's greater (meaning the ascending part of the output) the string/swap position is incremented, otherwise it's decremented (actually it's -1-1+1 which is fewer bytes than an if/else branching structure).



                                                                Standalone executable program, takes input string from command line.



                                                                Output



                                                                enter image description here



                                                                Download YT.COM







                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited yesterday

























                                                                answered 2 days ago









                                                                gwaughgwaugh

                                                                1,335514




                                                                1,335514























                                                                    4












                                                                    $begingroup$


                                                                    APL (Dyalog Unicode), 9 bytesSBCS





                                                                    Anonymous tacit prefix function. Returns list of strings.



                                                                    (⊢,1↓⌽),


                                                                    Try it online!



                                                                    , the list of prefixes (lit, the cumulative concatenation)



                                                                    () apply the following function to that list:



                                                                     the reversed list



                                                                    1↓ drop the first item



                                                                    , prepend



                                                                     the unmodified list






                                                                    share|improve this answer











                                                                    $endgroup$


















                                                                      4












                                                                      $begingroup$


                                                                      APL (Dyalog Unicode), 9 bytesSBCS





                                                                      Anonymous tacit prefix function. Returns list of strings.



                                                                      (⊢,1↓⌽),


                                                                      Try it online!



                                                                      , the list of prefixes (lit, the cumulative concatenation)



                                                                      () apply the following function to that list:



                                                                       the reversed list



                                                                      1↓ drop the first item



                                                                      , prepend



                                                                       the unmodified list






                                                                      share|improve this answer











                                                                      $endgroup$
















                                                                        4












                                                                        4








                                                                        4





                                                                        $begingroup$


                                                                        APL (Dyalog Unicode), 9 bytesSBCS





                                                                        Anonymous tacit prefix function. Returns list of strings.



                                                                        (⊢,1↓⌽),


                                                                        Try it online!



                                                                        , the list of prefixes (lit, the cumulative concatenation)



                                                                        () apply the following function to that list:



                                                                         the reversed list



                                                                        1↓ drop the first item



                                                                        , prepend



                                                                         the unmodified list






                                                                        share|improve this answer











                                                                        $endgroup$




                                                                        APL (Dyalog Unicode), 9 bytesSBCS





                                                                        Anonymous tacit prefix function. Returns list of strings.



                                                                        (⊢,1↓⌽),


                                                                        Try it online!



                                                                        , the list of prefixes (lit, the cumulative concatenation)



                                                                        () apply the following function to that list:



                                                                         the reversed list



                                                                        1↓ drop the first item



                                                                        , prepend



                                                                         the unmodified list







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Feb 27 at 11:51

























                                                                        answered Feb 27 at 11:46









                                                                        AdámAdám

                                                                        29k276204




                                                                        29k276204























                                                                            4












                                                                            $begingroup$


                                                                            Ruby, 51 42 40 bytes





                                                                            f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}


                                                                            Try it online!



                                                                            Thanks to Doorknob for -2 bytes.






                                                                            share|improve this answer











                                                                            $endgroup$









                                                                            • 1




                                                                              $begingroup$
                                                                              You can save 2 bytes by replacing ... with ,
                                                                              $endgroup$
                                                                              – Doorknob
                                                                              Feb 27 at 13:17
















                                                                            4












                                                                            $begingroup$


                                                                            Ruby, 51 42 40 bytes





                                                                            f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}


                                                                            Try it online!



                                                                            Thanks to Doorknob for -2 bytes.






                                                                            share|improve this answer











                                                                            $endgroup$









                                                                            • 1




                                                                              $begingroup$
                                                                              You can save 2 bytes by replacing ... with ,
                                                                              $endgroup$
                                                                              – Doorknob
                                                                              Feb 27 at 13:17














                                                                            4












                                                                            4








                                                                            4





                                                                            $begingroup$


                                                                            Ruby, 51 42 40 bytes





                                                                            f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}


                                                                            Try it online!



                                                                            Thanks to Doorknob for -2 bytes.






                                                                            share|improve this answer











                                                                            $endgroup$




                                                                            Ruby, 51 42 40 bytes





                                                                            f=->s,i=1{s[i]?[t=s[0,i],*f[s,i+1],t]:s}


                                                                            Try it online!



                                                                            Thanks to Doorknob for -2 bytes.







                                                                            share|improve this answer














                                                                            share|improve this answer



                                                                            share|improve this answer








                                                                            edited Feb 27 at 13:20

























                                                                            answered Feb 27 at 10:44









                                                                            Kirill L.Kirill L.

                                                                            4,9251525




                                                                            4,9251525








                                                                            • 1




                                                                              $begingroup$
                                                                              You can save 2 bytes by replacing ... with ,
                                                                              $endgroup$
                                                                              – Doorknob
                                                                              Feb 27 at 13:17














                                                                            • 1




                                                                              $begingroup$
                                                                              You can save 2 bytes by replacing ... with ,
                                                                              $endgroup$
                                                                              – Doorknob
                                                                              Feb 27 at 13:17








                                                                            1




                                                                            1




                                                                            $begingroup$
                                                                            You can save 2 bytes by replacing ... with ,
                                                                            $endgroup$
                                                                            – Doorknob
                                                                            Feb 27 at 13:17




                                                                            $begingroup$
                                                                            You can save 2 bytes by replacing ... with ,
                                                                            $endgroup$
                                                                            – Doorknob
                                                                            Feb 27 at 13:17











                                                                            4












                                                                            $begingroup$


                                                                            JavaScript (Node.js), 90 bytes



                                                                            This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!





                                                                            s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}


                                                                            Try it online!






                                                                            share|improve this answer









                                                                            $endgroup$


















                                                                              4












                                                                              $begingroup$


                                                                              JavaScript (Node.js), 90 bytes



                                                                              This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!





                                                                              s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}


                                                                              Try it online!






                                                                              share|improve this answer









                                                                              $endgroup$
















                                                                                4












                                                                                4








                                                                                4





                                                                                $begingroup$


                                                                                JavaScript (Node.js), 90 bytes



                                                                                This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!





                                                                                s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}


                                                                                Try it online!






                                                                                share|improve this answer









                                                                                $endgroup$




                                                                                JavaScript (Node.js), 90 bytes



                                                                                This can probably be golfed alot more, Arnauld already has a way shorter one but I had fun atleast!





                                                                                s=>{a=[];for(c=s.length-1;c--;)a[c]=s.slice(0,c+1);return[...a,s,...a.reverse()].join`n`}


                                                                                Try it online!







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Feb 27 at 14:23









                                                                                T. DirksT. Dirks

                                                                                1765




                                                                                1765























                                                                                    4












                                                                                    $begingroup$


                                                                                    Attache, 15 bytes



                                                                                    Bounce@Prefixes


                                                                                    Try it online!



                                                                                    Pretty simple. Bounces (appends reverse without center) the Prefixes of the input.



                                                                                    Alternatively, 21 bytes: Bounce@{_[0..0:~-#_]}, re-implementing prefix.






                                                                                    share|improve this answer









                                                                                    $endgroup$


















                                                                                      4












                                                                                      $begingroup$


                                                                                      Attache, 15 bytes



                                                                                      Bounce@Prefixes


                                                                                      Try it online!



                                                                                      Pretty simple. Bounces (appends reverse without center) the Prefixes of the input.



                                                                                      Alternatively, 21 bytes: Bounce@{_[0..0:~-#_]}, re-implementing prefix.






                                                                                      share|improve this answer









                                                                                      $endgroup$
















                                                                                        4












                                                                                        4








                                                                                        4





                                                                                        $begingroup$


                                                                                        Attache, 15 bytes



                                                                                        Bounce@Prefixes


                                                                                        Try it online!



                                                                                        Pretty simple. Bounces (appends reverse without center) the Prefixes of the input.



                                                                                        Alternatively, 21 bytes: Bounce@{_[0..0:~-#_]}, re-implementing prefix.






                                                                                        share|improve this answer









                                                                                        $endgroup$




                                                                                        Attache, 15 bytes



                                                                                        Bounce@Prefixes


                                                                                        Try it online!



                                                                                        Pretty simple. Bounces (appends reverse without center) the Prefixes of the input.



                                                                                        Alternatively, 21 bytes: Bounce@{_[0..0:~-#_]}, re-implementing prefix.







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Feb 27 at 15:35









                                                                                        Conor O'BrienConor O'Brien

                                                                                        30.2k264162




                                                                                        30.2k264162























                                                                                            4












                                                                                            $begingroup$


                                                                                            F# (.NET Core), 67 61 bytes





                                                                                            let l=s.Length
                                                                                            [1..l*2-1]|>Seq.map(fun i->s.[..l-abs(i-l)-1])


                                                                                            Try it online!



                                                                                            Input is a string and output is a seq<string>



                                                                                            Another solution could be let f(s:string)=for i=1 to s.Length*2-1 do printfn"%s"s.[..s.Length-abs(i-s.Length)-1] for 80ish bytes... I am not sure that it is worth looking into.






                                                                                            share|improve this answer











                                                                                            $endgroup$


















                                                                                              4












                                                                                              $begingroup$


                                                                                              F# (.NET Core), 67 61 bytes





                                                                                              let l=s.Length
                                                                                              [1..l*2-1]|>Seq.map(fun i->s.[..l-abs(i-l)-1])


                                                                                              Try it online!



                                                                                              Input is a string and output is a seq<string>



                                                                                              Another solution could be let f(s:string)=for i=1 to s.Length*2-1 do printfn"%s"s.[..s.Length-abs(i-s.Length)-1] for 80ish bytes... I am not sure that it is worth looking into.






                                                                                              share|improve this answer











                                                                                              $endgroup$
















                                                                                                4












                                                                                                4








                                                                                                4





                                                                                                $begingroup$


                                                                                                F# (.NET Core), 67 61 bytes





                                                                                                let l=s.Length
                                                                                                [1..l*2-1]|>Seq.map(fun i->s.[..l-abs(i-l)-1])


                                                                                                Try it online!



                                                                                                Input is a string and output is a seq<string>



                                                                                                Another solution could be let f(s:string)=for i=1 to s.Length*2-1 do printfn"%s"s.[..s.Length-abs(i-s.Length)-1] for 80ish bytes... I am not sure that it is worth looking into.






                                                                                                share|improve this answer











                                                                                                $endgroup$




                                                                                                F# (.NET Core), 67 61 bytes





                                                                                                let l=s.Length
                                                                                                [1..l*2-1]|>Seq.map(fun i->s.[..l-abs(i-l)-1])


                                                                                                Try it online!



                                                                                                Input is a string and output is a seq<string>



                                                                                                Another solution could be let f(s:string)=for i=1 to s.Length*2-1 do printfn"%s"s.[..s.Length-abs(i-s.Length)-1] for 80ish bytes... I am not sure that it is worth looking into.







                                                                                                share|improve this answer














                                                                                                share|improve this answer



                                                                                                share|improve this answer








                                                                                                edited Feb 27 at 22:37

























                                                                                                answered Feb 27 at 22:20









                                                                                                aloisdgaloisdg

                                                                                                1,4041122




                                                                                                1,4041122























                                                                                                    4












                                                                                                    $begingroup$


                                                                                                    PowerShell, 46 bytes





                                                                                                    ($l=$args|% t*y|%{($s+=$_);++$i})+$l[$i..0]|gu


                                                                                                    Try it online!






                                                                                                    PowerShell, 42 bytes (YouTube special, dirty)



                                                                                                    It is known that the maximum length of a comment on youtube is 10,000 characters. Ok, use this as the upper limit.





                                                                                                    ($l=$args|% t*y|%{($s+=$_)})+$l[1e4..0]|gu


                                                                                                    Try it online!






                                                                                                    share|improve this answer











                                                                                                    $endgroup$


















                                                                                                      4












                                                                                                      $begingroup$


                                                                                                      PowerShell, 46 bytes





                                                                                                      ($l=$args|% t*y|%{($s+=$_);++$i})+$l[$i..0]|gu


                                                                                                      Try it online!






                                                                                                      PowerShell, 42 bytes (YouTube special, dirty)



                                                                                                      It is known that the maximum length of a comment on youtube is 10,000 characters. Ok, use this as the upper limit.





                                                                                                      ($l=$args|% t*y|%{($s+=$_)})+$l[1e4..0]|gu


                                                                                                      Try it online!






                                                                                                      share|improve this answer











                                                                                                      $endgroup$
















                                                                                                        4












                                                                                                        4








                                                                                                        4





                                                                                                        $begingroup$


                                                                                                        PowerShell, 46 bytes





                                                                                                        ($l=$args|% t*y|%{($s+=$_);++$i})+$l[$i..0]|gu


                                                                                                        Try it online!






                                                                                                        PowerShell, 42 bytes (YouTube special, dirty)



                                                                                                        It is known that the maximum length of a comment on youtube is 10,000 characters. Ok, use this as the upper limit.





                                                                                                        ($l=$args|% t*y|%{($s+=$_)})+$l[1e4..0]|gu


                                                                                                        Try it online!






                                                                                                        share|improve this answer











                                                                                                        $endgroup$




                                                                                                        PowerShell, 46 bytes





                                                                                                        ($l=$args|% t*y|%{($s+=$_);++$i})+$l[$i..0]|gu


                                                                                                        Try it online!






                                                                                                        PowerShell, 42 bytes (YouTube special, dirty)



                                                                                                        It is known that the maximum length of a comment on youtube is 10,000 characters. Ok, use this as the upper limit.





                                                                                                        ($l=$args|% t*y|%{($s+=$_)})+$l[1e4..0]|gu


                                                                                                        Try it online!







                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited Feb 28 at 5:14

























                                                                                                        answered Feb 28 at 4:30









                                                                                                        mazzymazzy

                                                                                                        2,6351316




                                                                                                        2,6351316























                                                                                                            4












                                                                                                            $begingroup$


                                                                                                            C (gcc), 68 67 + 3 bytes





                                                                                                            i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}


                                                                                                            Try it online!



                                                                                                            if you want reusable version, it is below.



                                                                                                            i,j,t;f(char*s){for(j=0;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
                                                                                                            ^^^


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$













                                                                                                            • $begingroup$
                                                                                                              Does not appear to be reusable.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 12:50










                                                                                                            • $begingroup$
                                                                                                              @gastropner what do you mean, not reusable?
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:12










                                                                                                            • $begingroup$
                                                                                                              @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 17:13










                                                                                                            • $begingroup$
                                                                                                              @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:16








                                                                                                            • 3




                                                                                                              $begingroup$
                                                                                                              @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 18:32
















                                                                                                            4












                                                                                                            $begingroup$


                                                                                                            C (gcc), 68 67 + 3 bytes





                                                                                                            i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}


                                                                                                            Try it online!



                                                                                                            if you want reusable version, it is below.



                                                                                                            i,j,t;f(char*s){for(j=0;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
                                                                                                            ^^^


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$













                                                                                                            • $begingroup$
                                                                                                              Does not appear to be reusable.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 12:50










                                                                                                            • $begingroup$
                                                                                                              @gastropner what do you mean, not reusable?
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:12










                                                                                                            • $begingroup$
                                                                                                              @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 17:13










                                                                                                            • $begingroup$
                                                                                                              @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:16








                                                                                                            • 3




                                                                                                              $begingroup$
                                                                                                              @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 18:32














                                                                                                            4












                                                                                                            4








                                                                                                            4





                                                                                                            $begingroup$


                                                                                                            C (gcc), 68 67 + 3 bytes





                                                                                                            i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}


                                                                                                            Try it online!



                                                                                                            if you want reusable version, it is below.



                                                                                                            i,j,t;f(char*s){for(j=0;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
                                                                                                            ^^^


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$




                                                                                                            C (gcc), 68 67 + 3 bytes





                                                                                                            i,j,t;f(char*s){for(;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}


                                                                                                            Try it online!



                                                                                                            if you want reusable version, it is below.



                                                                                                            i,j,t;f(char*s){for(j=0;j?--i:++i;puts(s),j+=!t,s[i]=t)t=s[i],s[i]=0;}
                                                                                                            ^^^


                                                                                                            Try it online!







                                                                                                            share|improve this answer














                                                                                                            share|improve this answer



                                                                                                            share|improve this answer








                                                                                                            edited 2 days ago

























                                                                                                            answered Feb 27 at 10:42









                                                                                                            jaeyong sungjaeyong sung

                                                                                                            1096




                                                                                                            1096












                                                                                                            • $begingroup$
                                                                                                              Does not appear to be reusable.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 12:50










                                                                                                            • $begingroup$
                                                                                                              @gastropner what do you mean, not reusable?
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:12










                                                                                                            • $begingroup$
                                                                                                              @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 17:13










                                                                                                            • $begingroup$
                                                                                                              @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:16








                                                                                                            • 3




                                                                                                              $begingroup$
                                                                                                              @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 18:32


















                                                                                                            • $begingroup$
                                                                                                              Does not appear to be reusable.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 12:50










                                                                                                            • $begingroup$
                                                                                                              @gastropner what do you mean, not reusable?
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:12










                                                                                                            • $begingroup$
                                                                                                              @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 17:13










                                                                                                            • $begingroup$
                                                                                                              @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                              $endgroup$
                                                                                                              – Baldrickk
                                                                                                              Feb 28 at 17:16








                                                                                                            • 3




                                                                                                              $begingroup$
                                                                                                              @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                              $endgroup$
                                                                                                              – gastropner
                                                                                                              Feb 28 at 18:32
















                                                                                                            $begingroup$
                                                                                                            Does not appear to be reusable.
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 12:50




                                                                                                            $begingroup$
                                                                                                            Does not appear to be reusable.
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 12:50












                                                                                                            $begingroup$
                                                                                                            @gastropner what do you mean, not reusable?
                                                                                                            $endgroup$
                                                                                                            – Baldrickk
                                                                                                            Feb 28 at 17:12




                                                                                                            $begingroup$
                                                                                                            @gastropner what do you mean, not reusable?
                                                                                                            $endgroup$
                                                                                                            – Baldrickk
                                                                                                            Feb 28 at 17:12












                                                                                                            $begingroup$
                                                                                                            @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 17:13




                                                                                                            $begingroup$
                                                                                                            @Baldrickk If you call the function again with a new string, it doesn't work.
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 17:13












                                                                                                            $begingroup$
                                                                                                            @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                            $endgroup$
                                                                                                            – Baldrickk
                                                                                                            Feb 28 at 17:16






                                                                                                            $begingroup$
                                                                                                            @gastropner so? Since when was that a requirement? It works fine running the program again with a new string.
                                                                                                            $endgroup$
                                                                                                            – Baldrickk
                                                                                                            Feb 28 at 17:16






                                                                                                            3




                                                                                                            3




                                                                                                            $begingroup$
                                                                                                            @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 18:32




                                                                                                            $begingroup$
                                                                                                            @Baldrickk https://codegolf.meta.stackexchange.com/a/4940/758869
                                                                                                            $endgroup$
                                                                                                            – gastropner
                                                                                                            Feb 28 at 18:32











                                                                                                            4












                                                                                                            $begingroup$


                                                                                                            J, 12 bytes



                                                                                                            ],[:}.@|.]


                                                                                                            Try it online!



                                                                                                            Still 1 byte longer than Adám's




                                                                                                            K (oK), 12 11 bytes



                                                                                                            -1 byte thanks to ngn



                                                                                                            {x,1_|x}@,


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$









                                                                                                            • 2




                                                                                                              $begingroup$
                                                                                                              Did I outgolf the master‽
                                                                                                              $endgroup$
                                                                                                              – Adám
                                                                                                              Feb 27 at 11:56










                                                                                                            • $begingroup$
                                                                                                              @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              Feb 27 at 12:00






                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              -1 byte for oK: {x,1_|x}@,
                                                                                                              $endgroup$
                                                                                                              – ngn
                                                                                                              Feb 28 at 22:31












                                                                                                            • $begingroup$
                                                                                                              @ngn Thank you!
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              2 days ago
















                                                                                                            4












                                                                                                            $begingroup$


                                                                                                            J, 12 bytes



                                                                                                            ],[:}.@|.]


                                                                                                            Try it online!



                                                                                                            Still 1 byte longer than Adám's




                                                                                                            K (oK), 12 11 bytes



                                                                                                            -1 byte thanks to ngn



                                                                                                            {x,1_|x}@,


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$









                                                                                                            • 2




                                                                                                              $begingroup$
                                                                                                              Did I outgolf the master‽
                                                                                                              $endgroup$
                                                                                                              – Adám
                                                                                                              Feb 27 at 11:56










                                                                                                            • $begingroup$
                                                                                                              @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              Feb 27 at 12:00






                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              -1 byte for oK: {x,1_|x}@,
                                                                                                              $endgroup$
                                                                                                              – ngn
                                                                                                              Feb 28 at 22:31












                                                                                                            • $begingroup$
                                                                                                              @ngn Thank you!
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              2 days ago














                                                                                                            4












                                                                                                            4








                                                                                                            4





                                                                                                            $begingroup$


                                                                                                            J, 12 bytes



                                                                                                            ],[:}.@|.]


                                                                                                            Try it online!



                                                                                                            Still 1 byte longer than Adám's




                                                                                                            K (oK), 12 11 bytes



                                                                                                            -1 byte thanks to ngn



                                                                                                            {x,1_|x}@,


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$




                                                                                                            J, 12 bytes



                                                                                                            ],[:}.@|.]


                                                                                                            Try it online!



                                                                                                            Still 1 byte longer than Adám's




                                                                                                            K (oK), 12 11 bytes



                                                                                                            -1 byte thanks to ngn



                                                                                                            {x,1_|x}@,


                                                                                                            Try it online!







                                                                                                            share|improve this answer














                                                                                                            share|improve this answer



                                                                                                            share|improve this answer








                                                                                                            edited 2 days ago

























                                                                                                            answered Feb 27 at 11:31









                                                                                                            Galen IvanovGalen Ivanov

                                                                                                            6,91711034




                                                                                                            6,91711034








                                                                                                            • 2




                                                                                                              $begingroup$
                                                                                                              Did I outgolf the master‽
                                                                                                              $endgroup$
                                                                                                              – Adám
                                                                                                              Feb 27 at 11:56










                                                                                                            • $begingroup$
                                                                                                              @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              Feb 27 at 12:00






                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              -1 byte for oK: {x,1_|x}@,
                                                                                                              $endgroup$
                                                                                                              – ngn
                                                                                                              Feb 28 at 22:31












                                                                                                            • $begingroup$
                                                                                                              @ngn Thank you!
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              2 days ago














                                                                                                            • 2




                                                                                                              $begingroup$
                                                                                                              Did I outgolf the master‽
                                                                                                              $endgroup$
                                                                                                              – Adám
                                                                                                              Feb 27 at 11:56










                                                                                                            • $begingroup$
                                                                                                              @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              Feb 27 at 12:00






                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              -1 byte for oK: {x,1_|x}@,
                                                                                                              $endgroup$
                                                                                                              – ngn
                                                                                                              Feb 28 at 22:31












                                                                                                            • $begingroup$
                                                                                                              @ngn Thank you!
                                                                                                              $endgroup$
                                                                                                              – Galen Ivanov
                                                                                                              2 days ago








                                                                                                            2




                                                                                                            2




                                                                                                            $begingroup$
                                                                                                            Did I outgolf the master‽
                                                                                                            $endgroup$
                                                                                                            – Adám
                                                                                                            Feb 27 at 11:56




                                                                                                            $begingroup$
                                                                                                            Did I outgolf the master‽
                                                                                                            $endgroup$
                                                                                                            – Adám
                                                                                                            Feb 27 at 11:56












                                                                                                            $begingroup$
                                                                                                            @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                            $endgroup$
                                                                                                            – Galen Ivanov
                                                                                                            Feb 27 at 12:00




                                                                                                            $begingroup$
                                                                                                            @Adám I'm far from being a J master :) There are many J coders here better than I am.
                                                                                                            $endgroup$
                                                                                                            – Galen Ivanov
                                                                                                            Feb 27 at 12:00




                                                                                                            1




                                                                                                            1




                                                                                                            $begingroup$
                                                                                                            -1 byte for oK: {x,1_|x}@,
                                                                                                            $endgroup$
                                                                                                            – ngn
                                                                                                            Feb 28 at 22:31






                                                                                                            $begingroup$
                                                                                                            -1 byte for oK: {x,1_|x}@,
                                                                                                            $endgroup$
                                                                                                            – ngn
                                                                                                            Feb 28 at 22:31














                                                                                                            $begingroup$
                                                                                                            @ngn Thank you!
                                                                                                            $endgroup$
                                                                                                            – Galen Ivanov
                                                                                                            2 days ago




                                                                                                            $begingroup$
                                                                                                            @ngn Thank you!
                                                                                                            $endgroup$
                                                                                                            – Galen Ivanov
                                                                                                            2 days ago











                                                                                                            3












                                                                                                            $begingroup$


                                                                                                            Octave, 58 bytes





                                                                                                            for k=1:(n=nnz(s=input(''))*2)-1
                                                                                                            disp(s(1:min(k,n-k)))
                                                                                                            end


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$









                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                              $endgroup$
                                                                                                              – Wolfie
                                                                                                              2 days ago










                                                                                                            • $begingroup$
                                                                                                              @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                              $endgroup$
                                                                                                              – Luis Mendo
                                                                                                              2 days ago
















                                                                                                            3












                                                                                                            $begingroup$


                                                                                                            Octave, 58 bytes





                                                                                                            for k=1:(n=nnz(s=input(''))*2)-1
                                                                                                            disp(s(1:min(k,n-k)))
                                                                                                            end


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$









                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                              $endgroup$
                                                                                                              – Wolfie
                                                                                                              2 days ago










                                                                                                            • $begingroup$
                                                                                                              @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                              $endgroup$
                                                                                                              – Luis Mendo
                                                                                                              2 days ago














                                                                                                            3












                                                                                                            3








                                                                                                            3





                                                                                                            $begingroup$


                                                                                                            Octave, 58 bytes





                                                                                                            for k=1:(n=nnz(s=input(''))*2)-1
                                                                                                            disp(s(1:min(k,n-k)))
                                                                                                            end


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$




                                                                                                            Octave, 58 bytes





                                                                                                            for k=1:(n=nnz(s=input(''))*2)-1
                                                                                                            disp(s(1:min(k,n-k)))
                                                                                                            end


                                                                                                            Try it online!







                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered Feb 27 at 14:01









                                                                                                            Luis MendoLuis Mendo

                                                                                                            74.6k888291




                                                                                                            74.6k888291








                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                              $endgroup$
                                                                                                              – Wolfie
                                                                                                              2 days ago










                                                                                                            • $begingroup$
                                                                                                              @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                              $endgroup$
                                                                                                              – Luis Mendo
                                                                                                              2 days ago














                                                                                                            • 1




                                                                                                              $begingroup$
                                                                                                              I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                              $endgroup$
                                                                                                              – Wolfie
                                                                                                              2 days ago










                                                                                                            • $begingroup$
                                                                                                              @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                              $endgroup$
                                                                                                              – Luis Mendo
                                                                                                              2 days ago








                                                                                                            1




                                                                                                            1




                                                                                                            $begingroup$
                                                                                                            I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                            $endgroup$
                                                                                                            – Wolfie
                                                                                                            2 days ago




                                                                                                            $begingroup$
                                                                                                            I came up with essentially the same answer in MATLAB before I saw yours, but you get to take shortcuts in Octave with those compound assignments saving several bytes... I did briefly consider if any char maps to zero, such that nnz would miss it?
                                                                                                            $endgroup$
                                                                                                            – Wolfie
                                                                                                            2 days ago












                                                                                                            $begingroup$
                                                                                                            @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                            $endgroup$
                                                                                                            – Luis Mendo
                                                                                                            2 days ago




                                                                                                            $begingroup$
                                                                                                            @Wolfie Somehow I assumed the input would not contain char(0), but you are right, it might be the case. I've asked for the OP if we can assume the standard ASCII range 32--127
                                                                                                            $endgroup$
                                                                                                            – Luis Mendo
                                                                                                            2 days ago











                                                                                                            3












                                                                                                            $begingroup$


                                                                                                            SNOBOL4 (CSNOBOL4), 118 bytes



                                                                                                            	N =INPUT
                                                                                                            L =1
                                                                                                            1 X =LT(X,SIZE(N)) X + 1 :F(D)
                                                                                                            O N ARB . OUTPUT POS(X) :($L)
                                                                                                            D X =GT(X) X - 1 :F(END)
                                                                                                            L ='D' :(O)
                                                                                                            END


                                                                                                            Try it online!



                                                                                                            There appears to be a bug in this implementation of SNOBOL; attempting to replace the label D with the label 2 causes an error, although the manual for Vanilla SNOBOL indicates that (emphasis added)




                                                                                                            If a label is present, it must begin with the first character of the line. Labels provide a name for the statement, and serve as the target for transfer of control from the GOTO field of any statement. Labels must begin with a letter or digit, optionally followed by an arbitrary string of characters. The label field is terminated by the character blank, tab, or semicolon. If the first character of a line is blank or tab, the label field is absent.




                                                                                                            My supposition is that the CSNOBOL interpreter only supports a single label that begins with an integer.






                                                                                                            share|improve this answer









                                                                                                            $endgroup$


















                                                                                                              3












                                                                                                              $begingroup$


                                                                                                              SNOBOL4 (CSNOBOL4), 118 bytes



                                                                                                              	N =INPUT
                                                                                                              L =1
                                                                                                              1 X =LT(X,SIZE(N)) X + 1 :F(D)
                                                                                                              O N ARB . OUTPUT POS(X) :($L)
                                                                                                              D X =GT(X) X - 1 :F(END)
                                                                                                              L ='D' :(O)
                                                                                                              END


                                                                                                              Try it online!



                                                                                                              There appears to be a bug in this implementation of SNOBOL; attempting to replace the label D with the label 2 causes an error, although the manual for Vanilla SNOBOL indicates that (emphasis added)




                                                                                                              If a label is present, it must begin with the first character of the line. Labels provide a name for the statement, and serve as the target for transfer of control from the GOTO field of any statement. Labels must begin with a letter or digit, optionally followed by an arbitrary string of characters. The label field is terminated by the character blank, tab, or semicolon. If the first character of a line is blank or tab, the label field is absent.




                                                                                                              My supposition is that the CSNOBOL interpreter only supports a single label that begins with an integer.






                                                                                                              share|improve this answer









                                                                                                              $endgroup$
















                                                                                                                3












                                                                                                                3








                                                                                                                3





                                                                                                                $begingroup$


                                                                                                                SNOBOL4 (CSNOBOL4), 118 bytes



                                                                                                                	N =INPUT
                                                                                                                L =1
                                                                                                                1 X =LT(X,SIZE(N)) X + 1 :F(D)
                                                                                                                O N ARB . OUTPUT POS(X) :($L)
                                                                                                                D X =GT(X) X - 1 :F(END)
                                                                                                                L ='D' :(O)
                                                                                                                END


                                                                                                                Try it online!



                                                                                                                There appears to be a bug in this implementation of SNOBOL; attempting to replace the label D with the label 2 causes an error, although the manual for Vanilla SNOBOL indicates that (emphasis added)




                                                                                                                If a label is present, it must begin with the first character of the line. Labels provide a name for the statement, and serve as the target for transfer of control from the GOTO field of any statement. Labels must begin with a letter or digit, optionally followed by an arbitrary string of characters. The label field is terminated by the character blank, tab, or semicolon. If the first character of a line is blank or tab, the label field is absent.




                                                                                                                My supposition is that the CSNOBOL interpreter only supports a single label that begins with an integer.






                                                                                                                share|improve this answer









                                                                                                                $endgroup$




                                                                                                                SNOBOL4 (CSNOBOL4), 118 bytes



                                                                                                                	N =INPUT
                                                                                                                L =1
                                                                                                                1 X =LT(X,SIZE(N)) X + 1 :F(D)
                                                                                                                O N ARB . OUTPUT POS(X) :($L)
                                                                                                                D X =GT(X) X - 1 :F(END)
                                                                                                                L ='D' :(O)
                                                                                                                END


                                                                                                                Try it online!



                                                                                                                There appears to be a bug in this implementation of SNOBOL; attempting to replace the label D with the label 2 causes an error, although the manual for Vanilla SNOBOL indicates that (emphasis added)




                                                                                                                If a label is present, it must begin with the first character of the line. Labels provide a name for the statement, and serve as the target for transfer of control from the GOTO field of any statement. Labels must begin with a letter or digit, optionally followed by an arbitrary string of characters. The label field is terminated by the character blank, tab, or semicolon. If the first character of a line is blank or tab, the label field is absent.




                                                                                                                My supposition is that the CSNOBOL interpreter only supports a single label that begins with an integer.







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered Feb 27 at 16:11









                                                                                                                GiuseppeGiuseppe

                                                                                                                16.8k31052




                                                                                                                16.8k31052























                                                                                                                    3












                                                                                                                    $begingroup$


                                                                                                                    Brachylog (v2), 6 bytes



                                                                                                                    a₀ᶠ⊆.↔


                                                                                                                    Try it online!



                                                                                                                    Function submission, returning an array of lines. Loosely based on @Fatalize's answer.



                                                                                                                    Explanation



                                                                                                                    a₀ᶠ⊆.↔
                                                                                                                    .↔ Find a palindrome
                                                                                                                    ⊆ that contains, in order,
                                                                                                                    ᶠ all
                                                                                                                    a₀ prefixes of {the input}


                                                                                                                    Tiebreak order here is set by the , which, when used with this flow pattern, prefers the shortest possible output, tiebroken by placing the given elements as early as possible. The shortest possible output is what we want here (due to it not being possible to have any duplicate prefixes), and placing the given elements (i.e. the prefixes) as early as possible will place them in the first half (rounded up) of the output. Given that we're also requiring them to be placed in the same order, we happen to get exactly the pattern we need even though the description we gave Brachylog is very general; the tiebreaks happen to work out exactly right, causing Brachylog to pick the output we want rather than some other output that obeys the description.






                                                                                                                    share|improve this answer











                                                                                                                    $endgroup$


















                                                                                                                      3












                                                                                                                      $begingroup$


                                                                                                                      Brachylog (v2), 6 bytes



                                                                                                                      a₀ᶠ⊆.↔


                                                                                                                      Try it online!



                                                                                                                      Function submission, returning an array of lines. Loosely based on @Fatalize's answer.



                                                                                                                      Explanation



                                                                                                                      a₀ᶠ⊆.↔
                                                                                                                      .↔ Find a palindrome
                                                                                                                      ⊆ that contains, in order,
                                                                                                                      ᶠ all
                                                                                                                      a₀ prefixes of {the input}


                                                                                                                      Tiebreak order here is set by the , which, when used with this flow pattern, prefers the shortest possible output, tiebroken by placing the given elements as early as possible. The shortest possible output is what we want here (due to it not being possible to have any duplicate prefixes), and placing the given elements (i.e. the prefixes) as early as possible will place them in the first half (rounded up) of the output. Given that we're also requiring them to be placed in the same order, we happen to get exactly the pattern we need even though the description we gave Brachylog is very general; the tiebreaks happen to work out exactly right, causing Brachylog to pick the output we want rather than some other output that obeys the description.






                                                                                                                      share|improve this answer











                                                                                                                      $endgroup$
















                                                                                                                        3












                                                                                                                        3








                                                                                                                        3





                                                                                                                        $begingroup$


                                                                                                                        Brachylog (v2), 6 bytes



                                                                                                                        a₀ᶠ⊆.↔


                                                                                                                        Try it online!



                                                                                                                        Function submission, returning an array of lines. Loosely based on @Fatalize's answer.



                                                                                                                        Explanation



                                                                                                                        a₀ᶠ⊆.↔
                                                                                                                        .↔ Find a palindrome
                                                                                                                        ⊆ that contains, in order,
                                                                                                                        ᶠ all
                                                                                                                        a₀ prefixes of {the input}


                                                                                                                        Tiebreak order here is set by the , which, when used with this flow pattern, prefers the shortest possible output, tiebroken by placing the given elements as early as possible. The shortest possible output is what we want here (due to it not being possible to have any duplicate prefixes), and placing the given elements (i.e. the prefixes) as early as possible will place them in the first half (rounded up) of the output. Given that we're also requiring them to be placed in the same order, we happen to get exactly the pattern we need even though the description we gave Brachylog is very general; the tiebreaks happen to work out exactly right, causing Brachylog to pick the output we want rather than some other output that obeys the description.






                                                                                                                        share|improve this answer











                                                                                                                        $endgroup$




                                                                                                                        Brachylog (v2), 6 bytes



                                                                                                                        a₀ᶠ⊆.↔


                                                                                                                        Try it online!



                                                                                                                        Function submission, returning an array of lines. Loosely based on @Fatalize's answer.



                                                                                                                        Explanation



                                                                                                                        a₀ᶠ⊆.↔
                                                                                                                        .↔ Find a palindrome
                                                                                                                        ⊆ that contains, in order,
                                                                                                                        ᶠ all
                                                                                                                        a₀ prefixes of {the input}


                                                                                                                        Tiebreak order here is set by the , which, when used with this flow pattern, prefers the shortest possible output, tiebroken by placing the given elements as early as possible. The shortest possible output is what we want here (due to it not being possible to have any duplicate prefixes), and placing the given elements (i.e. the prefixes) as early as possible will place them in the first half (rounded up) of the output. Given that we're also requiring them to be placed in the same order, we happen to get exactly the pattern we need even though the description we gave Brachylog is very general; the tiebreaks happen to work out exactly right, causing Brachylog to pick the output we want rather than some other output that obeys the description.







                                                                                                                        share|improve this answer














                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer








                                                                                                                        answered Feb 27 at 17:35


























                                                                                                                        community wiki





                                                                                                                        ais523
























                                                                                                                            3












                                                                                                                            $begingroup$

                                                                                                                            APL+WIN, 31 bytes



                                                                                                                            Prompts for input of string:



                                                                                                                             ⊃((⍳n),1↓⌽⍳n)↑¨(¯1+2×n←⍴s)⍴⊂s←⎕


                                                                                                                            Explanation:



                                                                                                                            (¯1+2×n←⍴s)⍴⊂s create a nested vector of the string of length =1+2x length of string

                                                                                                                            ((⍳n),1↓⌽⍳n)↑¨ progressively select elements from each element of the nested vector
                                                                                                                            following the pattern 1 2 ...to n to n-1 ... 1

                                                                                                                            ⊃ convert nested vector into a 2d array.





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$


















                                                                                                                              3












                                                                                                                              $begingroup$

                                                                                                                              APL+WIN, 31 bytes



                                                                                                                              Prompts for input of string:



                                                                                                                               ⊃((⍳n),1↓⌽⍳n)↑¨(¯1+2×n←⍴s)⍴⊂s←⎕


                                                                                                                              Explanation:



                                                                                                                              (¯1+2×n←⍴s)⍴⊂s create a nested vector of the string of length =1+2x length of string

                                                                                                                              ((⍳n),1↓⌽⍳n)↑¨ progressively select elements from each element of the nested vector
                                                                                                                              following the pattern 1 2 ...to n to n-1 ... 1

                                                                                                                              ⊃ convert nested vector into a 2d array.





                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$
















                                                                                                                                3












                                                                                                                                3








                                                                                                                                3





                                                                                                                                $begingroup$

                                                                                                                                APL+WIN, 31 bytes



                                                                                                                                Prompts for input of string:



                                                                                                                                 ⊃((⍳n),1↓⌽⍳n)↑¨(¯1+2×n←⍴s)⍴⊂s←⎕


                                                                                                                                Explanation:



                                                                                                                                (¯1+2×n←⍴s)⍴⊂s create a nested vector of the string of length =1+2x length of string

                                                                                                                                ((⍳n),1↓⌽⍳n)↑¨ progressively select elements from each element of the nested vector
                                                                                                                                following the pattern 1 2 ...to n to n-1 ... 1

                                                                                                                                ⊃ convert nested vector into a 2d array.





                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$



                                                                                                                                APL+WIN, 31 bytes



                                                                                                                                Prompts for input of string:



                                                                                                                                 ⊃((⍳n),1↓⌽⍳n)↑¨(¯1+2×n←⍴s)⍴⊂s←⎕


                                                                                                                                Explanation:



                                                                                                                                (¯1+2×n←⍴s)⍴⊂s create a nested vector of the string of length =1+2x length of string

                                                                                                                                ((⍳n),1↓⌽⍳n)↑¨ progressively select elements from each element of the nested vector
                                                                                                                                following the pattern 1 2 ...to n to n-1 ... 1

                                                                                                                                ⊃ convert nested vector into a 2d array.






                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered Feb 27 at 19:31









                                                                                                                                GrahamGraham

                                                                                                                                2,46678




                                                                                                                                2,46678






















                                                                                                                                    1 2
                                                                                                                                    next




                                                                                                                                    protected by Community Feb 28 at 17:45



                                                                                                                                    Thank you for your interest in this question.
                                                                                                                                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                                                                    Would you like to answer one of these unanswered questions instead?



                                                                                                                                    Popular posts from this blog

                                                                                                                                    Installing LyX: “No textclass is found.”LyX installation error- text class not found- 'Reconfigure' or...

                                                                                                                                    (1602) Indiana Índice Designación y nombre Características orbitales Véase...

                                                                                                                                    Universidad Autónoma de Occidente Índice Historia Campus Facultades Programas Académicos Medios de...