Created
November 1, 2016 08:32
-
-
Save CaseyLeask/7a6599e90eacf8373ed918ff2dcb494d to your computer and use it in GitHub Desktop.
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
import scala.io.StdIn.{readInt,readLine} | |
import scala.io.Source | |
object Solution { | |
def main(args: Array[String]) { | |
val count = readInt() | |
val phoneBook = (1 to count).foldLeft(List[String]())((phoneBook, _) => { | |
readLine().split(" ") match { | |
case Array(k, v) if v.endsWith("@gmail.com") => phoneBook :+ k | |
case _ => phoneBook | |
} | |
}) | |
for (name <- phoneBook.sorted) { | |
println(name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment