Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Cipher Map solution in Uncategorized category for Cipher Map by Elena_Korljukova
import assert from "assert";
function recallPassword(grille: string[], b: string[]): string {
let a = [[], [], [], []];
for (let i = 0; i < 4; i++) {
for(let j = 0; j < 4; j++) {
if (grille[i][j] == 'X') {
a[0].push([i,j]);
a[1].push([j, 3 - i]);
a[2].push([3 - i, 3 - j]);
a[3].push([3 - j, i]);
}
}
}
a = a[0].concat(a[1].sort()).concat(a[2].sort()).concat(a[3].sort());
let x = '';
for (let i of a) x += b[i[0]][i[1]];
return x;
}
console.log('Example:');
console.log(recallPassword(['X...', '..X.', 'X..X', '....'],
['itdf', 'gdce', 'aton', 'qrdi']));
// These "asserts" are used for self-checking
assert.equal(recallPassword(['X...', '..X.', 'X..X', '....'],
['itdf', 'gdce', 'aton', 'qrdi']), 'icantforgetiddqd');
assert.equal(recallPassword(['....', 'X..X', '.X..', '...X'],
['xhwc', 'rsqx', 'xqzz', 'fyzr']), 'rxqrwsfzxqxzhczy');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
July 6, 2020