Created
May 30, 2017 09:03
-
-
Save iulianu/252c6f0a005b7d6d7a2c7854d30115b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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