14
\$\begingroup\$

It's obviously ellipsisessieses.

Inspired by a chat message.

Your challenge

Given a list or space or comma-separated string of words, ellipsisessiesesify them.

To ellipsisessieses-ify a word:

  1. Start with the word.
  2. Add the first letter of the original word to the end.
  3. Add 2 of the last letter of the original word to the end.
  4. Add the second-to-last letter of the original word to the end.
  5. Add the first letter of the original word to the end.
  6. Add the last letter of the original word to the end.
  7. Repeat steps 5 & 6 once.
  8. You're done!

You can assume:

  • The input words will only be alphanumeric
  • Input & output can be a space-separated string or list
  • The input will contain only words
  • The words will be at least 2 letters long
  • The input will match the regex /^[a-z0-9]{2,}( [a-z0-9]{2,})*$/i
  • You can have a different input and output format
  • More to come...

Test cases:

ellipsis -> ellipsisessieses
goat -> goatgttagtgt
covfefe -> covfefeceefcece
programmer5000 -> programmer5000p000p0p0
up vote down goat -> upuppuupup voteveetveve downdnnwdndn goatgttagtgt
it is golf yo -> itittiitit isissiisis golfgfflgfgf yoyooyyoyo
crossed out 44 is still 44 -> crossedcddecdcd outottuotot 4444444444 isissiisis stillslllslsl 4444444444

Shorteststtsstst answerarrearar ininniinin bytesbssebsbs winswssnwsws!

\$\endgroup\$
  • \$\begingroup\$ Pretty sure the "e"s in "ellipsisessieses" is from "ellipses" (except the first "e") \$\endgroup\$ – Leaky Nun Aug 24 '17 at 21:06
  • 15
    \$\begingroup\$ I still don't know how to pluralize ellipsis... EDIT: apparently, it's ellipses. \$\endgroup\$ – totallyhuman Aug 24 '17 at 21:07
  • 1
    \$\begingroup\$ For step 2, I think it should just be add an e, not add the first letter \$\endgroup\$ – benzene Aug 24 '17 at 21:11
  • \$\begingroup\$ @benzene that might make more sense, but it's too late now. \$\endgroup\$ – programmer5000 Aug 24 '17 at 21:19
  • 2
    \$\begingroup\$ It's ellipses. Other plurals that have the same spelling but different pronunciation for a word ending in -is and a word ending in -e are axes and bases. \$\endgroup\$ – user73731 Aug 25 '17 at 16:47

18 Answers 18

16
\$\begingroup\$

JavaScript (ES6), 58 57 bytes

NB: This turns out to use the same trick as Jonathan Allan in this Jelly answer (though I noticed after posting).

Saved 1 byte thanks to Jonathan Allan

Works on arrays of strings.

s=>s.map(s=>s+'01120101'.replace(/./g,n=>s.substr(-n,1)))

Test cases

let f =

s=>s.map(s=>s+'01120101'.replace(/./g,n=>s.substr(-n,1)))

console.log(f(['ellipsis']))
console.log(f(['goat']))
console.log(f(['covfefe']))
console.log(f(['programmer5000']))
console.log(f(['up', 'vote', 'down', 'goat']))
console.log(f(['it', 'is', 'golf', 'yo']))
console.log(f(['crossed', 'out', '44', 'is', 'still', '44']))

\$\endgroup\$
  • \$\begingroup\$ Woah, this is cool! Nice job! \$\endgroup\$ – programmer5000 Aug 24 '17 at 22:09
  • \$\begingroup\$ I believe you can save a byte by replacing 21102121 with 01120101 and n-2 with -n. \$\endgroup\$ – Jonathan Allan Aug 24 '17 at 22:41
  • \$\begingroup\$ @JonathanAllan Good catch. Thanks! \$\endgroup\$ – Arnauld Aug 24 '17 at 22:44
11
\$\begingroup\$

Jelly,  13 12  11 bytes

⁽×ʠb3’ịṭµ€K

