Kotlin Imperative Solution
Code
# Code
```kotlin []
class Solution {
    fun hasSameDigits(s: String): Boolean {
        var s = s; var i = 1
        while (s.length > 2) {
            val str = StringBuilder()
            for (i in 1 until s.length)
                str.append(
                    (s[i - 1].digitToInt() + s[i].digitToInt()) % 10
                )
            i = 1; s = str.toString()
        }
        return s.first() == s.last()
    }
}
```
['Kotlin']