Skip to content

Instantly share code, notes, and snippets.

@CaseyLeask
Created November 1, 2016 08:32
Show Gist options
  • Save CaseyLeask/7a6599e90eacf8373ed918ff2dcb494d to your computer and use it in GitHub Desktop.
Save CaseyLeask/7a6599e90eacf8373ed918ff2dcb494d to your computer and use it in GitHub Desktop.
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