Created
October 1, 2016 22:12
-
-
Save coffeetocode/cabc8bb713dd734dc9ce3f5f4f9c0564 to your computer and use it in GitHub Desktop.
Code for part of http://coffeetocode.net/2016/10/sorting-out-a-nerdsnipe/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var results = {"Erin Ptacek": {0:0, 1:0, 2:0}, | |
"Thomas Ptacek": {0:0, 1:0, 2:0}, | |
"Jeremy Rauch": {0:0, 1:0, 2:0}, | |
}; | |
for(var i = 0; i < 1000000; i++) { | |
var arr = ["Erin Ptacek", "Thomas Ptacek", "Jeremy Rauch"].sort(function(x, y) { return 1 - Math.ceil(Math.random() * 100) % 3; }); | |
for(var name in results) { | |
results[name][arr.indexOf(name)]++; | |
} | |
if(i % 1000 == 0) { | |
console.log(i); | |
} | |
} | |
for(var name in results) { | |
console.log(name); | |
console.log(results[name]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment