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

24
LINES

< > BotCompany Repo | #1035201 // CheckLSFRTriplet

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (8059L/45K).

srecord noeq CheckLSFRTriplet(int bits, int[] triplet) {
  settable bool verbose;
  
  TripletLSFR lsfr;
  int steps;
  
  bool get() {
    lsfr = new TripletLSFR(bits, triplet[0], triplet[1], triplet[2]);
    int cycleLength = (1 << bits)-1;
    assertEquals(cycleLength, lsfr.cycleLength());
    
    new BitSet bs;
    for (steps = 0; steps < cycleLength; steps++) {
      int i = lsfr.next();
      if (verbose) print(+i);
      if (i < 1 || i > cycleLength) false;
      if (bs.get(i))
        false;
      bs.set(i);
    }
    
    true;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035201
Snippet name: CheckLSFRTriplet
Eternal ID of this version: #1035201/8
Text MD5: 11aefffc14631989eb85a9fd6fc8a989
Transpilation MD5: 576a25dace4e7d229a7577697ef8b2b2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-15 03:11:48
Source code size: 572 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 179 / 257
Version history: 7 change(s)
Referenced in: [show references]