Created
August 23, 2012 21:02
-
-
Save benhowes/3441697 to your computer and use it in GitHub Desktop.
Using array objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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