Hacker News new | ask | show | jobs
by thaumasiotes 3673 days 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.)

2 comments

This 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);
It might sound weird, but I actually found that more readable as three lines of code. :/
I wrote a program that counts but only appends the sequence if the binary sequence isn't already there.
> but only appends the sequence if the binary sequence isn't already there

Why?