Skip to content

Instantly share code, notes, and snippets.

@gonaumov
Created December 25, 2021 07:44
Show Gist options
  • Save gonaumov/387166476c700d8163eebda9581fdcf0 to your computer and use it in GitHub Desktop.
Save gonaumov/387166476c700d8163eebda9581fdcf0 to your computer and use it in GitHub Desktop.
/**
* Merry Christmas from Kotlin
*/
fun main() {
println(
arrayOf(
"M",
"rr",
"Chr",
"stm",
"s"
).zip(
arrayOf(
"e",
"y ",
"i",
"a",
""
)
) { a, b ->
a + b
}.joinToString("")
)
}
fun splitToVowelsAndConsonantsAndDumpArrays(input: String) {
val myRegex = "([^aeiouy]+)([aeiouy\\s]*)".toRegex(RegexOption.IGNORE_CASE)
val consonants: MutableList<String> = mutableListOf()
val vowels: MutableList<String> = mutableListOf()
input.replace(myRegex, ({
consonants.add(it.groupValues[1])
vowels.add(it.groupValues[2])
""
}))
dumpToArray(consonants)
dumpToArray(vowels)
}
fun dumpToArray(input: List<String>) {
print("arrayOf(\"")
print(input.joinToString("\",\n\""))
println("\")")
println()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment