Skip to content

Latest commit

 

History

History

polybius-square-cipher-encode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Implement the Polybius square cipher.

Replace every letter with a two-digit number. The first digit is the row number, and the second digit is the column number of following square. Letters 'I' and 'J' are both 24 in this cipher:

12345
1ABCDE
2FGHI/JK
3LMNOP
4QRSTU
5VWXYZ

Input will be valid (only spaces and uppercase letters from A to Z), so no need to validate them.

Examples

Solution.polybius("A")  // "11"
Solution.polybius("IJ") // "2424"
Solution.polybius("CODEWARS") // "1334141552114243"
Solution.polybius("POLYBIUS SQUARE CIPHER") // "3534315412244543 434145114215 132435231542"