(Meaning: Convert English to Bleet)

We have praised goats as god for years now.

But if we can't translate English to 'Bleet', the Goat God's language, we cannot communicate with them.

So, to communicate with them, we have researched the activities of goats, and retrieved this pattern, which is the core of the language.

Say 'Bleet' for the length of each words. That means the amount of 'e's should be (length-3) for words longer than 3 letters.You shall cut down 'Bleet' for words shorter than 'Blt'. For example, 'be' becomes 'bl', but 'cat' and 'boat' becomes 'blt' and 'blet'.

As it seems, they don't actually change non-alphabet characters to 'Bleet'. Our research showed that 'Hello, World!' to Bleet is 'Bleet, Bleet!' not 'Bleeet Bleeet'. Also, The goats are not so intelligent(no offense), so they don't seem to understand non-ascii characters or diacritics at all.

Now, It's time to make a translator to communicate with the goat gods.

Bleeeeet (Meaning: Examples)

Hello, World! => Bleet, Bleet!
lorem ipsum dolor sit amet. => Bleet Bleet Bleet Blt Blet.
We praise the Goat God! => Bl Bleeet Blt Blet Blt!
I have a pen => B Blet B Blt
0123456789_ => 0123456789_
0te_st1 => 0Bl_Bl1
  • 1
    \$\begingroup\$ Related! \$\endgroup\$ Mar 10, 2017 at 15:01
  • 1
    \$\begingroup\$ And what about words containing apostrophes? Will it's become Blt or Bl't or Bl'B? \$\endgroup\$ Mar 10, 2017 at 16:05
  • 3
    \$\begingroup\$ It's up to you, but if you keep it I'd notify every answerer. If it were me I think I'd probably allow any behaviour: pass them (Jimmy's:Bleee't), treat them as word separations (Jimmy's:Bleet'B), or treat them as part of words (Jimmy's:Bleeeet). If I had to choose one I'd go with the word separator option, since it's what the 6 answers do. \$\endgroup\$ Mar 10, 2017 at 16:18
  • 2
    \$\begingroup\$ This is really good challenge, we should have more like this. \$\endgroup\$
    – Downgoat
    Mar 14, 2017 at 16:04
  • 2
    \$\begingroup\$ @Downgoat quality-wise, or goat-wise? \$\endgroup\$ Mar 14, 2017 at 16:52

15 Answers 15


Retina, 31 bytes


Try it online!



Turn all letters into es.


Turn the first e in each run into B.


Turn Be into Bl.


Turn the last e in each run into t.

  • \$\begingroup\$ T1L the T stage "wraps" the translation pairs so that you can turn all letters like that to e \$\endgroup\$ Mar 14, 2017 at 1:07
  • \$\begingroup\$ @ConorO'Brien It's actually a lower-case l, not a 1, but I'm not sure what you mean by "wrap". Transliteration simply repeats the last character in the target pattern, so if it was T`lL`ef, you'd map a to e and all other letters to f, not alternatingly to e and f. \$\endgroup\$ Mar 14, 2017 at 8:10
  • \$\begingroup\$ it was a bad joke. Sorry \$\endgroup\$ Mar 14, 2017 at 16:15

JavaScript (ES6), 79 77 74 bytes


Alternate approach, currently 83 78 bytes:


The best I could do recursively was 88 bytes:

  • \$\begingroup\$ I came up with 'Blet'[i>1?2+!x[i+1]:i] but sadly it's the same length. \$\endgroup\$
    – Neil
    Mar 10, 2017 at 18:25
  • \$\begingroup\$ @Neil Yeah, I figured it would be possible to do it that way, but I'm surprised it was nearly shorter than the way I'm doing it. \$\endgroup\$ Mar 10, 2017 at 18:29

PHP, 115 88 86 77 75 bytes

preg_replace with arrays (requires PHP 5.4 or later)

echo preg_replace(["#[a-z]#i","#(?<!e)e#",_Be_,"#e(?!e)#"],[e,B,Bl,t],$argn);

Run with echo '<string>' | php -nR '<code>' or test it online.


            original string                     Hello
[a-z]       every letter            e           eeeee
(?<!e)e     first letter            B           Beeee
Be          first two letters       Bl          Bleee
e(?!e)      last letter if still e  t           Bleet

Revision 5: saved 9 bytes with Martin Ender´s regex chain.
(That also fixed cases with non-alphabetic word characters = digits/underscores.)


Haskell, 135 128 bytes

b e=e
e!(l:t)|elem l$['a'..'z']++['A'..'Z']=('e':e)!t|1<3=b e++l:""!t

Try it online! Usage (""!) $ "some string". Without regexes, this turned out to be quite long, maybe some other approach is shorter. Edit: Saved 7 bytes thanks to @nimi!

  • 1
    \$\begingroup\$ Renaming function b to a you can apply it immediately when constructing the resulting string and omit the final =<<: b!(l:t)|...|1<3=a b++l:""!t;b!_=a b;(""!). \$\endgroup\$
    – nimi
    Mar 10, 2017 at 17:30
  • \$\begingroup\$ Doesn't work online for It's Jimmy's test I get Bl'B Bleet'B \$\endgroup\$
    – cleblanc
    Mar 10, 2017 at 20:14
  • \$\begingroup\$ @cleblanc This requirement was added after my answer and invalidates most of the current answers ... let me ask the OP. \$\endgroup\$
    – Laikoni
    Mar 10, 2017 at 20:45
  • \$\begingroup\$ @Laikoni Right. I came late to this game and the apostrophe is a particularly difficult exception to handle. \$\endgroup\$
    – cleblanc
    Mar 10, 2017 at 20:53

Perl 5, 47 bytes

Saved 15 bytes by using the same technique as Martin Ender's Retina answer. (This answer is basically a port of his answer now)

46 bytes of code + -p flag.


Try it online!

Older versions: 62 bytes:

s/\pl+/$l=length$&;$_=Bl.e x($l-3).t;chop while$l<y%%%c;$_/ge

And 68 bytes:


PHP, 84 Bytes


PHP, 117 Bytes

<?=preg_replace_callback("#[a-z]+#i",function($m){return substr(str_pad(Bl,-1+$l=strlen($m[0]),e).t,0,$l);},$argv[1]);
  • \$\begingroup\$ Save one byte with -1+$l=... \$\endgroup\$
    – Titus
    Mar 10, 2017 at 14:31
  • \$\begingroup\$ @Titus nice and I Have found a better solution \$\endgroup\$ Mar 10, 2017 at 15:25
  • 1
    \$\begingroup\$ Zwei Dumme - ein Gedanke. :) But \bl fails for non-alphabetic word characters: _we_. You need an explicit assertion: (?<!l)l. Same for e\b -> e(?!e) (+7 bytes) \$\endgroup\$
    – Titus
    Mar 10, 2017 at 15:26
  • \$\begingroup\$ @Titus In the meantime it is myself noticed that my thought was wrong. And I love your german comment. \$\endgroup\$ Mar 10, 2017 at 15:43

C, 120 151 140 111 108 105 104 92 90 Bytes

Working for "It's Jimmy's test" --> Bl'B Bleet'B Blet


The output is now a side effect by destroying the original string.

    char test[] = "The End is near Fellows!";
    char test2[] = "We praise the Goat God!";
    char test3[] = "It's Jimmy's test";
    char test4[] = "0te_st1";
    char test5[] = "I have a pen";
    char test6[] = "_0123456789_";

I think it's correct at least now

Blt Blt Bl Blet Bleeeet!
Bl Bleeet Blt Blet Blt!
Bl'B Bleet'B Blet
B Blet B Blt
  • \$\begingroup\$ Jimmy? \$\endgroup\$
    – DLosc
    Mar 13, 2017 at 20:57
  • \$\begingroup\$ @DLosc I haven't gone mad and died yet. \$\endgroup\$
    – cleblanc
    Mar 13, 2017 at 21:06

Python 2.7, 129 118 114 109 95 91 88 bytes

import re
def f(i):print s(r"e\b","t",s("Be","Bl",s(r"\be","B",s("\w","e",i))))

Just an re.sub chain

Step by step

Example input: "We praise the Goat God!"

Alias sub so we can save bytes on repeated calls

import re

Replace all word characters with "e"


Output: ee eeeeee eee eeee eee!

Replace all "e"s which are preceded by a word boundary (Beginning of word) with "B"


Output: Be Beeeee Bee Beee Bee!

Replace all "Be" with "Bl"


Output: Bl Bleeee Ble Blee Ble!

Replace all "e"s which are followed by a word boundary with "t"


Output: Bl Bleeet Blt Blet Blt!

  • \$\begingroup\$ Welcome to PPCG! We allow functions to print their results, so replacing return with print should save a byte. \$\endgroup\$ Mar 14, 2017 at 1:43
  • \$\begingroup\$ You can also remove the leading r from raw strings if they have no backlashes in them saving another 3 bytes \$\endgroup\$ Mar 14, 2017 at 2:45
  • \$\begingroup\$ Thanks @ConorO'Brien ! I was able to simplify a piece of the regex (which ended up needing an r) and I got it down to 95 bytes. Thanks for the suggestion! \$\endgroup\$ Mar 14, 2017 at 19:10
  • \$\begingroup\$ Alright I got it down to 88 bytes and I think that's the best I can do here \$\endgroup\$ Mar 14, 2017 at 19:21

Pip, 28 bytes


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


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

Python 3, 271 bytes

I am aware that this is rather long and I welcome suggestions on how to reduce the length.

def f(s):
 for c in s:
  if c.isalpha():t+='e'
   if t:a(b,t);t=''
 if t:a(b,t)
 for i in b:
  if i[0]=='e':
   if len(i)>2:i[1]='l'
 return ''.join(f)
  • \$\begingroup\$ Welcome to the site! I see a couple golfs you could make. You can visit our tips page for a list of useful tips for golfing in Python. \$\endgroup\$
    – Wheat Wizard
    Mar 11, 2017 at 16:44
  • \$\begingroup\$ instead of x.append(y) or in your case, a(x,y), you can do x+=y, (comma required) \$\endgroup\$
    – Cyoce
    Mar 14, 2017 at 20:33

stacked, 57 bytes

'\l+'{!n size 2-:4\^5*1+3/\1<-4 tb 0\,'Blet'\#''join}repl

Try it online! Takes input from the top of the stack.

Let a(n) = A136412(n - 2) = (5 × 4n − 2 + 1) ÷ 3. Converting a(n) to base 4 yields:

a(3) = 134
a(4) = 1234
a(5) = 12234
a(6) = 122234

Mapping indices 0..3 to the string Blet, we get:

a(3) = lt
a(4) = let
a(5) = leet
a(6) = leeet

Now, prepending B gives us the desired string, given the length. Mostly. One just needs to handle the special cases for n ≤ 2. In my case, this is solved by subtracting (n − 2 < 1) as a numeric boolean (1 for "true" and 0 for "false").

As for the specifics of the answer:

'\l+'{! ... }repl
             repl    replace all
'\l+'                alphanumeric strings ("letters")
     {!     }        applying this function to the result.

Python 2, 137 114 bytes

def f(s,r='',l=-3):
 for c in s+'\0':
	if c.isalpha():l+=1
 print r

Try it online!


Java 7, 201 bytes

String c(String s){String r="",z="e([^e]|$)";char p=0;int x;for(char c:s.toCharArray()){x=c&~32;p=x>64&x<91?p==66?'l':p>100&p<109?'e':66:c;r+=p;}return r.replaceAll("l"+z,"lt$1").replaceAll(z,"et$1");}

Not really happy with it, and can certainly be golfed some more..


String c(String s){               // Method with String parameter and String return-type
  String r="",                    //  The return-String
         z="e([^e]|$)";           //  Partial regex String that's used twice ('e' followed by non-'e' or nothing)
  char p=0;                       //  The previous character
  int x;                          //  Another temp value
  for(char c : s.toCharArray()){  //  Loop over the characters of the input String
    x = c&~32;                    //   Make every lowercase character uppercase (this returns an integer, hence the integer temp value, which is shorter than a cast to char)
    p = x>64 & x<91 ?             //   If the current character is a letter:
         p == 66 ?                //    And if the previous character is 'B':
          'l'                     //     Set the character value to 'l'
         : p>100&p<109 ?          //    Else if the previous character is either an 'e' or 'l':
            'e'                   //     Set the character value to 'e'
           :                      //    Else:
            66                    //     Set the character value to 'B'
         :                        //   Else (not a letter):
          c;                      //    Set the character to the current character
    r += p;                       //   Append the result-String with this character
  }                               //  End loop
  return r                        //  Return the result-String
    .replaceAll("l"+z,"lt$1")     //   After we've replaced all occurrences of "le." with "lt." (where "." can be anything else, including nothing at the end of a line)
    .replaceAll(z,"et$1")         //   And also replaced all occurrences of "ee." with "et." (where "." can again be anything else)
}                                 // End of method

Test code:

Try it here.

class M{
  static String c(String s){String r="",z="e([^e]|$)";char p=0;int x;for(char c:s.toCharArray()){x=c&~32;p=x>64&x<91?p==66?'l':p>100&p<109?'e':66:c;r+=p;}return r.replaceAll("l"+z,"lt$1").replaceAll(z,"et$1");}

  public static void main(String[] a){
    System.out.println(c("Hello, World!"));
    System.out.println(c("lorem ipsum dolor sit amet."));
    System.out.println(c("We praise the Goat God!"));
    System.out.println(c("I have a pen"));


Bleeet, Bleeet!
Bleeet Bleeet Bleeet Blt Bleet.
Bl Bleeeet Blt Bleet Blt!
B Bleet B Blt
  • \$\begingroup\$ s.split("") instead of s.toCharArray() saves some I believe \$\endgroup\$
    – user41805
    Mar 11, 2017 at 10:33
  • \$\begingroup\$ @KritixiLithos I tried it, but then I have the issue of checking if the String is a letter (x=c&~32 won't work on a String, and x>64&x<91 both won't work anymore). If you can make it shorter with the split let me know, though. \$\endgroup\$ Mar 11, 2017 at 11:46

05AB1E, 36 bytes


Try it online! or as a Test suite


Prepare input:

lD                                    # convert input to lower-case and duplicate
  As                                  # push lower-case alphabet and swap input to the top
    Så                                # check each char in input for 
                                      # membership in the alphabet
      .¡                              # split into chunks of equal elements
        €g                            # get length of each chunk
          £                           # split input into chunks of those lengths

This creates a list such as ['hello', ', ', 'world', '!'] for the input Hello, World!

Iterate over list:

v                          # for each element in the list
 y                         # push current element
  AySåPi               }   # if all members of current element are letters
        gÍ<'e×             # repeat string "e" len(element)-3 times
              "Blÿt"       # replace "ÿ" with the e's in the string "Blÿt"
                    yg£    # take the first len(element) chars of the string
                        J  # join to string

sed -E, 58 bytes

Port of Martin Ender's Retina answer.


Attempt This Online!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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