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

18
LINES

< > BotCompany Repo | #1004717 // class HighestShortest - collect highest score, then shortest code

JavaX fragment (include)

// also updates when equal score and shorter code
static class HighestShortest {
  S a;
  double score;
  
  bool update(S x, double s) {
    if (a == null || s > score || (s == score && l(x) < l(a))) {
      a = x;
      score = s;
      true;
    }
    false;
  }
  
  Pair<S, Double> getPair() {
    ret a == null ? null : pair(a, score);
  }
}

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: #1004717
Snippet name: class HighestShortest - collect highest score, then shortest code
Eternal ID of this version: #1004717/1
Text MD5: 72c240a21f1f7e4d252e2c77c02dc857
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-27 22:42:49
Source code size: 364 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 497 / 1100
Referenced in: [show references]