Facey McFaceface

V, 27 28 30 bytes

Vu~Ùóe¿y$
Hóy$
ÁyJaMc<Esc>Aface

Try it online!

<Esc> represents 0x1b

  • Golfed two bytes after learning that we did not need to support inputs with less than 3 characters.

  • 1 byte saved thanks to @DJMcMayhem by working on the second line before the first one, thus removing the G

The input is in the buffer. The program begins by converting everything to lowercase

V selects the line and u lowercases it

~ toggles the case of the first character (converting it to uppercase)

and Ù duplicates this line above, leaving the cursor at the bottom line

ó and replaces e¿y$, compressed form of e\?y$ (optional e and a y at the end of the line), with nothing (happens on the second line)

H goes to the first line

ó replaces y$ (y at the end of the line) with nothing on the first line

Á appends a y to the end of the first line

J and joins the last line with the first with a space in the middle, and the cursor is moved to this space

a appends Mc (<Esc> returns to normal mode)

A finally, appends face at the end of the line


Python, 144 bytes

def f(s):
 s=s[0].upper()+s[1:].lower()
 y=lambda s:s[:-1]if s[-1]=='y'else s
 t=y(s)
 u=s[:-2]if s[-2:]=='ey'else y(s)
 return t+'y Mc%sface'%u

Try it online here


Excel, 204 144 137 165 bytes

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(REPT(REPLACE(LOWER(A1),1,1,UPPER(LEFT(A1)))&"~",2),"~","y Mc",1),"yy ","y "),"ey~","~"),"y~","~"),"~","face")

From the inside outwards:

REPLACE(LOWER(A1),1,1,UPPER(LEFT(A1)))      Replaces PROPER to handle space-delimited cases
REPT(%&"~",2)                   Duplicate.                    Donkey~Donkey~
SUBSTITUTE(%,"~","y Mc",1)      Replace first ~.              Donkeyy McDonkey~
SUBSTITUTE(%,"yy ","y ")        Handle words ending in 'y'.   Donkey McDonkey~
SUBSTITUTE(%,"ey~","~")         Handle words ending in 'ey'   Donkey McDonk~
SUBSTITUTE(%,"y~","~")          Handle words ending in 'y'    Donkey McDonk~
SUBSTITUTE(%,"~","face")        Adding face.                  Donkey McDonkface

Old answer, creating all bits separately, and then concatenating (176 bytes). Does not handle space-delimited cases correctly.

=PROPER(A1)&IF(LOWER(RIGHT(A1,1))="y",,"y")&" Mc"&IF(LOWER(RIGHT(A1,2))="ey",LEFT(PROPER(A1),LEN(A1)-2),IF(LOWER(RIGHT(A1,1))="y",LEFT(PROPER(A1),LEN(A1)-1),PROPER(A1)))&"face"