1 | static bool adjective_debug; |
2 | |
3 | // put func {}'s returning a string in there |
4 | static void makeGenerators(L<Gen> l, final L<S> log) { |
5 | gen(l, func { "3" }); |
6 | gen(l, "plus1", func { parseLong(gI())+1 }); |
7 | gen(l, "delta", func { parseLong(g0())*2-parseLong(g1()) }); |
8 | gen(l, "exponential", func { sqr(parseLong(g0()))/parseLong(g1()) }); |
9 | |
10 | // short version |
11 | gen(l, "adjective magic short", func { |
12 | lineAbove(findAdjectiveComment(findAdjective())) |
13 | }); |
14 | |
15 | // long version |
16 | final bool debug = adjective_debug; |
17 | |
18 | gen(l, "adjective magic", func { |
19 | if (debug) print("last: " + last(log)); |
20 | S a = findAdjective(last(log)); |
21 | if (debug) print("a = " + a); |
22 | if (a == null) null; |
23 | int i = findAdjectiveComment(a); |
24 | if (debug) print("i = " + _get(log, i)); |
25 | ret _get(log, i-1); |
26 | }); |
27 | } |
28 | |
29 | static S findAdjective() { ret findAdjective(gI()); } |
30 | |
31 | static S findAdjective(S s) { |
32 | ret findOneOfTheWords(s, "crazy", "nice"); |
33 | } |
34 | |
35 | static int findAdjectiveComment(final S adjective) { |
36 | if (adjective == null) ret -1; |
37 | ret gSearch(func(S s) { |
38 | matchStart("that's", s) && find3(adjective, s) |
39 | }); |
40 | } |
Began life as a copy of #1003816
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003831 |
Snippet name: | Solvers for Random v7 (older version with long adjective magic) |
Eternal ID of this version: | #1003831/1 |
Text MD5: | da253b44934c56abe84bdf42e6715555 |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-28 14:06:24 |
Source code size: | 1153 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 495 / 466 |
Referenced in: | [show references] |