add reducing guesser simulator
This commit is contained in:
parent
9a14144439
commit
374c42802e
1 changed files with 20 additions and 3 deletions
|
@ -157,7 +157,24 @@ Deno.test("test_smallest_cuts", () => {
|
||||||
assertEquals(best, "ba");
|
assertEquals(best, "ba");
|
||||||
});
|
});
|
||||||
|
|
||||||
function matches_constraints(cand: string, constraints: [string, Info][]) {
|
function matches_constraints(candidate: string, constraints: [string, Info][]) {
|
||||||
// TODO
|
const letters = [...candidate];
|
||||||
return false;
|
|
||||||
|
for (const [index, [letter, info]] of enumerate(constraints)) {
|
||||||
|
if (info.kind !== "there") continue;
|
||||||
|
if (letters[index] !== letter) return false;
|
||||||
|
letters[index] = ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [index, [letter, info]] of enumerate(constraints)) {
|
||||||
|
if (info.kind === "there") continue;
|
||||||
|
if (info.kind === "abscent") if (letters.includes(letter)) return false;
|
||||||
|
// is somewhere
|
||||||
|
if (letters[index] === letter) return false;
|
||||||
|
if (!letters.includes(letter)) return false;
|
||||||
|
const index_ = letters.findIndex((i) => i === letter);
|
||||||
|
letters[index_] = ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue