Created
October 29, 2016 03:05
-
-
Save CaseyLeask/4cb0f704e25c36e7995199e42423448b 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(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