Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created June 4, 2012 02:38
Show Gist options
  • Select an option

  • Save masahitojp/2866016 to your computer and use it in GitHub Desktop.

Select an option

Save masahitojp/2866016 to your computer and use it in GitHub Desktop.
def minus(n : Int) = {
val strList = n.toString().sortWith(_ < _)
strList.reverse.toInt - strList.toInt
}
def test(a:Int, b: Int):Int = if (b==0) a else test(minus(a), b-1)
test(1974,100)
// => 6174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment