Last active
March 25, 2019 09:52
-
-
Save dleshem/98bfb50803a332b5150cd17bfda6a0e9 to your computer and use it in GitHub Desktop.
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
const past = new Map(); | |
let last = 'LRLRL'; | |
for (let i = 0; i < 1000; ++i) { | |
const stats = past.get(last) || {L: 0, R: 0}; | |
const choice = (stats.L >= stats.R) ? 'R' : 'L'; | |
console.log(choice); | |
++stats[choice]; | |
past.set(last, stats); | |
last = last.substr(-4, 4) + choice; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment