JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://pastebin.com/raw.php?i=vpBpXyd6"></script>
CSS
th, td {
height:20px;
width:20px;
zoom:40%;
}
td {
font-size:1px;
}
table {
border: 1px dotted red;
}
JavaScript
function shuffle() {
//your code goes here
}
$(function() {
test();
});
var deck, deckSize, l, log2, plot, rand, results, swap, test, testCount;
deckSize = 52;
deck = (function() {
results = [];
for (var l = 0; 0 <= deckSize ? l < deckSize : l > deckSize; 0 <= deckSize ? l++ : l--){ results.push(l); }
return results;
}).apply(this);
rand = function(min, max) {
if (min == null) {
min = 0;
}
if (max == null) {
max = deckSize;
}
return Math.floor(Math.random() * (max - min)) + min;
};
swap = function(a, b) {
var ref;
if (a !== b) {
return ref = [deck[b], deck[a]], deck[a] = ref[0], deck[b] = ref[1], ref;
}
};
testCount = 10000;
log2 = function(x) {
return Math.log(x) / Math.LN2;
};
test = function(document) {
if (document == null) {
document = document;
}
return plot((function() {
var i, m, n, o, ref, ref1, results1, results2;
results1 = [];
for (m = 1, ref = testCount; 1 <= ref ? m <= ref : m >= ref; 1 <= ref ? m++ : m--) {
deck = (function() {
results2 = [];
for (var n = 0; 0 <= deckSize ? n < deckSize : n > deckSize; 0 <= deckSize ? n++ : n--){ results2.push(n); }
return results2;
}).apply(this);
shuffle();
for (i = o = 0, ref1 = deckSize; 0 <= ref1 ? o < ref1 : o > ref1; i = 0 <= ref1 ? ++o : --o) {
if (deck.indexOf(i) === -1) {
throw i + " is not in the deck";
}
if (deck.length !== deckSize) {
throw "deck length is " + deck.length + "; should be " + deckSize;
}
}
results1.push(deck);
}
return results1;
})());
};
plot = function(runs) {
var card, i, index, j, k, len, len1, m, maxValue, n, o, p, proportion, ref, ref1, results1, row, run, table, td, th, v, values;
values = (function() {
var m, ref, results1;
results1 = [];
for (m = 0, ref = deckSize; 0 <= ref ? m < ref : m > ref; 0 <= ref ? m++ : m--) {
results1.push((function() {
var n,...