A full program that takes a list of lists of characters and prints the space separated output.

Try it online!

How?

⁽×ʠb3’ịṭµ€K - Main link: list of lists of characters e.g. ["this","is","it"]
        µ€  - for each word in the input:            e.g. "this"
⁽×ʠ         -   base 250 literal 5416                     5416
   b3       -   converted to base 3                       [2,1,1,0,2,1,2,1]
     ’      -   decrement                                 [1,0,0,-1,1,0,1,0]
      ị     -   index into the word                       "tssitsts"
       ṭ    -   tack to the word                          ["this",["tssitsts"]]
          K - join the results with spaces                ["this",["tssitsts"]," is",["issiisis"]," it",["ittiitit"]]
            - implicit print                              thistssitsts isissiisis itittiitit

Alternatively a list of words to list of words is also possible in 11 bytes:

⁽×ʠb3’ị;@µ€

⁽×ʠb3’ may also be replaced by 4,⁵Bj- for the same byte count
([4,10] in binary is [[1,0,0],[1,0,1,0]] joined by -1 is [1,0,0,-1,1,0,1,0]).

\$\endgroup\$
  • \$\begingroup\$ Do you need to join the results with spaces? You are allowed to output a list / a list of lists. \$\endgroup\$ – programmer5000 Aug 25 '17 at 1:04
  • \$\begingroup\$ @programmer5000 Yeah, joining with spaces is optional here \$\endgroup\$ – ASCII-only Aug 25 '17 at 2:34
  • \$\begingroup\$ @programmer5000 There is an alternative 11 byter that returns a list which I have given below the main answer (note that there is no way to get the main one down to 10 by removing the K because as a monadic link the returned list would not be one level deep, which I imagine is pushing lax I/O too far - that is for an input of ["this", "is", "it"] the return value would be [['t','h','i','s',"tssitsts"],['i','s',"issiisis"],['i','t',"ittiitit"]] (where "..." are lists of characters) and leaving it to print as a full program would smash it all together as thistssitstsisissiisisitittiitit) \$\endgroup\$ – Jonathan Allan Aug 25 '17 at 2:52
7
\$\begingroup\$

05AB1E, 12 bytes

εD•Lz•3вÍèJ«

Try it online!

Explanation

ε              # apply on each word in input
 D             # duplicate the word
  •Lz•         # push the base-255 compressed number 5416
      3в       # convert to a list of base-3 digits (yields [2, 1, 1, 0, 2, 1, 2, 1])
        Í      # subtract 2 from each (yields [0, -1, -1, -2, 0, -1, 0, -1])
         è     # index into the word with these numbers
          J    # join to string
           «   # append to the original word
\$\endgroup\$
  • 1
    \$\begingroup\$ Hehe, great minds... \$\endgroup\$ – Jonathan Allan Aug 24 '17 at 21:43
  • \$\begingroup\$ @JonathanAllan: Yeah, we had exactly the same idea it seems. Jellys shorter compression won the day this time :) \$\endgroup\$ – Emigna Aug 24 '17 at 21:46
6
\$\begingroup\$

Retina, 52 49 bytes

3 bytes thanks to Arnauld.

(\w)(\w+)
$1$2$1
(.)(.)(.)\b
$1$2$3$2$2$1$3$2$3$2

Try it online!

\$\endgroup\$
  • 5
    \$\begingroup\$ That third line of code reminds me of a mutant from Total Recall. \$\endgroup\$ – Jonathan Allan Aug 24 '17 at 21:49
  • \$\begingroup\$ @JonathanAllan Who was inspired by Eccentrica Gallumbits mentioned in the Hitch-Hiker's Guide to the Galaxy. \$\endgroup\$ – Neil Aug 25 '17 at 0:21
5
\$\begingroup\$

Python 2, 56 bytes

lambda s:[i+i[0]+i[-1]*2+i[-2]+(i[0]+i[-1])*2for i in s]

Try it online!

I think this is my fastest FGITW and it's not even that impressive. :P

\$\endgroup\$
4
\$\begingroup\$

Python 3, 60 bytes

lambda k:[x+''.join(x[-int(i)]for i in"01120101")for x in k]

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Charcoal, 20 bytes

F⪪S «ι↑E”o∨↙8”§ι±Iκ→

Try it online! Link is to verbose version of code. Only happened to read @Arnauld's answer after coding this but this is basically a port of it. Explanation:

F   «                   Loop over
  S                     Input string
 ⪪                       Split at spaces
     ι                  Print the word
        ”o∨↙8”          Compressed string 01120101
       E                Map over each character
                 Iκ     Cast character to integer
                ±       Negate
              §ι        Circularly index into word
      ↑                 Print array upwards, prints each element rightwards
                    →    Move right
\$\endgroup\$
  • \$\begingroup\$ 18 bytes maybe? \$\endgroup\$ – ASCII-only Aug 25 '17 at 1:34
  • \$\begingroup\$ @ASCII-only Wouldn't you have to add extra bytes for the -rs flag? \$\endgroup\$ – Neil Aug 25 '17 at 7:58
  • \$\begingroup\$ Not sure, I guess so? -rs is there just to disable printing the input prompt though \$\endgroup\$ – ASCII-only Aug 25 '17 at 7:59
  • \$\begingroup\$ Should I just make -rs mode the default instead? \$\endgroup\$ – ASCII-only Aug 25 '17 at 8:00
4
\$\begingroup\$

sed, 46 bytes

s/^\(\(.\).*\(.\)\(.\)\)$/\1\2\4\4\3\2\4\2\4/g

Try it online!

\$\endgroup\$
3
\$\begingroup\$

JavaScript (ES6), 74 60 bytes

s=>s.map(s=>s+(a=s[l=s.length-1],b=s[0])+a+a+s[l-1]+b+a+b+a)

Takes input as an array, and outputs an array.

-9 bytes thanks to Programmer5000

Test cases:

let f=

s=>s.map(s=>s+(a=s[l=s.length-1],b=s[0])+a+a+s[l-1]+b+a+b+a)

console.log(JSON.stringify(f(['ellipsis']))) // ellipsisessieses
console.log(JSON.stringify(f(['goat']))) // goatgttagtgt
console.log(JSON.stringify(f(['covfefe']))) // covfefeceefcece
console.log(JSON.stringify(f(['programmer5000']))) // programmer5000p000p0p0
console.log(JSON.stringify(f(['up', 'vote', 'down', 'goat']))) // upuppuupup,voteveetveve,downdnnwdndn,goatgttagtgt
console.log(JSON.stringify(f(['it', 'is', 'golf', 'yo']))) // itittiitit,isissiisis,golfgfflgfgf,yoyooyyoyo
console.log(JSON.stringify(f(['crossed', 'out', '44', 'is', 'still', '44']))) // crossedcddecdcd,outottuotot,4444444444,isissiisis,stillslllslsl,4444444444

\$\endgroup\$
3
\$\begingroup\$

Mathematica, 89 bytes

((f[a_]:=#~StringTake~a;k=#<>(q=f@1)<>(w=f[-1])<>w<>f@{-2}<>q<>w<>q<>w)&/@StringSplit@#)&
\$\endgroup\$
  • 1
    \$\begingroup\$ There's no mathematica Ellipsisessieses builtin? :( \$\endgroup\$ – programmer5000 Aug 25 '17 at 14:02
3
\$\begingroup\$

Pyth, 17 bytes

Uses the same trick as in @Jonathan's answer.

m+dsm@dttkj5416 3

Try it here! or Check out the test Suite (Give it some time).

Port of my Python solution, 19 bytes 18 bytes:

m+dsm@d_k+0j1144 3
\$\endgroup\$
3
\$\begingroup\$

Dyalog APL, 51 49 bytes

Requires ⎕ML←3

∊{⍺,' ',⍵}/{S←1,L←≢⍵⋄⍵,⍵[∊S(L-0 1)S S]}¨' '(≠⊂⊢)⍞

-9 bytes thanks to @Adám in chat!

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Paradoc (v0.2.10), 13? bytes (CP-1252)

µ96Qó3BÌDX=v+

Try it online!

Takes a list of words, and results in a list of words on the stack.

A small variation on the base-3 trick. Maybe it's time to work on my base 250-whatever compressor.

Explanation:

μ             .. Map the following block over each word (the block is
              .. terminated by }, but that doesn't exist, so until EOF)
              .. (The word is on the stack now.)
 96Qó         .. 96 * 26 (Q in base 26) = 2496, a hack to prevent us from
              .. needing a space to separate this from the following number.
     3B       .. Convert 2496 to base 3 to get [1,0,1,0,2,1,1,0]
       ÌD     .. Negate and reverse to get [0,-1,-1,-2,0,-1,0,-1]
         X    .. Push the loop variable: the word being mapped over
          =v  .. Index, vectorize; map over the indices by indexing them
              .. into the word
            + .. Concatenate with the original word

(Byte-counting question: Now that I'm actually demonstrating this in TIO, it take a list of words on the stack and results in a list of words on the stack, but you can't really do much with that list of words unless you close the block started by µ. Should I count that closing brace?)

\$\endgroup\$
  • 1
    \$\begingroup\$ Should I cound that closing brace? Yes, if you need it. \$\endgroup\$ – Erik the Outgolfer Aug 25 '17 at 9:18
3
\$\begingroup\$

Wolfram Language/Mathematica, 66 bytes

StringJoin[StringSplit[#,""]/.{a_,___,b_,c_}:>{#,a,c,c,b,a,c,a,c}]&

Just whipped it up real quick, might have a minor improvement here or there.

\$\endgroup\$
2
\$\begingroup\$

Perl 5, 55 49 + 1 (-a) = 56 50 bytes

used a trick from @Arrnauld's post to save a couple bytes

say map$_.'01120101 '=~s/\d/substr$_,-$&,1/egr,@F

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 38 30 bytes

-8 bytes thanks to ASCII-only.

F⪪S «ι§ι⁰ײ§ι±¹§ι±²×²⁺§ι⁰§ι±¹ 

Try it online! Link is to verbose version.

Note the trailing space.

\$\endgroup\$
2
\$\begingroup\$

Java 8, 117 bytes

a->{int i=0,l;for(String s:a){char c=s.charAt(0),d=s.charAt(l=s.length()-1);a[i++]+=""+c+d+d+s.charAt(l-1)+c+d+c+d;}}

Takes the input as a String-array, and modified this original array instead of returning a new one to save bytes.

Can most likely be golfed some more..

Explanation:

Try it here.

a->{                          // Method with String-array as parameter and no return-type
  int i=0,                    //  Index-integer (starting at 0)
      l;                      //  Length-integer which we use multiple times
  for(String s:a){            //  Loop over the input array
    char c=s.charAt(0),       //   The first character of the word
         d=s.charAt(          //   The last character of the word
            l=s.length()-1);  //    and set `l` at the same time to `length()-1`
    a[i++]+=                  //   Append to the current value in the array:
      ""                      //    String so the characters aren't appended as integers
      +c                      //    + the first character
      +d+d                    //    + two times the last character
      +s.charAt(l-1)          //    + the single-last character
      +c+d+c+d;               //    + the first + last character two times
  }                           //  End of loop
}                             // End of method
\$\endgroup\$
2
\$\begingroup\$

C# (.NET Core), 106 bytes

n=>{for(int i=0,x;i<n.Length;){var h=n[i];x=h.Length-1;char y=h[0],j=h[x];n[i++]=h+y+j+j+h[x-1]+y+j+y+j;}}

Try it online!

Lambda function that takes input as array of strings, and modifies original array for output

\$\endgroup\$

Your Answer

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

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