ROT13 is a code where every letter gets coded as the letter 13 letters from it in the alphabet.
Letter:ABCDEFGHIJKLMNOPQRSTUVWXYZ
ROT13:NOPQRSTUVWXYZABCDEFGHIJKLM
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
DO
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)
NEXT
IF isWord(w2$) THEN PRINT w$, w2$: PRINT #3, w$, w2$
END IF
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
DO
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
CLOSE 2
END FUNCTION
finds the following mutually coding words:
a n
ab no
abba noon
abjurer nowhere
abo nob
ah nu
aha nun
an na
ana nan
anil navy
anna naan
ant nag
ar ne
avo nib
ba on
balk onyx
bar one
barf ones
be or
been orra
beg ort
ben ora
bin ova
bub oho
cel pry
chat pung
chef purs
craal penny
crag pent
creel perry
ebbs roof
eng rat
envy rail
er re
erg ret
erne rear
err ree
errs reef
ers ref
flap sync
frag sent
frere serer
fry sel
fun sha
fur she
gel try
ghat tung
gnat tang
green terra
gul thy
ha un
hern urea
irk vex
jun wha
jura when
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 |