MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / letter_to_numbers

Method letter_to_numbers

ciphers/polybius.py:24–36  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 1

encodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected