MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / letter_to_numbers

Method letter_to_numbers

ciphers/bifid.py:25–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

encodeMethod · 0.95
decodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected