table freshness

JavaScript

var rolls=10000; //number of rolls on the table. Change to any number you want and the freshness shouldn't significantly change
var entries = rolls * 2; //number of table items
var collection = new Array(entries); //list of numbers we've rolled
var freshcount=0; //counter for fresh rolls

for(var n=0;n<rolls;n++){
        //generate random number between 0 and entries-1
        var myroll=Math.floor(Math.random()*entries);

        //increase the freshness count only if we've never seen this one
        if(typeof(collection[myroll])=="undefined") {
                collection[myroll]=1;
                freshcount++;
        }
}

console.log("freshness is "+(freshcount/rolls)*100+"%");