Skip to content

Instantly share code, notes, and snippets.

@heathermiller
Created July 7, 2014 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heathermiller/1f0a82217f2b7652387f to your computer and use it in GitHub Desktop.
Save heathermiller/1f0a82217f2b7652387f to your computer and use it in GitHub Desktop.
val codeToChars: Map[Char, String] =
Map(
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ"
)
/**
* Inverse of codeToChars,
* e.g. 'A' -> '2', 'B' -> '2'.
*/
val charCode: Map[Char, Char] =
for {
(digit, chars) <- codeToChars
char <- chars
} yield char -> digit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment