Created
November 21, 2017 20:09
-
-
Save kastoestoramadus/8d2143bdcb49fbb163fdd0f99a39fbc0 to your computer and use it in GitHub Desktop.
second
This file contains 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
val phones = List("91125426", "97 625 992", "911", "9761") | |
def isConsistent(pl: List[String]) = { | |
val sorted = pl.map(_.replaceAll(" ", "").replaceAll("-","")).sorted | |
sorted.tail.foldLeft((true, sorted.head)){ | |
case (bPrev, str) => | |
(bPrev._1 && !str.startsWith(bPrev._2), str) | |
}._1 | |
} | |
isConsistent(phones) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment