Created
October 12, 2019 17:54
-
-
Save jamesmcm/a796b3023c9b6dd2c753025d88ef4853 to your computer and use it in GitHub Desktop.
scalaq.scala
This file contains hidden or 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
| def encodePair(pair: (Char, Char)): (Char, Char) = { | |
| (findLetterInSquare(pair._1), findLetterInSquare(pair._2)) match { | |
| case ((A, B), (A, D)) => (indexToLetter((A, (B+1)%5)), indexToLetter((A, (D+1)%5))) // same row | |
| case ((A, B), (C, B)) => (indexToLetter(((A + 1)%5, B)), indexToLetter(((C+1)%5, B))) // same column | |
| case ((A, B), (C, D)) => (indexToLetter((A, D)),indexToLetter((C, B))) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment