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

44
LINES

< > BotCompany Repo | #1003812 // solveExamples

JavaX fragment (include)

1  
!759
2  
3  
// user must include a Thinker, e.g. #1003797
4  
// and, of course, implement makeGenerators
5  
6  
static void solveExamples(L<S> examples) {
7  
  new Thinker thinker;
8  
9  
  bool unsolved = false, partiallySolved = false, fullySolved = false;
10  
  
11  
  for (int i = 0; i < l(examples); i++) {
12  
    setConsoleTitle("[" + (i+1) + "/" + l(examples) + "] Solving..." + " - " + getProgramTitle());
13  
    S example = examples.get(i);
14  
    print("Example " + (i+1));
15  
    L<S> log = toLinesFullTrim(example);
16  
    BitSet interestingLines = detectInterestingLines(log);
17  
    int maxScore = interestingLines.cardinality();
18  
    MultiSet<S> scores = thinker.scores(log, interestingLines);
19  
    S top = scores.getMostPopularEntry();
20  
    int score = scores.get(top);
21  
    S status = null;
22  
    if (score >= maxScore) {
23  
      status = "Example fully solved by " + quote(top) + " (" + score + "/" + maxScore + ")!";
24  
      fullySolved = true;
25  
    } else if (score > 0) {
26  
      status = "Example partially solved by " + quote(top) + " (" + score + "/" + maxScore + ")";
27  
      partiallySolved = true;
28  
    } else {
29  
      status = "Example not solved";
30  
      unsolved = true;
31  
    }
32  
    print(status);
33  
  }
34  
  
35  
  int n = l(examples);
36  
  S status = fullySolved && !partiallySolved && !unsolved
37  
    ? n + "/" + n + " Solved"
38  
    : partiallySolved ? n + " Partially solved"
39  
    : n + "/" + n + " Unsolved";
40  
41  
  print();
42  
  print(status);
43  
  setConsoleTitle(status + " - " + getProgramTitle());
44  
}

Author comment

Began life as a copy of #1003803

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003812
Snippet name: solveExamples
Eternal ID of this version: #1003812/1
Text MD5: becfe3ecddea45cc02e9c7f5eb5845a1
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 02:37:29
Source code size: 1487 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 504 / 487
Referenced in: [show references]