1 | !752 |
2 | |
3 | !include #1004584 // GenOpt 3 |
4 | |
5 | p { |
6 | S input = loadSnippet("#1004584"); |
7 | L<S> lines = toLines(input); |
8 | int[] indents = new int[l(lines)]; |
9 | for i over indents: |
10 | indents[i] = getIndent(lines.get(i)); |
11 | } |
12 | |
13 | sclass MyGenOpt extends GenOpt<Data> { |
14 | void fillSandbox(Sandbox s, Data d) { |
15 | d.grid = new Grid(d.numbers); |
16 | final Grid g = d.grid; |
17 | |
18 | s.setOuter("lastLine", new ZerogArgFunction() { |
19 | public LuaValue call(LuaValue arg) { |
20 | ret Lua.value(g.get(arg.toint())); |
21 | } |
22 | }); |
23 | |
24 | s.setOuter("thisLine", new TwoArgFunction() { |
25 | public LuaValue call(LuaValue a, LuaValue b) { |
26 | g.swap(a.toint(), b.toint()); |
27 | ret Lua.NIL; |
28 | } |
29 | }); |
30 | } |
31 | |
32 | double getScore(Sandbox s, Data data) { |
33 | int[] sorted = sortedArray(data.numbers); |
34 | int errors = 0; |
35 | for (int i = 0; i < numbers; i++) |
36 | if (data.grid.get(i) != sorted[i]) |
37 | ++errors; |
38 | ret 100-errors; |
39 | } |
40 | |
41 | Data makeData() { |
42 | int[] data = new int[numbers]; |
43 | for (int i = 0; i < numbers; i++) |
44 | data[i] = random(100); |
45 | ret new Data(data); |
46 | } |
47 | |
48 | void updatePool(L<Make> pool) { |
49 | pool.clear(); |
50 | pool.add(new Bubblesort); |
51 | } |
52 | } |
53 | |
54 | p { |
55 | new MyGenOpt go; |
56 | go.steps = numbers*numbers*10; // execution steps limit |
57 | go.go(); |
58 | } |
59 | |
60 | |
61 | //// CONTESTANTS //// |
62 | |
63 | static O bubblesort_bot; |
64 | |
65 | sclass Bubblesort implements Make { |
66 | public S getLua() { |
67 | if (bubblesort_bot == null) |
68 | bubblesort_bot = hotwire(numbers == 2 ? "#1003167" : "#1003158"); |
69 | ret (S) call(bubblesort_bot, "makeLua"); |
70 | } |
71 | } |
Began life as a copy of #1004585
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: | #1004586 |
Snippet name: | Lua Indent Guesser Experiment (dev.) |
Eternal ID of this version: | #1004586/1 |
Text MD5: | f7c71a5c03b208de4f43618751085444 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-23 15:26:09 |
Source code size: | 1599 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 537 / 531 |
Referenced in: | [show references] |