Wavecycle
09/23/2020, 2:24 PMclass Leetspeak : Encoder() {
private val leetChars = mapOf<String, String>("a" to "4", "e" to "3", "l" to "1",
"m" to "/^^\\", "o" to "0", "u" to "(_)")
override fun encode(source: String?): String {
return if (source.isNullOrEmpty()) ""
else source.map { it: Char -> leetChars.get(it) ?: it.toString() }
.joinToString("")
}
}
diesieben07
09/23/2020, 2:26 PMleetChars.get
with a Char
. But the map keys are String
. The get
will never return anythingWavecycle
09/23/2020, 2:27 PM