# 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 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 at 16:07
• We need an answer in l33t. – Arnauld Nov 18 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 at 6:41
• 1 in Chinese sounds like an i. – A̲̲ Nov 20 at 9:31

# C (gcc), 152143140 128 bytes

a[256];c=256;main(){for(;a[c]=--c;)a[66]=a[98]=56;for(a[69]=a[101]=51;c=~getchar(a[73]=a[105]=49);printf(a+~c))a[83]=a[115]=53;}


Requires ASCII. Try it online!

• -8 bytes using this to transform ASCII characters to their codes and using c+1 rather than c>-1 to check if EOF is reached
• -3 bytes using toupper rather than tolower and changing all characters to their ASCII codes
• -3 bytes abandoning that whole track together and using a character dictionary instead
• -12 bytes thanks to @ceilingcat
• 96 bytes – ceilingcat Nov 21 at 19:46
• @ceilingcat That seems to be borrowing a lot of ideas from my answer... – JL2210 Nov 21 at 21:18

# Icon, 52 bytes

I was looking for a way to represent the 8-digit number as a shorter expression, but only got the same length:

procedure f(s)
return map(s,"ESIseiBb",77^4+147)
end


Try it online!

# Icon, 52 bytes

procedure f(s)
return map(s,"BEISbeis",83158315)
end


Try it online!

Test case taken from @Arnauld

# Clojure, 101 bytes

(defn l[s](clojure.string/replace s #"[BEISbeis]"{"B""8""b""8""E""3""e""3""I""1""i""1""S""5""s""5"}))


Try it online!

# Perl 6, 19 bytes

{TR/beisBEIS/8315/}


Try it online!

Kinda annoying that the case-insensitive adverb doesn't work with transliteration. That's made up a little by the second half cycling for both cases.

# C# .NET, 145 bytes

class P{static void Main(string[]a){foreach(var c in a[0]){var d=c%32;System.Console.Write((char)(c>64?d==5?51:d==2?65:d==9?49:d==19?53:c:c));}}}


# ///, 40 bytes

/B/b//b/8//E/e//e/3//I/i//i/1//S/s//s/5/


Input should be appended to the program.

Try it online!

# K (oK), 29 bytes

Solution:

{x[&y=_x]:z}/[;"ebis";"3815"]


Try it online!

Explanation:

There is no ssr in oK, this is good enough for single character replacement.

Explanation:

{x[&y=_x]:z}/[;"ebis";"3815"] / the solution
{          }/[;      ;      ] / lambda that iterates over implicit x, y and z
"3815"  / our z, leet characters
"ebis"         / our y, non-leet characters
x[     ]:z                   / assign z to x at indices given inside []
_x                      / lowercase x
y=                        / equal to y?
&                          / indices where true


# Python, 60 bytes

lambda s:''.join([('8315'*2)['beisBEIS'.find(c)] if c in 'beisBEIS' else c for c in s])


edit - size was wrong. Thanks Jo King!

• Welcome to the site! – MD XF Nov 18 at 23:40
• 60 bytes – Jo King Nov 19 at 7:28
• The size wasn't wrong. Jo King linked to a better solution which is 60 bytes long. – JL2210 Nov 22 at 17:27

# GolfScript, 48 bytes

GolfScript doesn't have those fancy replacement functions. This simply indexes into a lookup table.

Hopefully I should be able to golf this better than Keg. Look ma, no Unicode!

"Bb8Ee3Ii1Ss5"1/:x;1/{.x?-1={}{x?.3%- 2+x\=}if}/


Try it online!

## Explanation

# Implicit input is prepended onto the stack.

"Bb8Ee3Ii1Ss5"                                   # This is our lookup table.
1/:x;                              # We split it into a list, set to a variable, and discard it.
1/                            # Split the input into a list.
{                        }/ # Foreach input:
.                          # Duplicate the each value.
x?                        # Try to index the value into the lookup table.
-1=                     # Does this value exist?
{}              if   # If not, do nothing.
{            }     # Otherwise...
x?                # Where is this number in the lookup table?
.3%- 2+         # There is a formula for creating the sequence 2, 2, 2 (which refers to the character 8)
# and 5, 5, 5 (which refers to the character 3) and so on.
# n-(3%n)-2
# This will work for the numbers because the number characters index exactly into the intended positions, avoiding to modify them.
x\=      # Index the generated value into x and return the value to the string.

# There is an implicit output.
$$$$


# Q/kdb+, 26 bytes

Solution:

ssr/[;"ebisEBIS";8#"3815"]


Examples:

q)ssr/[;"ebisEBIS";8#"3815"]"Elite!"
"3l1t3!"
q)ssr/[;"ebisEBIS";8#"3815"]"The quick brown fox..."
"Th3 qu1ck 8rown fox..."


Explanation:

Perform search and replace over the input

ssr/[;"ebisEBIS";8#"3815"] / the solution
ssr/[;          ;        ] / iterate (/) ssr[input;find;replace]
8#"3815"  / 8 take "3815" => "38153815"
"ebisEBIS"           / the string "ebisEBIS"


## Mumps (M), 32 bytes

R I W $TR(I,"BbEeIiSs",88331155)  Although... it might look a tad 'weird.' Mumps doesn't output a carriage return even if typed on input, so the input & output will be all in a single line. To aid readability, add 2 characters: R I W !,$TR(I,"BbEeIiSs",88331155)


# C (gcc), 84 83 bytes

-1 byte thanks to ceilingcat!

n[]={[83]=5,[73]=1,[69]=3,[66]=8},c;f(char*s){for(;*s;c?*s=c+48:c,s++)c=n[*s&~32];}


Ungolfed and commented:

int n[] =
{ /* lookup table */
['S'] = 5,
['I'] = 1,
['E'] = 3,
['B'] = 8
};
int c;

void f(char *s)
{
/* if lookup table entry is not empty,
set *s to that entry + '0' for the ASCII representation
else do nothing
increment s and repeat */
for( ; *s; c ? (*s = c + '0') : c, s++ )
c = n[*s & ~32]; /* uppercase */
}
`

Try it online!