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).

!752
!_case

// an example
static class E {
  S in, out;
}

static L<E> examples = group(E.class, litlist("in", "out"), litlist(
  "0", "00",
  "1", "11",
  "5", "55",
  "a", "aa",
  "b", "bb"));
  
p {
  print(structure(examples));
  
  for (int i = 0; i < l(examples); i++)
    computeExample(i);
}

static O solver;

static void computeExample(int pivot) {
  if (solver == null)
    solver = hotwire("#738");
  
  // move pivot example last so it's used as secret example internally
  S[] list = new S[l(examples)*2];
  int j = 0;
  for (int i = 0; i < l(examples); i++)
    if (i != pivot) {
      list[j++] = examples.get(i).in;
      list[j++] = examples.get(i).out;
    }
  list[j++] = examples.get(pivot).in;
  list[j++] = examples.get(pivot).out;
  O case = call(solver, "quickSolve", (O) list);
  
  if (get(case, "winner") != null)
    print("Example " + (pivot+1) + " computable.");
  else
    print("Example " + (pivot+1) + " not computable.");
}

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: 720 / 797
Referenced in: [show references]