2 ms·
You don't need a transcendental number; simple counting has perfect entropy: 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000... (Grant
by thaumasiotes 10y ago
You don't need a transcendental number; simple counting has perfect entropy:
0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000...
(Granted, that is a transcendental number -- the Champernowne constant for base 2 -- but there's no real need to think of it that way.)
- steego 10y agoI wrote a program that counts but only appends the sequence if the binary sequence isn't already there.
- thaumasiotes 10y ago> but only appends the sequence if the binary sequence isn't already there Why?
- Bognar 10y agoThis sequence seems to settle right around 50%: var simulateKeyPress = function(character) { var evt = document.createEvent("KeyboardEvent"); evt.initKeyEvent ("keypress", true, true, window, 0, 0, 0, 0, 0, character.charCodeAt(0)) document.body.dispatchEvent(evt); }; var num = 0; var loop = function() { console.log(num); var binary = num.toString(2); num++; for(var i = 0, len = binary.length; i < len; i++) { simulateKeyPress(binary[i] == '0' ? 'd' : 'f'); } }; setInterval(loop, 100);
- thaumasiotes 10y agoIt might sound weird, but I actually found that more readable as three lines of code. :/