object ArmstrongNumber {
fun check(input: Int): Boolean {
val digits = input.toString().map { it.toString().toInt() }
val numberOfDigits = digits.size
val sum = digits.sumOf { digit ->
digit.toDouble().pow(numberOfDigits).toInt() }
return sum == input
}
}
I have the implementation above for armstrongnumber, when I run that code in my ide against the unit tests, all the tests are passing but when I run it on the exercism platform, the test are not passing, I noticed that perhaps the exercism ide does not have the pow method, I manually added that and all the tests are now passing also in the exercism online ide, but I cannot submit the task, I am getting the prompt that all the tests need to pass when I try to submit the code. Screenshot attached.
#ArmstrongNumber Kotlin
2 messages · Page 1 of 1 (latest)