import java.io.*
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val r = br.readLine()
var sum = 0
for (i in 0..r.length-1) {
when (r[i]) {
'A','B','C' -> sum += 3
'D','E','F' -> sum += 4
'G','H','I' -> sum += 5
'J','K','L' -> sum += 6
'M','N','O' -> sum += 7
'P','Q','R','S' -> sum += 8
'T','U','V' -> sum += 9
'W','X','Y','Z' -> sum += 10
}
}
println(sum)
br.close()
}
메모리 |
시간 |
언어 |
코드 길이 |
11860 KB |
88 ms |
Kotlin (JVM) |
536 B |
조건문 when
when (x) {
1 -> print("x == 1")
2 -> print("x == 2")
else -> { // Note the block
print("x is neither 1 nor 2")
}
}
when (x) {
0, 1 -> print("x == 0 or x == 1")
else -> print("otherwise")
}