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

Function get_position

ciphers/porta_cipher.py:63–71  ·  view source on GitHub ↗

>>> get_position(generate_table('marvin')[0], 'M') (0, 12)

(table: tuple[str, str], char: str)

Source from the content-addressed store, hash-verified

61
62
63def get_position(table: tuple[str, str], char: str) -> tuple[int, int]:
64 """
65 >>> get_position(generate_table('marvin')[0], 'M')
66 (0, 12)
67 """
68 # `char` is either in the 0th row or the 1st row
69 row = 0 if char in table[0] else 1
70 col = table[row].index(char)
71 return row, col
72
73
74def get_opponent(table: tuple[str, str], char: str) -> str:

Callers 1

get_opponentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected