Skip to content

Instantly share code, notes, and snippets.

@ThomasGreiner
Created December 3, 2015 15:08
Show Gist options
  • Save ThomasGreiner/c346d62f3096bc0b1e0f to your computer and use it in GitHub Desktop.
Save ThomasGreiner/c346d62f3096bc0b1e0f to your computer and use it in GitHub Desktop.
"use strict";
function test() {
let arr = ["a", "b", "c", "d", "e", "f"];
let result = [];
while (arr.length) {
let i = Math.floor(Math.random() * (arr.length - 1));
result.push(arr.splice(i, 1)[0]);
}
return result;
}
let result = {
a: [0, 0, 0, 0, 0, 0],
b: [0, 0, 0, 0, 0, 0],
c: [0, 0, 0, 0, 0, 0],
d: [0, 0, 0, 0, 0, 0],
e: [0, 0, 0, 0, 0, 0],
f: [0, 0, 0, 0, 0, 0]
};
for (let i = 0; i < 1000000; i++) {
let items = test();
for (let rank = 0; rank < items.length; rank++) {
result[items[rank]][rank]++;
}
}
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment