Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created February 27, 2015 14:26
Show Gist options
  • Save lovasoa/22a9300179a3b077ecf3 to your computer and use it in GitHub Desktop.
Save lovasoa/22a9300179a3b077ecf3 to your computer and use it in GitHub Desktop.
ARSYS
var MAX = 3;
var a=0, b=0, n=0, p=0;
var ncorr = 0, pred=0;
var histpred = {};
var hist = [false,false,false,false];
for (var i=0; i<24; i++) {
a = (a+1)%2;
b = (b+1)%3;
var act = a<b;
var id = JSON.stringify(hist);
pred = histpred[id] || false;
ncorr += act == pred;
histpred[id] = act;
hist.push(act);
hist.shift();
}
console.log(ncorr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment