Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Final with comments solution in Creative category for [old] Cipher Map by vincent.tscherter
"use strict";
function recallPassword(a, b) {
return a = a.join(''), b = b.join(''), // flatten the grille (a) and the password (b)
[1, 2, 3, 4].reduce((c, d) => ( // we nead for passes ..
c += b.replace(RegExp(a.replace(/X/g, "(.)")), "$1$2$3$4"),
// create a regexp from the grille X becomes (.), so letters
// from the password get easily extracted by n-th ref to group
a = a.split("").map( (b, c) => a[parseInt("C840D951EA62FB73"[c], 16)]).join(""),
// rotate the grill using hex reference, this was for sure a brilliant idea ;)
c), "")
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(recallPassword(['X...',
'..X.',
'X..X',
'....'],
['itdf',
'gdce',
'aton',
'qrdi']), 'icantforgetiddqd', "First Example");
assert.equal(recallPassword(['....',
'X..X',
'.X..',
'...X'],
['xhwc',
'rsqx',
'xqzz',
'fyzr']), 'rxqrwsfzxqxzhczy', "Second Example");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Dec. 8, 2016
Comments: