1 | // These end up inside the main class |
2 | |
3 | static class LEmptyBox extends LearnerImpl { |
4 | static boolean debug; |
5 | Learner inputLearner; |
6 | char c; |
7 | |
8 | *(Learner *inputLearner) {} |
9 | |
10 | public void tryAgain() { |
11 | inputLearner.tryAgain(); |
12 | } |
13 | |
14 | public void processInOut(Object in, Object _out) { |
15 | String out = (String) _out; |
16 | L<S> l = toLines(out); |
17 | int w = l.get(1).length(), h = l.size()-1; |
18 | String input = w + "*" + h; |
19 | if (debug) |
20 | System.out.println("LEmptyBox: Feeding to input learner: " + in + " => " + input); |
21 | inputLearner.processInOut(in, input); |
22 | if (debug) |
23 | System.out.println("Input learner: " + structure(inputLearner)); |
24 | c = l.get(1).charAt(0); |
25 | if (debug) |
26 | System.out.println("LEmptyBox: c=" + c); |
27 | } |
28 | |
29 | public Object processIn(Object in) { |
30 | String input = (String) inputLearner.processIn(in); |
31 | if (debug) |
32 | System.out.println("LEmptyBox: in=" + in + ", input=" + input); |
33 | String[] split = input.split("\\*"); |
34 | int w = Integer.parseInt(split[0]), h = Integer.parseInt(split[1]); |
35 | new StringBuilder buf; |
36 | buf.append("\n"); |
37 | buf.append(main.repeat(c, w) + "\n"); |
38 | for (int y = 1; y < h-1; y++) |
39 | buf.append(c + main.repeat(' ', w-2) + c + "\n"); |
40 | buf.append(main.repeat(c, w) + "\n"); |
41 | return buf.toString(); |
42 | } |
43 | |
44 | public void toJava(Code code) { |
45 | todo(); |
46 | } |
47 | } |
Began life as a copy of #1000382
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
333 | #1000604 (pitcher) | 2015-08-18 00:07:22 | ||
332 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { // These end up inside the main class static class LEmptyBox extends LearnerImpl { static boolean debug; Learner inputLearner; char c; *(Learner *inputLearner) {} public void tryAgain() { inputLearner.tryAgain(); } public void processInOut(Object in, Object _out) { String out = (String) _out; L<S> l = toLines(out); int w = l.get(1).length(), h = l.size()-1; String input = w + "*" + h; if (debug) System.out.println("LEmptyBox: Feeding to input learner: " + in + " => " + input); inputLearner.processInOut(in, input); if (debug) System.out.println("Input learner: " + structure(inputLearner)); c = l.get(1).charAt(0); if (debug) System.out.println("LEmptyBox: c=" + c); } public Object processIn(Object in) { String input = (String) inputLearner.processIn(in); if (debug) System.out.println("LEmptyBox: in=" + in + ", input=" + input); String[] split = input.split("\\*"); int w = Integer.parseInt(split[0]), h = Integer.parseInt(split[1]); new StringBuilder buf; buf.append("\n"); buf.append(repeat(c, w) + "\n"); for (int y = 1; y < h-1; y++) buf.append(c + repeat(' ', w-2) + c + "\n"); buf.append(repeat(c, w) + "\n"); return buf.toString(); } static String repeat(char c, int n) { char[] chars = new char[n]; for (int i = 0; i < n; i++) chars[i] = c; return new String(chars); } public void toJava(Code code) { todo(); } } }} | 2015-08-18 01:46:09 | delete |
Snippet ID: | #1000387 |
Snippet name: | Empty Box learner (developing) |
Eternal ID of this version: | #1000387/1 |
Text MD5: | b887211f2e04d90a10670cf5b39ab922 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-10-17 01:21:12 |
Source code size: | 1410 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1010 / 2904 |
Referenced in: | [show references] |