23
\$\begingroup\$

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.

\$\endgroup\$
  • 64
    \$\begingroup\$ Bruh, it's 1337 \$\endgroup\$ – Poke Nov 18 at 14:53
  • 9
    \$\begingroup\$ 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. \$\endgroup\$ – Arnauld Nov 18 at 16:07
  • 4
    \$\begingroup\$ We need an answer in l33t. \$\endgroup\$ – Arnauld Nov 18 at 23:55
  • 1
    \$\begingroup\$ @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 ... \$\endgroup\$ – Num Lock Nov 19 at 6:41
  • \$\begingroup\$ 1 in Chinese sounds like an i. \$\endgroup\$ – A̲̲ Nov 20 at 9:31

42 Answers 42

1
\$\begingroup\$

C (gcc), 152 143 140 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
\$\endgroup\$
  • \$\begingroup\$ 96 bytes \$\endgroup\$ – ceilingcat Nov 21 at 19:46
  • \$\begingroup\$ @ceilingcat That seems to be borrowing a lot of ideas from my answer... \$\endgroup\$ – JL2210 Nov 21 at 21:18
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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));}}}

Try Online

\$\endgroup\$
1
\$\begingroup\$

///, 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!

\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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!

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

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.
```
\$\endgroup\$
0
\$\begingroup\$

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"
\$\endgroup\$
0
\$\begingroup\$

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)
\$\endgroup\$
0
\$\begingroup\$

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!

\$\endgroup\$

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.