Created
November 13, 2012 12:49
-
-
Save jonelf/4065600 to your computer and use it in GitHub Desktop.
Use Fisher-Yates instead
This file contains hidden or 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 = []; | |
for (var i = 0; i < 60000; i++) { | |
var arr = ['A', 'B', 'C']; | |
arr.sort( function() { return 0.5 - Math.random() } ); | |
results.push(arr); | |
}; | |
var dict = {}; | |
for (var i = results.length - 1; i >= 0; i--) { | |
var prop = results[i].join(''); | |
if (dict.hasOwnProperty(prop)) | |
dict[prop]++; | |
else | |
dict[prop]=1; | |
} | |
for (var key in dict) { | |
if (dict.hasOwnProperty(key)) { | |
console.log(key+":"+dict[key]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example result:
ABC:14873
BCA:7451
CAB:7457
CBA:7515
BAC:15119
ACB:7585