ROT13 is a code where every letter gets coded as the letter 13 letters from it in the alphabet.
There are two synonyms such that if you code either one of them with ROT13, then you will get the other. What are the two synonyms?
DECLARE FUNCTION isWord! (w$)
OPEN "\words\words.txt" FOR INPUT AS #1
OPEN "codesyn.txt" FOR OUTPUT AS #3
LINE INPUT #1, w$
IF w$ = LCASE$(w$) THEN
w2$ = ""
FOR i = 1 TO LEN(w$)
v = ASC(MID$(w$, i, 1)) + 13
IF v > ASC("z") THEN v = v - 26
w2$ = w2$ + CHR$(v)
IF isWord(w2$) THEN PRINT w$, w2$: PRINT #3, w$, w2$
LOOP UNTIL w$ > "m"
FUNCTION isWord (w$)
n = LEN(w$)
w1$ = SPACE$(n)
OPEN "\words\words" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
l = LOF(2) / n
low = 1: high = l
mid = INT((low + high) / 2)
GET #2, (mid - 1) * n + 1, w1$
IF w1$ = w$ THEN isWord = 1: CLOSE 2: EXIT FUNCTION
IF w1$ < w$ THEN low = mid + 1: ELSE high = mid - 1
LOOP UNTIL low > high
isWord = 0
finds the following mutually coding words:
It would seem IRK and VEX are the two sought.
But gnat and tang also have another symmetry as well, though not anything to do with this puzzle.
Posted by Charlie
on 2013-03-14 18:18:42