Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1001873 // Compute one from the others (developing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (598L/4K/15K).

1  
!752
2  
!_case
3  
4  
// an example
5  
static class E {
6  
  S in, out;
7  
}
8  
9  
static L<E> examples = group(E.class, litlist("in", "out"), litlist(
10  
  "0", "00",
11  
  "1", "11",
12  
  "5", "55",
13  
  "a", "aa",
14  
  "b", "bb"));
15  
  
16  
p {
17  
  print(structure(examples));
18  
  
19  
  for (int i = 0; i < l(examples); i++)
20  
    computeExample(i);
21  
}
22  
23  
static O solver;
24  
25  
static void computeExample(int pivot) {
26  
  if (solver == null)
27  
    solver = hotwire("#738");
28  
  
29  
  // move pivot example last so it's used as secret example internally
30  
  S[] list = new S[l(examples)*2];
31  
  int j = 0;
32  
  for (int i = 0; i < l(examples); i++)
33  
    if (i != pivot) {
34  
      list[j++] = examples.get(i).in;
35  
      list[j++] = examples.get(i).out;
36  
    }
37  
  list[j++] = examples.get(pivot).in;
38  
  list[j++] = examples.get(pivot).out;
39  
  O case = call(solver, "quickSolve", (O) list);
40  
  
41  
  if (get(case, "winner") != null)
42  
    print("Example " + (pivot+1) + " computable.");
43  
  else
44  
    print("Example " + (pivot+1) + " not computable.");
45  
}

Author comment

Began life as a copy of #1001869

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001873
Snippet name: Compute one from the others (developing)
Eternal ID of this version: #1001873/1
Text MD5: eda64ce838f6d24a6c85ba62fcb20057
Transpilation MD5: aa25dd83a1b51bb47cb492521f77ee12
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-01 02:33:13
Source code size: 1003 bytes / 45 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 721 / 798
Referenced in: [show references]