Skip to content

Instantly share code, notes, and snippets.

@CaseyLeask
Created October 29, 2016 03:05
Show Gist options
  • Save CaseyLeask/4cb0f704e25c36e7995199e42423448b to your computer and use it in GitHub Desktop.
Save CaseyLeask/4cb0f704e25c36e7995199e42423448b 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(Map[String, String]())((phoneBook, _) => {
readLine().split(" ") match {
case Array(k, v) => phoneBook + (k -> v)
case _ => phoneBook
}
})
var key = readLine()
while (key != null) {
phoneBook.get(key) match {
case Some(value) => println(s"$key=$value")
case None => println("Not found")
}
key = readLine()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment