Last active
October 16, 2021 12:46
-
-
Save IkumaTadokoro/6359f38b93e64566390725cc2a5f20de to your computer and use it in GitHub Desktop.
leetify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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