main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const table = {
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 reversed = Object.values(table).reduce((acc, letter, index) => {acc[letter] = Object.keys(table)[index]; return acc;}, {})


const encode = text => text.toUpperCase().split('').map(char => table[char]).join('')

const decode = text => text.split('').map(char => reversed[char]).join('')

//console.log(decode('∫Ÿ<&£ª∫ ~<&î'))
console.log(encode("Shamir's game"))
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie