Created
December 25, 2021 07:44
-
-
Save gonaumov/387166476c700d8163eebda9581fdcf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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