Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

58
LINES

## < > BotCompanyRepo | #1001890 - Is In Bot - can solve logic puzzles

### JavaX source code [tags: use-pretranspiled] - run with: x30.jar

```// If the pope is in the house and the house is in the world, then is the pope in the world?

!752

p {
makeBot("Is In Bot.");
}

new MultiMap<S, S> isIn;

new Matches m;
if (
flexmatch("if the * is in the *, and the * is in the *, then is the * in the *?", s, m) ||
flexmatch("if the * is in the *, and the * is in the *, is the * in the *?", s, m)) {
S a = m.unq(0), b = m.unq(1), c = m.unq(2), d = m.unq(3), e = m.unq(4), f = m.unq(5);
isIn.put(a, b);
isIn.put(c, d);
}

if (
flexmatch("if the * is in the *, and the * is in the *, and the * is in the *, then is the * in the *?", s, m) ||
flexmatch("if the * is in the *, and the * is in the *, and the * is in the *, is the * in the *?", s, m)) {
S a = m.unq(0), b = m.unq(1), c = m.unq(2), d = m.unq(3), e = m.unq(4), f = m.unq(5), g = m.unq(6), h = m.unq(7);
isIn.put(a, b);
isIn.put(c, d);
isIn.put(e, f);
}
ret null;
}

static S makeAnswer(MultiMap<S, S> isIn, S e, S f) {
boolean result = hasTransitive(isIn, e, f);
if (result)
ret format("Yes, the * is in the *.", e, f);
else
ret format("No, the * is not in the *.", e, f);
}

static boolean flexmatch(S pat, S s, Matches m) {
pat = simplify1(pat); s = simplify1(s);
if (match(pat, s, m)) ret true;
pat = simplify2(pat); s = simplify2(s);
ret match(pat, s, m);
}

// simplifications that seem safe
static S simplify1(S s) {
s = dropWords(s, "the", "an", "my", "your", "his", "her", "our", "their");
ret replaceWords(s, "are", "is", "on", "in", "am", "is");
}

// simplifications that might fail (because a is a popular noun for this bot, like in "if a is in b and...2)
static S simplify2(S s) {
ret dropWords(s, "a");
}```

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz