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

Function get_opponent

ciphers/porta_cipher.py:74–83  ·  view source on GitHub ↗

>>> get_opponent(generate_table('marvin')[0], 'M') 'T'

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

Source from the content-addressed store, hash-verified

72
73
74def get_opponent(table: tuple[str, str], char: str) -> str:
75 """
76 >>> get_opponent(generate_table('marvin')[0], 'M')
77 'T'
78 """
79 row, col = get_position(table, char.upper())
80 if row == 1:
81 return table[0][col]
82 else:
83 return table[1][col] if row == 0 else char
84
85
86if __name__ == "__main__":

Callers 1

encryptFunction · 0.85

Calls 1

get_positionFunction · 0.85

Tested by

no test coverage detected