# Make me speak L33T

I want to be down with the kids of the 1990's and start speaking this L33T speak of their's.

For any given input I would like the resulting L33T speech as an output.

I don't want to go to far down the rabbit hole so let's start simple. Consider the following replacements:

B or b = 8

E or e = 3

I or i = 1

S or s = 5

Lets get down with the kids people.

• Bruh, it's 1337 – Poke Nov 18 '19 at 14:53
• Not sure why this was VTC questions without an objective primary winning criterion are off-topic, since the challenge was tagged as code-golf from the beginning. – Arnauld Nov 18 '19 at 16:07
• We need an answer in l33t. – Arnauld Nov 18 '19 at 23:55
• @some_guy632 There is no 7 in L33T as OP mentions. But then again, OP thinks that "i" is substituted with 1. So yeah, this might be a whole different dialect! Not sure which 90s kids were using this, though ... – Num Lock Nov 19 '19 at 6:41
• 1 in Chinese sounds like an i. – user85052 Nov 20 '19 at 9:31

# 05AB1E, 1413 12 bytes

„ÛãbÂu«ŽKcº‡


-1 byte thanks to @Grimy by using the dictionary word sie.

Try it online.

12 bytes alternative (from @Grimy):

2F.š„ÛãbŽKc‡


Try it online.

Explanation:

„Ûãb          # Push dictionary string "sieb"
Â         # Bifurcate it (short for Duplicate & Reverse copy)
u        # Uppercase the copy
«       # Merge the strings together: "siebBEIS"
ŽKc    # Push compressed integer 5138
º   # Mirror it: 51388315
‡  # Transliterate "siebBEIS" to "51388315" in the (implicit) input-string
# (after which the result is output implicitly)

2F            # Loop 2 times:
.š          #  Switch the case of the string (lower- to uppercase, and vice-versa)
#  (which will use the implicit input-string in the first iteration)
„Ûãb      #  Push dictionary string "sieb"
ŽKc   #  Push compressed integer 5138
‡  #  Transliterate "sieb" to "5138" in the string
# (after the loop, the result is output implicitly)


See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress large integers?) to understand why „Ûãb is "sieb" and ŽKc is 5138.

• Iterative is the same: .•ª³•vyŽWœNè: – Magic Octopus Urn Nov 18 '19 at 22:16
• @MagicOctopusUrn That program only replaces the lowercase letters, though. Uppercase BEIS characters remain unchanged I'm afraid. – Kevin Cruijssen Nov 19 '19 at 7:05
• -1 with dictionary word sie. And here's an alternative 12. – Grimmy Nov 19 '19 at 12:29
• @Grimmy How did I miss that sie.. I've looked through the dictionary in search for useful words containing the letters, but couldn't find any. I thought about is be, but the space and being two dictionary words (requiring four characters) would only increase the byte-count. Thanks! And nice alternative with the loop and switch-case, I'll add it. :) – Kevin Cruijssen Nov 19 '19 at 12:41

# JavaScript (ES6), 49 bytes

s=>s.replace(/[beis]/gi,c=>parseInt(c+1,31)%9||8)


Try it online!

### How?

By using parseInt(), we don't have to worry about the case at all since lowercase and uppercase letters are parsed the same way. The downside of this formula is that we have to explicitly turn $$\0\$$ into $$\8\$$. It's still 1 byte shorter than the Node version, though.

 char | +'1' | base 31 -> decimal | mod 9 | || 8
------+------+--------------------+-------+------
'b' | 'b1' |         342        |   0   |  8
'e' | 'e1' |         435        |   3   |  3
'i' | 'i1' |         559        |   1   |  1
's' | 's1' |         869        |   5   |  5


# JavaScript (Node.js),  54  50 bytes

s=>s.replace(/[beis]/gi,c=>17/(Buffer(c)[0]%16)|0)


Try it online!

### How?

We look for beis in the input string in a case-insensitive way. For each matching character of ASCII code $$\n\$$, we apply the following formula:

$$f(n)=\left\lfloor\frac{17}{n\bmod 16}\right\rfloor$$

which gives:

 char | ASCII code | mod 16 -> x | 17 / x | floor
------+------------+-------------+--------+-------
'B' |      66    |      2      |  8.5   |   8
'b' |      98    |      2      |  8.5   |   8
'E' |      69    |      5      |  3.4   |   3
'e' |     101    |      5      |  3.4   |   3
'I' |      73    |      9      |  1.889 |   1
'i' |     105    |      9      |  1.889 |   1
'S' |      83    |      3      |  5.667 |   5
's' |     115    |      3      |  5.667 |   5


NB: we could use $$\16\$$ instead of $$\17\$$ just as well.

• +1. How did you figure out that formula? (And the past ones, for that matter) – Malivil Nov 18 '19 at 15:27
• @Malivil There's usually a good deal of brute-forcing, but not that much for this one. The mod 16 was trivial, given the way the ASCII table is built. And once I had 2,5,9,3 to be mapped to 8,3,1,5, it looked very promising to try something / x (I did write a short script for that, but now I realize that it's not very hard to find it with mental calculation.) – Arnauld Nov 18 '19 at 15:38

# QuadR with i flag, 15 bytes

B
E
I
S
8
3
1
5


Try it online!

I don't need to explain this, do I?

• 1'm afra1d 1 don't und3r5tand th353 5trang3 charact3r5 B, E, I, S 1n your cod3, 1 hav3 n3v3r 3ncount3r3d th3m 83for3 – Quintec Nov 18 '19 at 22:58

# Perl 5 (-p), 19, 18 bytes

-1 thanks to @manatwork

y;BbEeIiSs;8833115


Try it online!

• You can cut off the last “5”, because “if the REPLACEMENTLIST is shorter than the SEARCHLIST, the final character, if any, is replicated until it is long enough” — perldoc y///. – manatwork Nov 18 '19 at 16:22
• sure, I had the idea but then forgot about looking for another approach – Nahuel Fouilleul Nov 18 '19 at 16:48

## tr, 2320 19

tr BbEeIiSs 8833115


Try it online!

• -1 byte from man SET2 is extended to length of SET1 by repeating its last character as necessary. – Nahuel Fouilleul Nov 18 '19 at 16:57
• This is the same as @Delta'a Bash answer (codegolf.stackexchange.com/a/196065/61292) – Wernisch Nov 21 '19 at 15:54
• @Wernisch: which I posted 1 day before delta – Thor Nov 21 '19 at 18:12

# R, 39 bytes

chartr('BbEeIiSs','88331155',scan(,''))


Try it online!

• Beat me by 10 minutes... but I had this exact solution typed up. I was too busy experimenting with utf8ToInt to see if it had any possibility of being shorter. – Sumner18 Nov 18 '19 at 17:22
• @Sumner18 Yeah, I was originally looking at using the formula in Arnauld's answer. Then I remembered chartr! – Robert S. Nov 18 '19 at 17:26

# Python 3, 53 bytes

lambda x:x.translate(dict(zip(b"BEISbeis",2*"8315")))


Try it online!

-17 bytes thanks to Jitse

• 53 bytes – Jitse Nov 18 '19 at 14:59
• @Jitse I thought translate had to be used with integer keys... whoops. Thanks! – HyperNeutrino Nov 18 '19 at 17:56
• It does, but I'm using a bytestring which does contain integers. – Jitse Nov 18 '19 at 20:43

# C (gcc) (x86-64),  71 70  65 bytes

This is essentially a port of my Node answer.

c;f(char*s){for(;c=*s++;)putchar(524836>>c&c/64?48|16/(c&15):c);}


Try it online!

### How?

On x86-64, 524836>>c is turned into:

mov     eax, DWORD PTR c[rip]
mov     edx, 524836
mov     ecx, eax
sar     edx, cl


