Skip to main content
The National Cipher Challenge

Reply To: Challenge 10B

A Tale of 2 Secrets Forums T.E.M.P.E.S.T. Challenge 10B Reply To: Challenge 10B

#114952
ILL
Participant

[Thank you for the push in the right direction and happy to say we finally got it! Can I ask you post this late enough so that you don’t have have to sensor it]

For those who are still stuck, and sadly did not solve it. You still deserve a pat on the back for getting this far, and you should take the time to look back at all the other ciphers of quite high difficulty you managed to solve.

If you wanted to know the coding approach to solving the cipher you can gaze upon my Frankenstein of Python code. Definitely not the most streamlined solution, but I knew as soon as I could begin thinking of what the plaintext would be the keywords would fall into place in the 4×6 and 6×4 grids:

cards_6x6 = [
    ["AC", "2C", "3C", "4C", "5C", "6C"],
    ["7C", "8C", "9C", "XC", "JC", "QC"],
    ["KC", "AD", "2D", "3D", "4D", "5D"],
    ["6D", "7D", "8D", "9D", "XD", "JD"],
    ["QD", "KD", "AH", "2H", "3H", "4H"],
    ["5H", "6H", "7H", "8H", "9H", "XH"],
]

cards_4x4 = [
    ["JH", "QH", "KH", "AS"],
    ["2S", "3S", "4S", "5S"],
    ["6S", "7S", "8S", "9S"],
    ["XS", "JS", "QS", "KS"],
]

letters_6x4 = [
    ["s", "h", "a", "d", "o", "w"],
    ["b", "c", "e", "f", "g", "i"],
    ["k", "l", "m", "n", "p", "q"],
    ["r", "t", "u", "v", "x", "y"],
]

letters_4x6 = [
    ["f", "u", "l", "h"],
    ["e", "a", "r", "t"],
    ["b", "c", "d", "g"],
    ["i", "k", "m", "n"],
    ["o", "p", "q", "s"],
    ["v", "w", "x", "y"],
]

def index_grid(grid):
    pos = {}
    for r, row in enumerate(grid):
        for c, val in enumerate(row):
            pos[val] = (r, c)
    return pos

pos_6x6 = index_grid(cards_6x6)
pos_4x4 = index_grid(cards_4x4)
pos_4x6 = index_grid(letters_4x6)
pos_6x4 = index_grid(letters_6x4)

pair_to_letters = {}

for c1 in pos_6x6:
    r1, col1 = pos_6x6[c1]

    for c2 in pos_4x4:
        r2, col2 = pos_4x4[c2]

        l1 = letters_6x4[r2][col1]

        l2 = letters_4x6[r1][col2]

        pair_to_letters[(c1, c2)] = f"{l1} {l2}"

def decode_full_text(text):
    output = []
    cards = text.split()
    if len(cards) % 2 != 0:
        raise ValueError("Ciphertext should have an even number of cards")
    
    for i in range(0, len(cards), 2):
        c1, c2 = cards[i], cards[i+1]
        output.append(pair_to_letters[(c1, c2)])
    
    return " ".join(output)

ciphertext = (
    "..."
)

print(decode_full_text(ciphertext))
Report a problem