In this challenge, you must take a string matching the regex ^[a-zA-Z]+$ or whatever is reasonable (you don't have to consider uppercase or lowercase letters if you want) (you may assume the string is long enough, and has the right structure for all the operations), and output another string, produced similarly to word at the end of a recent dadaist tweet by the POTUS ("Despite the constant negative press covfefe").

How to covfefify a string:

First, get the first sound group (made up terminology).

How do you do this? Well:

  • Find the first vowel (y is also a vowel)

  • Find the first consonant after that

  • Remove the rest of the string


That is your first sound group.

Next step:

Get the last consonant of the sound group


and replace it with the voiced or voiceless version. To do this, find the letter in this table. Replace with the letter given (which may be the same letter)

b: p
c: g
d: t
f: v
g: k
h: h
j: j
k: g
l: l
m: m
n: n
p: b
q: q
r: r
s: z
t: d
v: f
w: w
x: x
z: s

so, we get


Then, take the next vowel after that consonant. You can assume that this consonant is not at the end of the string. Join these two together, then repeat it twice:


Concatenate this to the first sound group:


You're done: the string is covfefified, and you can now output it.

Test cases:

coverage: covfefe

example: exxaxa

programming: progkaka (the a is the first vowel after the g, even though it is not immediately after)
code: codtete

president: preszizi

This is , so please make your program as short as possible!

  • 7
    \$\begingroup\$ "x" should technically map onto "gz". "qu" should map onto "gw". \$\endgroup\$ – Steve Bennett Jun 5 '17 at 5:34
  • 3
    \$\begingroup\$ This specifies one concept of covfefification but I keep feeling that a reference to Douglas Hofstadter's (and Melanie Mitchell's) work on string-conversion analogies, e.g. in Fluid Concepts seems appropriate. \$\endgroup\$ – Mars Jun 7 '17 at 5:51
  • 64
    \$\begingroup\$ Answers over 140 characters should be disqualified \$\endgroup\$ – Sandy Gifford Jun 7 '17 at 15:27
  • 12
    \$\begingroup\$ Unfortunately it is impossible to do this in TrumpScript :( \$\endgroup\$ – user69279 Jun 14 '17 at 22:09
  • 4
    \$\begingroup\$ @ThePlasmaRailgun It was a joke, since tweets have to be 140 characters or less. \$\endgroup\$ – Esolanging Fruit Dec 31 '17 at 22:14

38 Answers 38

1 2

Python 3.8 (pre-release), 142 bytes

g=lambda i,f='aeiuoy':i if s[i]in f else g(i+1,f)
q=g(g(0),c:='pgtcvkh jglmn bqrzd fwx s')

Try it online!

A little late to the party, but here's yet another non-regex Python answer! I interpreted the rules to allow printing to STDERR which saves a byte (exit/print). Using Python 3.8 over 3<=3.7 saves me a total of 1 byte with the walrus operator as opposed to defining the c variable elsewhere.

Thanks a lot to Post Rock Garf Hunter (-21 bytes) for the help!

New contributor
chinatsu is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    \$\begingroup\$ Looks good! +1 for the good job :D also, you are never late for a code-golf party! \$\endgroup\$ – RGS Feb 13 at 14:08
  • 1
    \$\begingroup\$ You can take off some bytes by having b look for the index instead of the character since indexing is shorter than .find. Try it online! \$\endgroup\$ – Post Rock Garf Hunter Feb 13 at 15:03
  • \$\begingroup\$ I really, really like this, but does it not break on input words such as peeled? Try it online! I need a bit of time to properly understand it, I can't quite figure out how to fix it but I have a feeling that it is possible! \$\endgroup\$ – chinatsu Feb 13 at 15:49
  • \$\begingroup\$ I thought I had it with this, however it also breaks if the word start with a vowel :( The example given should return avfefe \$\endgroup\$ – chinatsu Feb 13 at 16:31
  • 1
    \$\begingroup\$ You can save a few bytes with short-circuiting \$\endgroup\$ – Reinstate Monica Feb 13 at 16:51

Perl, 90 bytes (89 + 1)

I see that I've already been beaten by another Perl answer, but I'll post this anyway. Run with -p.


Go, 298 bytes

func c(l string)string{v:="aeiouy";c:="bcdfghjklmnpqrstvwxz";r:="pgtvkhjglmnbqrzdfwxs";b:=l[0:strings.IndexAny(l,v)+1];t:=strings.SplitAfterN(l,b,2)[1];i:=strings.IndexAny(t,c);b=b+t[0:i+1];x:=string(r[strings.IndexAny(c,string(t[i]))]);z:=string(t[i:][strings.IndexAny(t[i:],v)]);return b+x+z+x+z}
  • \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ – Martin Ender Jun 19 '17 at 14:46

Modern Pascal 2.0, 415, 396 bytes

function c(S:String):String;
var L,M,I:Longint; const v='aeiouy'; o='_pgt_vkh_jglmn_bqrzd_fwx_s';
begin S:=Lowercase(S); Result:=S;
For l:=1 to length(S) do if pos(S[l],v)>0 then Break;
For M:=l to length(S) do if pos(S[M],v)=0 then begin
For L:=1 to Length(S) do If Pos(S[l],v)>0 then begin

// Author of Modern Pascal

  • 1
    \$\begingroup\$ this is not 415 bytes. please trim spaces and actually make it 415 bytes to have that score. also the function name can be golfed \$\endgroup\$ – Destructible Lemon Jun 12 '17 at 23:52
  • \$\begingroup\$ made smaller by unformatting. Could go even smaller, as modern pascal does not enforce the grammer of then a wasted heartbeat in parsing. \$\endgroup\$ – Ozz Nixon Jun 13 '17 at 17:46
  • 3
    \$\begingroup\$ if you can go even smaller then you should \$\endgroup\$ – Destructible Lemon Jun 13 '17 at 22:17

Python 3, 194 bytes

f=lambda s,g='aeiouy':min([s.index(l)for l in g if l in s])

Try it online!

I've had this coded since the week of the challenge, but was discouraged to post in its then-current state (which also happens to be the current state) because of all the 80-byte regex answers.

But hey, what the hell. Here's another non-esoteric, non-regex answer, six months late to the party.

-30 bytes from typing out the consonants in a string rather than using a list comprehension

  • \$\begingroup\$ Your TIO gives an error. \$\endgroup\$ – FlipTack Jan 4 '18 at 7:49

Vim, 107 keystrokes

Who needs Java, Python 3, Modern Pascal 2.0, C#, Python 2, R, Go, C, BlitzMax, Javascript, Crystal, Clojure, Lua, Matlab/Octave, Haskell and PHP when you have vim?

i ⎋o⏎bcdfghjklmnpqrstvwxz⏎pgtvkhjglmnbqrzdfwxs⎋1Ghqy/[aeiouy]⏎q/[^aeiouy]⏎mz@yyl`zpld$yhjpg*jyl`zpy2lPjdGX

is the Escape key and is the Return key


i ⎋                         Insert a space before the first character
o⏎bcdfghjklmnpqrstvwxz⏎     Insert the character data
qy/[aeiouy]⏎q               Find the first vocal after the space
/[^aeiouy]⏎mz               Find the next consonant and add a marker
@yyl`zp                     Find the next vocal and put it after the consonant 
ld$                         Delete the rest of the world
yhjpg*                      Search for the consonant in the first row of the character data
jyl                         Copy the character in the same position in the second row
`zpy2lPjdGX                 Paste it after the last vowel and repeat the two last characters
  • \$\begingroup\$ I may be wrong, but it doesn't look like [aeiou] and [^aeiou] account for the fact that, in this challenge, y is considered a vowel. \$\endgroup\$ – FlipTack Jan 3 '18 at 16:32

SmileBASIC, 185 179 168 bytes

This is an even more golfed version of snail_'s answer.



'function returns true if the character at POS is a consonant
'scan through the word until there's a vowel followed by a consonant
'Store and print the final letter of the "normal" section
'Find the next vowel
'If last normal letter is one of "BCDFGKPSTVZ", replace with corresponding letter in "PGTVKGBZDFS"
'otherwise don't change it
'print the "corrupted" letter and the vowel that was found earlier, twice.

05AB1E, 35 bytes


Try it online!

1ú                 # prepend the input with a space
                   # (this ensures the word doesn’t start with a vowel)
  .γ    }          # group characters by:
    žO             #  built-in constant "aeiouy"
      så           #  is the character in that string?
         R         # reverse the list of groups
          `        # dump all on the stack (first group on top)
¦                  # remove the space we added earlier
 ?                 # print the first consonant group
  ?                # print the first vowel group
   н               # get the first letter of the second consonant group
    ©              # save it in the register
     ?             # print it
      н            # get the first letter of the second vowel group
       ®           # restore the consonant from the register
        ì          # prepend, giving a consonant-vowel pair
.•gÍĆdQ¸G•         # compressed string "pgtvgzskfdcb"
          Â        # push a reversed copy of it
           ‡       # transliterate (b => p, c => g, ...)
            D      # duplicate the transliterated pair
             ?,    # print both copies (with a newline the second time)
1 2

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.