The count operand of sar (and other shift instructions) is masked to 5 bits. So this is equivalent to 524836>>(c&31).

Therefore, 524836>>c&c/64 is truthy if $$\64\le c<127\$$ and $$\c\bmod32\$$ is one of:

 10000000001000100100
^         ^   ^  ^
19         9   5  2
(s)       (i) (e)(b)
(S)       (I) (E)(B)


# PostgreSQL, 54 characters

\prompt s
select translate(:'s','beisBEIS','83158315')


Sample run:

bash-5.0$psql -Atf leet.sql <<< 'aA~bB~eE~iI~sS~zZ' aA~88~33~11~55~zZ  # sed, 20 bytes y/beisBEIS/83158315/  Try it online! # Gema (with -i switch), 15 characters b=8 e=3 i=1 s=5  Sample run: bash-5.0$ gema -i 'b=8;e=3;i=1;s=5' <<< 'This is a test: BbEeIiSs'
Th15 15 a t35t: 88331155


Try it online!

# PHP, 36 34 bytes

<?=strtr($argn,BbEeIiSs,88331155);  Try it online! • -2 bytes thx to @manatwork! • Why the quotes around the 2nd argument? – manatwork Nov 18 '19 at 18:30 ## Batch, 71 bytes @set/ps= @set s=%s:b=8% @set s=%s:e=3% @set s=%s:i=1% @echo(%s:s=5%  Takes a line of input on STDIN. Batch's substitute operator is automatically case insensitive. # Bash, 66 43 bytes sed -e"s/b/8/Ig;s/e/3/Ig;s/i/1/Ig;s/s/5/Ig"  Try it online! 19 Bytes I will leave it hear as it was suggested by @WGroleau as an improvement but was already posted by @Thor tr BbEeIiSs 8833115  Try it online! Thnaks to: -@MD XF for saving 23 bytes -@WGroleau for saving 23 bytes -@Jo King for saving 1 byte • Works fine without the function stuff... try it online – MD XF Nov 18 '19 at 23:39 • But you can use tr in bash for only twenty characters. – WGroleau Nov 19 '19 at 5:03 • Is "bash" the right title for this answer, rather than something like "GNU coreutils" or "POSIX commands"? – rexkogitans Nov 19 '19 at 10:06 • @rexkogitans I would argue that the core utils from gnu are a part of the bash utils or am I wrong? – Delta Nov 19 '19 at 11:17 • @Delta no, at least neither in Debian nor in Manjaro, coreutils is a dependency of bash, and also not the other way around. tr is part of coreutils, and sed is standalone. – rexkogitans Nov 19 '19 at 14:35 # Ruby, 33, 31, 29, 28 bytes ->x{x.tr"BEISbeis","8315"*2}  Try it online! -2 bytes thanks to @manatwork • 1) No need for ! as you only care about .tr's returned value, not x itself; 2) no need for parenthesis around .tr's arguments. – manatwork Nov 18 '19 at 15:52 • @manatwork Nice catch! Thanks for saving me those 2 bytes!!! – game0ver Nov 18 '19 at 15:55 # Haskell, 58 55 bytes -3 bytes thanks to @Laikoni! map(\c->last$c:[b|(a,b)<-zip"BEISbeis""83158315",a==c])


Try it online!

• 55 bytes: Try it online! – Laikoni Nov 18 '19 at 15:51
• @Laikoni Thanks! The Just was just so inefficient:) – flawr Nov 18 '19 at 16:03

# Excel, 147 bytes

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"B",8),"b",8),"E",3),"e",3),"I",1),"i",1),"S",5),"s",5)


So elegant...

• I'm afraid you forgot to transliterate “s” and “S” to “5”. – manatwork Nov 18 '19 at 17:33
• Yeah but the nested "SUBSITUTE"s look really cool even though it´s never going to win.. It´s the sort of thing I´d do with Lotus Formula using @ReplaceSubstring just for the fun of it but Formula is even more verbose than Excel. +1 – ElPedro Nov 18 '19 at 20:04
• Exactly, @ElPedro. 2 more SUBSTITUTE() calls and the part of the code visible at first glace will be just those, needing to scroll for the rest. Will have a definitely unique look. – manatwork Nov 18 '19 at 20:45
• Thanks @manatwork, have updated. – Wernisch Nov 19 '19 at 11:38
• @Thor Are you allowed to alter other letters? I don't see any other answers doing that. – Neil Nov 21 '19 at 11:16

# l33t, 1346 bytes

5o y0u want t0 l34rn t0 sp33k 0n teh 1ntERn1t... 4r3 y0u t3h 14m3rz d00d?
is s0 EZ t0 8e 888888881 awes0mes!! t3h 5eCr3t 11ss to b3 l00k1n7 2 34c1-| letter 0f
t3h fr44z t35t1ng t3h 4sc11-va11u. R34c7 to t3h
zer0 8y go-2 t3h end. 8efor a11 8e g0 w3 n33d-2 5m4sH all t3h l4m3 9999999999996 1etters.
5ome 0f the 1e7ers d0n't n33d t0 b3 ch4ng3d!1 S0 we le4ve them 4l0ne.
5o j00 b3 z33ro s0 w33'1l 999997 1n 5o y0u r3m3mb2r us 4 t33h next 0ne.
cl3r m3m3r11s to bre4k out.
4t thi5 p0int w3 n33d t0 4r3 7777776 & pr1nt 50 j00 5e3 the '0ne' 4 th33 'i'
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 999995 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 8888887 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 999997 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 7777776 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 999995 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
cl3r m3m3r11s to bre4k out.
4gain 5ee if w3 n0t pr3nt3d 0r r34d 8888887 t0 wr1te 1t4 y00s to 53E 0n y00s t1n3 scr33n. Then
50 j00 r34d all tH3s3 c0Des, n0w 2 r43d m0re 4nd l00p
bye 5uXz0r5!



Try it online!

I think its self explanatory really. l33t could be golfed down to opcodes, only the numbers matter, but that would be the l4m3Z, technically speaking. (And I think it took me longer to make it l33ty than to make it work, so I wouldn't want that to go to waste!)

Here's the l4m3 version, for those interested.

# Keg, 56 19 bytes

?(¦b8|e3|i1|s5║ ™⅍,


Uses the newly implemented switch statements to remove 37 bytes!

# C# (Visual C# Interactive Compiler), 53 bytes

Inputs a string, outputs an array of char codes.

s=>s.Select(c=>"beisBEIS".Contains(c)?48+17/(c%16):c)


Try it online!

# C# (Visual C# Interactive Compiler), 98, 92, 70, 55 bytes

s=>s.Select(x=>(x+"88331155")["BbEeIiSs".IndexOf(x)+1])


Try it online!

• If you inline the using you can save 6 bytes. Try it online! – Malivil Nov 18 '19 at 15:25
• You don't need the string.Concat – Embodiment of Ignorance Nov 18 '19 at 16:28

# Pyth, 17 bytes

XQ"BEISbeis""8315


Try it online!

X                    # Translate characters in
Q                   # the input
"BEISbeis"         # that are in this string from this string
"8315"   # to this string (modular indexing: "B"->"8", "b"->"8")

• Sadly srB"BEIS"0 doesn't save anything. If only there was one more letter! – FryAmTheEggman Nov 19 '19 at 19:15

# IBM/Lotus Notes Formula, 76 bytes

@ReplaceSubstring(i;@Explode("B b E e I i S s");@Explode("8 8 3 3 1 1 5 5"))


Takes input as i. Works because @ReplaceSubstring can take a list of characters to replace and a list of replacement characters and match them one to one.

There is no TIO for formula so a screenshot is shown below:

# Japt, 13 bytes

dßÈí8#ì)pu


Includes an unprintable (charcode 153) after the #.

Try it

dßÈí8#ì)pu      :Implicit input of string
d                 :For each pair of characters in the following, replace the first with the second
ßÈ             :  Compressed string "bise"
í            :  Interleave
8#          :    8153
ì        :    To digit array
)       :  End interleave
p      :  Append
u     :    Uppercase


# Retina, 2019 16 bytes

YB\EISbeis8315


-1 byte thanks to @ovs (transliterating Ss to 5 due to (quote from docs): "If the to list is shorter than the from list and the current character appears after the end of the to list, it gets mapped to the last character in the to list (alternatively, you can think of it as padding to to the length of from using the last character in to)." So only a single 5 is necessary in the to list.)
-3 bytes thanks to @FryAmTheEggman, using the cyclic transliterate Y instead of the regular T.

Try it online.

Explanation:

Pretty straight-forward; transliterates the characters BEISbeis to 83158315.

Two things to note:
- The \ is to escape the E, because the E within the transliterate is a builtin for 02468.
- The cyclic transliterate Y is used instead of the regular transliterate T. In the cyclic transliterate, the characters are repeated indefinitely. So the BEISbeis is actually BEISbeisBEISbeisBEISbeis... and the 8315 is actually 831583158315... Only the first character in the from-list are relevant, though. So this will transliterate BEISbeis to 83158315.

• 1 byte shorter with TbeiB\EISs8318315 – ovs Nov 19 '19 at 12:34
• @ovs Thanks! I really should take some time to read through the entire docs more carefully. – Kevin Cruijssen Nov 19 '19 at 12:56
• Cyclic transliteration is slightly more complicated than that, but that doesn't apply in this case as your from list length is a multiple of your to list length. – Neil Nov 21 '19 at 11:24

# Brainfuck, 475 bytes

>,[>+++++++++++[<------>-]<[>++[<+++++>-]]<[<]>>++[<----->-]<---[>+++[<++++++>-]]<[<]>>+++[<------>-]<----[>++++[<++++++>-]]<[<]>>++++[<------>-]++[<----->-]<[>+++++[<++++++>-]]<[<]>>+++++[<------>-]+++[<----->-]<[>++++++[<+++++++>-]]<[<]>>++++++[<------->-]<---[>+++++[<++++++++++>-]]<[<]>>+++++[<---------->-]<----[>+++++++[<++++++++>-]]<[<]>>+++++++[<-------->-]++[<----->-]<[>++++++[<++++++++++>-]<++>]<[<]>>++++++[<---------->-]<-->++++++++++[<+++++++++++>-]<+++++.[-],]


Basically, it works like this:

1. For each inputted character...
1. Subtract the value of B
2. If the resulting value is nonzero, add B-8
3. Subtract B-8
4. Subtract the value of B-E
5. If the resulting value is nonzero, add E-3
6. Subtract E-3
7. So on for every letter in the order of least to greatest ASCII
8. At the end, add the value of s (the greatest ASCII) back

Sorry it's like super duper messy.

# Vim, 4844 42 bytes

se ic
%s/b/8/g
%s/e/3/g
%s/i/1/g
%s/s/5/g


A Vim script taking advantage of the repeated pattern has more bytes:

# Vim, 82 59 bytes

for p in ['b/8','e/3','i/1','s/5']
exe'%s/\c'.p.'/g'
endfo


# T-SQL, 127 bytes

print replace(replace(replace(replace(replace(replace(replace(replace(@,'e',3),'E',3),'b',8),'B',8),'i',1),'I',1),'s',5),'S',5)


Assuming "@" the input. Not very efficient, though. :)

• starting from SQL Server 2017 you can use the TRANSLATE function – grabthefish Nov 19 '19 at 11:37
• @grabthefish Thank you, still using 2012 and 2016 versions. – JuanCa Nov 19 '19 at 14:28

# J, 28 bytes

rplc'BEISbeis';"0'8315'\$~8"1


Try it online!

# CJam, 20 characters

q"beisBEIS"83152*er
`

Try it online!