Bombe: review, tests, validation

This commit is contained in:
s2224834 2019-01-08 18:25:42 +00:00
parent b6eb4e84e4
commit ad6e30f3d4
5 changed files with 173 additions and 31 deletions

View file

@ -103,8 +103,8 @@ export class Rotor {
if (!/^[A-Z]$/.test(initialPosition)) {
throw new OperationError("Rotor initial position must be exactly one uppercase letter");
}
this.map = new Array(26).fill();
this.revMap = new Array(26).fill();
this.map = new Array(26);
this.revMap = new Array(26);
const uniq = {};
for (let i=0; i<LETTERS.length; i++) {
const a = a2i(LETTERS[i]);
@ -235,7 +235,7 @@ export class Reflector extends PairMapBase {
if (s !== 26) {
throw new OperationError("Reflector must have exactly 13 pairs covering every letter");
}
const optMap = new Array(26).fill();
const optMap = new Array(26);
for (const x of Object.keys(this.map)) {
optMap[x] = this.map[x];
}