Skip to content

Instantly share code, notes, and snippets.

@benhowes
Created August 23, 2012 21:02
Show Gist options
  • Save benhowes/3441697 to your computer and use it in GitHub Desktop.
Save benhowes/3441697 to your computer and use it in GitHub Desktop.
Using array objects
initBuffer = (len)->
buffer = new ArrayBuffer(len)
stack = new Uint8Array(buffer);
for i in [0..len] by 2
stack[i] = 0;
stack[i+1] = 1;
stack
regress = ()->
stack = initBuffer(4)
overwrite = 0
(result)->
stack[(overwrite++%4)] = 0
sum = 0
for i in stack
sum += i
if sum is 2 then Math.RandomInteger(0,1)
else if sum > 2 then 0 #based on resent history guess differently
else 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment