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