Skip to content

Instantly share code, notes, and snippets.

@IkumaTadokoro
Last active October 16, 2021 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IkumaTadokoro/6359f38b93e64566390725cc2a5f20de to your computer and use it in GitHub Desktop.
Save IkumaTadokoro/6359f38b93e64566390725cc2a5f20de to your computer and use it in GitHub Desktop.
leetify
class Leetify
LEET_TABLE = {
'a' => 4,
'A' => 4,
'b' => 8,
'B' => 8,
'e' => 3,
'E' => 3,
'l' => 1,
'L' => 1,
'o' => 0,
'O' => 0,
's' => 5,
'S' => 5,
't' => 7,
'T' => 7,
'z' => 2,
'Z' => 2,
}.freeze
def self.leetify(original_string)
original_string.chars.map { |s| LEET_TABLE[s] || s }.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment