// put func {}'s returning a string in there // not using _log parameter anymore static void makeGenerators(L l, L _log) { gen(l, func { "3" }); gen(l, "plus1", func { parseLong(gI())+1 }); gen(l, "delta", func { parseLong(g0())*2-parseLong(g1()) }); gen(l, "exponential", func { sqr(parseLong(g0()))/parseLong(g1()) }); gen(l, "assoc", gOneAssoc()); gen(l, "adjective magic", func { lineAbove(findAdjectiveComment(findAdjective())) }); gen(l, "complete line", func { gSearchNeqNoSystem(func(S s) { startsWithIgnoreCase(s, gI()) }) }); gen(l, "complete line -> answer", func { lineBelow( gSearchNeqNoSystemIdx(func(S s) { startsWithIgnoreCase(s, gI()) })) }); gen(l, "word search", func { gSearchNeqNoSystem(func(S s) { match(gI(), s) }) }); gen(l, "raw string search", func { gSearchNeqNoSystem(func(S s) { containsIgnoreCase(s, gI()) }) }); gen(l, "raw string search (!java)", func { gSearchNeqNoSystem(func(S s) { s.startsWith("!java") && containsIgnoreCase(s, gI()) }) }); gen(l, "yes/no from java", func { L tok = javaTok(gI()); if (contains(tok, "t")) ret "yes"; if (contains(tok, "f")) ret "no"; null; }); gen(l, "learned", func { for (L learn : gLearns()) { if (l(learn) >= 2 && match(first(learn), gI())) try answer lastNonSystemLine(learn); } null; }); gen(l, "learned (single step)", func { for (L learn : gLearns()) { for (int i = 0; i < l(learn)-1; i++) if (match(learn.get(i), gI())) ret learn.get(i+1); } null; }); gen(l, "learned (single step 2)", func { thislearn: for (L learn : gLearns()) { L log = gLog(); int j = l(gLog())-l(learn)+1; if (j < 0) null; for (int i = 0; i < l(learn)-1; i++) if (!match(learn.get(i), log.get(j+i))) break thislearn; ret last(learn); // all entries match } null; }); } static S findAdjective() { ret findAdjective(gI()); } static S findAdjective(S s) { ret findOneOfTheWords(s, "crazy", "nice"); } static int findAdjectiveComment(final S adjective) { if (adjective == null) ret -1; ret gSearchIdx(func(S s) { matchStart("that's", s) && find3(adjective, s) }); }