Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-155

Playfair Prepare Pair

Problem

Apply the Playfair digraph preparation rules to two letters: convert J to I, and when the two letters are equal replace the second with X. Return the resulting two-character string.

Hint

Duplicate letters must be split before Playfair encryption.

Test cases

case 1
in: ["A","A"]
expected: "AX"
case 2
in: ["A","B"]
expected: "AB"
case 3
in: ["J","J"]
expected: "IX"
case 4
in: ["J","I"]
expected: "IX"
case 5
in: ["X","X"]
expected: "XX"
Starter codePython
def playfair_prepare_pair(a, b):
    # Your code here
    pass

5 test cases · run your code against them in the editor