Skip to content

Instantly share code, notes, and snippets.

@iulianu
Created May 30, 2017 09:03
Show Gist options
  • Save iulianu/252c6f0a005b7d6d7a2c7854d30115b3 to your computer and use it in GitHub Desktop.
Save iulianu/252c6f0a005b7d6d7a2c7854d30115b3 to your computer and use it in GitHub Desktop.
import scala.collection.JavaConverters._
// you can write to stdout for debugging purposes, e.g.
// println("this is a debug message")
object Task1Solution {
def phoneMetric(number: Int): Long = {
val numberStr = number.toString
100000000000L * numberStr.size +
10000000000L * numberStr.distinct.size +
number
}
def solution(a: Array[Int]): Int = {
a.minBy(phoneMetric)
}
}
object Main2 extends App {
println(Task1Solution.solution(Array(1233, 1111111, 1333, 34126, 3131)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment