// put func {}'s returning a string in there // not using _log parameter anymore static void makeGenerators(L<Gen> l, L<S> _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<S> tok = javaTok(gI()); if (contains(tok, "t")) ret "yes"; if (contains(tok, "f")) ret "no"; null; }); gen(l, "learned", func { for (L<S> learn : gLearns()) { if (l(learn) >= 2 && match(first(learn), gI())) try answer lastNonSystemLine(learn); } null; }); gen(l, "learned (single step)", func { for (L<S> 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<S> learn : gLearns()) { L<S> 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) }); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003816 |
Snippet name: | Generators for Random v7 |
Eternal ID of this version: | #1003816/1 |
Text MD5: | 4d373c8a755274ed9b4da41f32ff944f |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-03 18:23:36 |
Source code size: | 2342 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 635 / 1255 |
Referenced in: | #1003803 - Test Random v7 Solvers On Standard Examples #1003815 - "Random" v7 #1003817 - Debug Random v7 (adjective magic) #1003831 - Solvers for Random v7 (older version with long adjective magic) #1004022 - Generators for Random v8 |