“Polybius was an ancient Greek writer who first proposed a method of substituting different two-digit numbers for each letter. The alphabet is written inside a 5-by-5 2d array which a has numbered rows and columns:
1 | 2 | 3 | 4 | 5 | |
1 | A | B | C | D | E |
2 | F | G | H | I | J |
3 | K | L | M | N | O |
4 | P | Q | R | S | T |
5 | U | V | W | X | Y/Z |
Note both Y and Z are written in the last cell to divide the letters evenly. The context of the message should make clear which of the two letters is intended.
To encode, substitute for each letter the numbers marking the row and column in which the letter appears. Always put the row number first. For example, the number for J is 25. The word WATERMELON would be encoded as
53 11 45 15 43 33 15 32 35 34
To decode, simply locate each letter indicated by the number. The first number, 53, tells you to find the letter at the intersection of the fifth row and the third column.”
Write a program that uses the Polybius Checkerboard to encode strings and decode lists of numbers.