// ===================== // Forward translation: letters → symbols // + per-word palindrome // + multiline palindrome (center = last input line) // ===================== function forward(input) { const map = { // Cyrillic 'Й':'ꖌ','Ц':'⧮','У':'✧','К':'✻','Е':'🜊','Н':'⊞', 'А':'⛋','Б':'⧲','В':'𖢌','Г':'🮻','Д':'🟗','Ё':'🜋', 'Ж':'𐋅','З':'᪥','І':'∣','И':'∣','Л':'◇','М':'✸', 'О':'Ⓞ','П':'☐','Р':'🝊','С':'⯏','Т':'✢','Ў':'✦', 'Ф':'𖥠','Х':'ꕤ','Ч':'⑄','Ш':'◫','Щ':'⎅','Ъ':'❂', 'Ы':'∣❁∣','Ь':'❁','Э':'𖡛','Ю':'𖥤','Я':'ⵙ', // Latin 'A':'⛋','B':'𖢌','C':'⯏','D':'🟗','E':'🜊','F':'𖥠', 'G':'Ⱉ','H':'⊞','I':'ⵙ','J':'𐫰','K':'✻','L':'◇', 'M':'✸','N':'𑽇','O':'Ⓞ','P':'🝊','Q':'¤','R':'⦻', 'S':'𖧷','T':'✢','U':'𐫱','V':'🟅','W':'🟏','X':'ꕤ', 'Y':'✧','Z':'🝱', // Digits '0':'ⵔ','1':'꞉','2':'⋮','3':'⁘','4':'⸭', '5':'⠿','6':'፨','7':'❋','8':'𐧾','9':'ⵔ' }; const lines = input.split('\n'); const convertedLines = lines.map(line => { const words = line.split(/(\s+)/); return words.map(word => { if (/^\s+$/.test(word)) return word; const symbols = Array.from(word.toUpperCase()).map(c => map[c] || c); if (!symbols.length) return ''; const MOM = symbols[0]; const XMMX = symbols.slice(1); return XMMX.slice().reverse().join('') + MOM + XMMX.join(''); }).join(''); }); // Multiline palindrome: mirror around LAST input line const reversed = convertedLines.slice().reverse(); return [...reversed, ...convertedLines.slice(1)].join('\n'); } // ===================== // Backward translation: symbols → letters // (undo per-word palindrome + multiline palindrome) // ===================== function backward(input) { const reverseMap = { // Cyrillic 'ꖌ':'Й','⧮':'Ц','✧':'У','✻':'К','🜊':'Е','⊞':'Н', '⛋':'А','⧲':'Б','𖢌':'В','🮻':'Г','🟗':'Д','🜋':'Ё', '𐋅':'Ж','᪥':'З','∣':'І','◇':'Л','✸':'М','Ⓞ':'О', '☐':'П','🝊':'Р','⯏':'С','✢':'Т','✦':'Ў','𖥠':'Ф', 'ꕤ':'Х','⑄':'Ч','◫':'Ш','⎅':'Щ','❂':'Ъ','∣❁∣':'Ы', '❁':'Ь','𖡛':'Э','𖥤':'Ю','ⵙ':'Я', // Latin '⛋':'A','𖢌':'B','⯏':'C','🟗':'D','🜊':'E','𖥠':'F', 'Ⱉ':'G','⊞':'H','ⵙ':'I','𐫰':'J','✻':'K','◇':'L', '✸':'M','𑽇':'N','Ⓞ':'O','🝊':'P','¤':'Q','⦻':'R', '𖧷':'S','✢':'T','𐫱':'U','🟅':'V','🟏':'W','ꕤ':'X', '✧':'Y','🝱':'Z' }; const lines = input.split('\n'); // Only the center line contains the original data const centerIndex = Math.floor(lines.length / 2); const centerLine = lines[centerIndex]; const words = centerLine.split(/(\s+)/); return words.map(word => { if (/^\s+$/.test(word)) return word; let decoded = ''; let remaining = word; const keys = Object.keys(reverseMap).sort((a,b) => b.length - a.length); while (remaining.length) { let matched = false; for (const k of keys) { if (remaining.startsWith(k)) { decoded += reverseMap[k]; remaining = remaining.slice(k.length); matched = true; break; } } if (!matched) { decoded += remaining[0]; remaining = remaining.slice(1); } } const mid = Math.floor(decoded.length / 2); return (decoded[mid] + decoded.slice(mid + 1)).toUpperCase(); }).join(''); }