Skip to main content
Added explanation
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

Pip, 28 bytes

aR+XA{Y'eX#a-3\"Bl\yt\"@<#a}

Takes input as a command-line argument. Try it online!

Explanation

This was fun--I got to use regex modifiers and string interpolation.

                              a is 1st cmdline arg; XA is the regex `[A-Za-z]` (implicit)
aR                            In a, replace
   XA                          the regex XA
  +                            wrapped in (?:  )+
     {                     }  with this callback function:
          #a-3                 Length of argument - 3
       'eX                     Repeat e that many times (empty string if #a-3 is negative)
      Y                        Yank that string into the y variable
              \"Bl\yt\"        An escaped string, which interpolates the value of y
                       @<#a    Take first len(a) characters
                              After the replacement, the string is autoprinted

Pip, 28 bytes

aR+XA{Y'eX#a-3\"Bl\yt\"@<#a}

Takes input as a command-line argument. Try it online!

Pip, 28 bytes

aR+XA{Y'eX#a-3\"Bl\yt\"@<#a}

Takes input as a command-line argument. Try it online!

Explanation

This was fun--I got to use regex modifiers and string interpolation.

                              a is 1st cmdline arg; XA is the regex `[A-Za-z]` (implicit)
aR                            In a, replace
   XA                          the regex XA
  +                            wrapped in (?:  )+
     {                     }  with this callback function:
          #a-3                 Length of argument - 3
       'eX                     Repeat e that many times (empty string if #a-3 is negative)
      Y                        Yank that string into the y variable
              \"Bl\yt\"        An escaped string, which interpolates the value of y
                       @<#a    Take first len(a) characters
                              After the replacement, the string is autoprinted
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

Pip, 28 bytes

aR+XA{Y'eX#a-3\"Bl\yt\"@<#a}

Takes input as a command-line argument. Try it online!