title: Can you map/reduce a String into an Int?
body: <p>I was solving a problem on codeforces in which I had to sum up the digits of a big number (it can have up to 100k digits) and I'd have to repeat that process until there is only one digit left and count the number of times I did that and I came up with a working solution, however I'd like to know if some things could have been done in a more "Kotlin-ish like way", so given:</p>
  
  <pre><code>fun main(args: Array&lt;String&gt;) {
      println(transform(readLine()!!))
  }
  
  fun transform(n: String): Int {
      var count = 0
      var sum : Int
      var s = n
      while(s.length &gt; 1) {
          sum = (0 until s.length).sumBy { s[it].toInt() - '0'.toInt() }
          s = sum.toString()
          count++
      }
      return count
  }
  </code></pre>
  
  <ol>
  <li><code>sum = (0 until s.length).sumBy { s[it].toInt() - '0'.toInt() }</code> is there a way to I guess map the sum of digits in the string to the sum variable, or in general a better approach than the one I used?</li>
  <li>When converting a Char to an Int it converts it to the ASCII value so I had to add "-'0'.toInt()" is there a faster way (not that it's too much to write, asking out of curiosity)?</li>
  <li>How to make the String n mutable without creating a new String s and manipulating it? Or is that the desired (and only) way?</li>
  </ol>
  
  <p>P.S. I'm a beginner with Kotlin.</p>