Bombe: Add checking machine

This commit is contained in:
s2224834 2019-01-11 13:18:25 +00:00
parent 78768e00d4
commit 21335e7d05
7 changed files with 178 additions and 66 deletions

View file

@ -182,7 +182,8 @@ class PairMapBase {
}
const a = a2i(pair[0]), b = a2i(pair[1]);
if (a === b) {
throw new OperationError(`${name}: cannot connect ${pair[0]} to itself`);
// self-stecker
return;
}
if (this.map.hasOwnProperty(a)) {
throw new OperationError(`${name} connects ${pair[0]} more than once`);