Ad
  • Default User Avatar

    small nit: Char.toInt will return the ASCII code for the character, eg:

    scala> '1'.toInt
    res15: Int = 49
    

    the proper method should be Char.asDigit, eg:

    scala> '1'.asDigit
    res16: Int = 1
    

    I haven't found an example if input that will result in wrong answer though.