백준 - 2941 크로아티아 알파벳
문제
2941 크로아티아 알파벳
답
kotlin code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fun main() {
q2941()
}
fun q2941() {
val input = readln()
var output = 0
var i = 0;
val croatianAlphabet = listOf("c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z=")
while(i < input.length) {
if(i + 2 < input.length && croatianAlphabet.contains(input.substring(i, i + 3)))
i += 3
else if(i + 1 < input.length && croatianAlphabet.contains(input.substring(i, i + 2)))
i += 2
else
i++
output++
}
println(output)
}
This post is licensed under CC BY 4.0 by the author.