Created
July 6, 2015 21:03
-
-
Save mientjan/ee557d5c727780412c07 to your computer and use it in GitHub Desktop.
Code generation
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 codes = []; | |
var charsNumber = '437'.split(''); | |
var charsString = 'CKX'.split(''); | |
var getCharRndString = function(){ | |
return charsString[ Math.floor(Math.random()* charsString.length) ]; | |
} | |
var getCharRndNumber = function(){ | |
return charsNumber[ Math.floor(Math.random()*charsNumber.length) ]; | |
} | |
for(var i = 0; i < 10000; i++){ | |
var code = []; | |
var charStringCount = 0; | |
while(code.length < 8){ | |
if(Math.random() < .4 && charStringCount < 2){ | |
charStringCount++; | |
code.push(getCharRndString()); | |
} else { | |
code.push(getCharRndNumber()); | |
} | |
} | |
var codeString = code.join(''); | |
if(codes.indexOf(codeString)==-1){ | |
codes.push(codeString); | |
} | |
} | |
console.log(codes.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment