Return the pair of numbers that represents the given letter in the polybius square >>> np.array_equal(PolybiusCipher().letter_to_numbers('a'), [1,1]) True >>> np.array_equal(PolybiusCipher().letter_to_numbers('u'), [4,5]) True
(self, letter: str)
| 22 | self.SQUARE = np.array(SQUARE) |
| 23 | |
| 24 | def letter_to_numbers(self, letter: str) -> np.ndarray: |
| 25 | """ |
| 26 | Return the pair of numbers that represents the given letter in the |
| 27 | polybius square |
| 28 | >>> np.array_equal(PolybiusCipher().letter_to_numbers('a'), [1,1]) |
| 29 | True |
| 30 | |
| 31 | >>> np.array_equal(PolybiusCipher().letter_to_numbers('u'), [4,5]) |
| 32 | True |
| 33 | """ |
| 34 | index1, index2 = np.where(letter == self.SQUARE) |
| 35 | indexes = np.concatenate([index1 + 1, index2 + 1]) |
| 36 | return indexes |
| 37 | |
| 38 | def numbers_to_letter(self, index1: int, index2: int) -> str: |
| 39 | """ |