1 | // put func {}'s returning a string in there
|
2 | // not using _log parameter anymore |
3 | static void makeGenerators(L<Gen> l, L<S> _log) {
|
4 | gen(l, func { "3" });
|
5 | gen(l, "plus1", func { parseLong(gI())+1 });
|
6 | gen(l, "delta", func { parseLong(g0())*2-parseLong(g1()) });
|
7 | gen(l, "exponential", func { sqr(parseLong(g0()))/parseLong(g1()) });
|
8 | gen(l, "assoc", gOneAssoc()); |
9 | gen(l, "adjective magic", func {
|
10 | lineAbove(findAdjectiveComment(findAdjective())) |
11 | }); |
12 | gen(l, "complete line", func {
|
13 | gSearchNeqNoSystem(func(S s) { startsWithIgnoreCase(s, gI()) })
|
14 | }); |
15 | gen(l, "complete line -> answer", func {
|
16 | lineBelow( |
17 | gSearchNeqNoSystemIdx(func(S s) { startsWithIgnoreCase(s, gI()) }))
|
18 | }); |
19 | gen(l, "word search", func {
|
20 | gSearchNeqNoSystem(func(S s) { match(gI(), s) })
|
21 | }); |
22 | gen(l, "raw string search", func {
|
23 | gSearchNeqNoSystem(func(S s) { containsIgnoreCase(s, gI()) })
|
24 | }); |
25 | gen(l, "raw string search (!java)", func {
|
26 | gSearchNeqNoSystem(func(S s) { s.startsWith("!java") && containsIgnoreCase(s, gI()) })
|
27 | }); |
28 | gen(l, "yes/no from java", func {
|
29 | L<S> tok = javaTok(gI()); |
30 | if (contains(tok, "t")) ret "yes"; |
31 | if (contains(tok, "f")) ret "no"; |
32 | null; |
33 | }); |
34 | gen(l, "learned", func {
|
35 | for (L<S> learn : gLearns()) {
|
36 | if (l(learn) >= 2 && match(first(learn), gI())) |
37 | try answer lastNonSystemLine(learn); |
38 | } |
39 | null; |
40 | }); |
41 | gen(l, "learned (single step)", func {
|
42 | for (L<S> learn : gLearns()) {
|
43 | for (int i = 0; i < l(learn)-1; i++) |
44 | if (match(learn.get(i), gI())) |
45 | ret learn.get(i+1); |
46 | } |
47 | null; |
48 | }); |
49 | gen(l, "learned (single step 2)", func {
|
50 | thislearn: for (L<S> learn : gLearns()) {
|
51 | L<S> log = gLog(); |
52 | int j = l(gLog())-l(learn)+1; |
53 | if (j < 0) null; |
54 | for (int i = 0; i < l(learn)-1; i++) |
55 | if (!match(learn.get(i), log.get(j+i))) |
56 | break thislearn; |
57 | ret last(learn); // all entries match |
58 | } |
59 | null; |
60 | }); |
61 | } |
62 | |
63 | static S findAdjective() { ret findAdjective(gI()); }
|
64 | |
65 | static S findAdjective(S s) {
|
66 | ret findOneOfTheWords(s, "crazy", "nice"); |
67 | } |
68 | |
69 | static int findAdjectiveComment(final S adjective) {
|
70 | if (adjective == null) ret -1; |
71 | ret gSearchIdx(func(S s) {
|
72 | matchStart("that's", s) && find3(adjective, s)
|
73 | }); |
74 | } |
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: | 847 / 1483 |
| Referenced in: | [show references] |