So today at the beginning of the class, our teacher asked us to write a function that translates a given string to "leet speak" (basically having to replace every character to another).

Some used python dictionnaries, some used arrays...

And the two people arround me wrote a program with a condition for EVERY SINGLE CHARACTER.

It kind of made me wanna die or kill them πŸ˜₯

  • 5

    He says as he realizes this is some shit he'd do.
  • 2
    @jhh2450 πŸ˜‚

    Well honnestly I didn't use the dictionnary solution because I don't use python a lot so I didn't think about it, but it's the most efficient one.

    I basically created an array with our alphabet and an array with the corresponding characters, converted the string to an array, replaced every char and converted it back to a string, whereas the dictionnary just uses every char of the string as the key to the corresponding char, so you basically just have to scan the string
  • 1
    @Tahaga Well my thought process is setting a condition for every character is easy. It's repetitive and kinda ugly to read, but it gets the job done. And it's also hard to fuck it up lmao
  • 1
    @jhh2450 it does work, but for some bigger tasks it would be difficult
    (+ I haven't checked it, but I feel like a condition for every character is quite slower)
    I think it's better to do it in a way that it would be scalable and easier maintainable, this way you get the good Habits while learning! πŸ˜„
  • 2
    @Tahaga Oh it's definitely better to not do it. It's incredibly inefficient, but if it meets the requirements for class, fuck it. Lol
  • 0
    @jhh2450 yeah πŸ˜‚
  • 1
Add Comment