4 ms·
What are you using to generate the strings?
by RuggeroAltair 15y ago
What are you using to generate the strings?
- debacle 15y agoJavaScript.
- RuggeroAltair 15y agoI guess JavaScript has a pretty bad random number generator. The tool I linked does a good job at showing that. If you post a string here I'd be curious to look at it. In the past computers where using generators that under some particular tests turned out to be performing really really bad.
- debacle 15y agoThe code I was using is here: var random = []; var i = 10; while(i) { random.push(Math.floor(Math.random() * 2)); i--; } console.log(random.join()); I was just manually doing the insertions. It lost five out of five times, though the last time only by a very small amount.
- RuggeroAltair 15y agoAt a quick look in one case this function was generating more 1s than 0s. It seems also that it generated very often a 1 after a 0 (more than twice as many times than it generates another 0). Now I got curious, I'll do more tests and look at the documentation for Math.random Certainly I won't ever use it for any important feature of a website! EDIT: it seems that with large enough numbers it's not too bad, so I might be able to say more after reading the documentation. At any rate using the strings generated with the khanacademy link I was able to win few times in a row.