move towards desired output
This commit is contained in:
parent
0790e1e6f4
commit
f6f469cef7
43
genids.js
43
genids.js
|
@ -5,26 +5,45 @@ var fs = require('fs')
|
||||||
, shuffle = require('knuth-shuffle').knuthShuffle
|
, shuffle = require('knuth-shuffle').knuthShuffle
|
||||||
, animalsFile = path.join(__dirname, 'animals.txt')
|
, animalsFile = path.join(__dirname, 'animals.txt')
|
||||||
, adjectivesFile = path.join(__dirname, 'adjectives.txt')
|
, adjectivesFile = path.join(__dirname, 'adjectives.txt')
|
||||||
, animals
|
, animals = []
|
||||||
, adjectives
|
, animalsMaster
|
||||||
|
, adjectives = []
|
||||||
|
, adjectivesMaster
|
||||||
, numbers = []
|
, numbers = []
|
||||||
, i = 0
|
, i = 0
|
||||||
|
, k = 0
|
||||||
, id
|
, id
|
||||||
;
|
;
|
||||||
|
|
||||||
animals = fs.readFileSync(animalsFile, 'utf8').split('\n');
|
animalsMaster = fs.readFileSync(animalsFile, 'utf8').split('\n');
|
||||||
adjectives = fs.readFileSync(adjectivesFile, 'utf8').split('\n');
|
adjectivesMaster = fs.readFileSync(adjectivesFile, 'utf8').split('\n');
|
||||||
while (i <= 101) {
|
|
||||||
numbers.push(i);
|
function genNumbers() {
|
||||||
i += 1;
|
numbers.push(0);
|
||||||
|
i = 2;
|
||||||
|
// 1 is not plural, so we skip it
|
||||||
|
while (i <= 100) {
|
||||||
|
numbers.push(i);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shuffle(numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 1000; i += 1) {
|
for (k = 0; k < 100; k += 1) {
|
||||||
i += 1;
|
if (!adjectives.length) {
|
||||||
|
adjectives = shuffle(adjectivesMaster.slice(0));
|
||||||
|
}
|
||||||
|
if (!animals.length) {
|
||||||
|
animals = shuffle(animalsMaster.slice(0));
|
||||||
|
}
|
||||||
|
if (!numbers.length) {
|
||||||
|
numbers = genNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
id = shuffle(adjectives)[0]
|
id = adjectives.pop()
|
||||||
+ '-' + shuffle(animals)[0]
|
+ '-' + animals.pop()
|
||||||
+ '-' + shuffle(numbers)[0]
|
+ '-' + numbers.pop()
|
||||||
;
|
;
|
||||||
|
|
||||||
console.log(id);
|
console.log(id);
|
||||||
|
|
Loading…
Reference in New Issue