문제
1065 한수
답
kotlin code
import java.util.*
fun main() {
q1065()
}
fun q1065() = with(Scanner(System.`in`)) {
val input = nextInt()
var result = if(input < 100) input else 99
for(i in 111 .. input) {
val ints = i.toString().toCharArray().map { Character.getNumericValue(it) }
var itSame = true
val diffStd = ints[0] - ints[1]
for(j in 1 until (ints.count() - 1)) {
val diffThis = ints[j] - ints[j + 1]
if (diffStd != diffThis) {
itSame = false
break;
}
}
if(itSame) result++
}
println(result)
}