move towards desired output

This commit is contained in:
AJ ONeal 2014-07-20 23:28:47 -06:00
parent 0790e1e6f4
commit f6f469cef7
1 changed files with 31 additions and 12 deletions

View File

@ -5,26 +5,45 @@ var fs = require('fs')
, shuffle = require('knuth-shuffle').knuthShuffle
, animalsFile = path.join(__dirname, 'animals.txt')
, adjectivesFile = path.join(__dirname, 'adjectives.txt')
, animals
, adjectives
, animals = []
, animalsMaster
, adjectives = []
, adjectivesMaster
, numbers = []
, i = 0
, k = 0
, id
;
animals = fs.readFileSync(animalsFile, 'utf8').split('\n');
adjectives = fs.readFileSync(adjectivesFile, 'utf8').split('\n');
while (i <= 101) {
animalsMaster = fs.readFileSync(animalsFile, 'utf8').split('\n');
adjectivesMaster = fs.readFileSync(adjectivesFile, 'utf8').split('\n');
function genNumbers() {
numbers.push(0);
i = 2;
// 1 is not plural, so we skip it
while (i <= 100) {
numbers.push(i);
i += 1;
}
for (i = 0; i < 1000; i += 1) {
i += 1;
return shuffle(numbers);
}
id = shuffle(adjectives)[0]
+ '-' + shuffle(animals)[0]
+ '-' + shuffle(numbers)[0]
for (k = 0; k < 100; k += 1) {
if (!adjectives.length) {
adjectives = shuffle(adjectivesMaster.slice(0));
}
if (!animals.length) {
animals = shuffle(animalsMaster.slice(0));
}
if (!numbers.length) {
numbers = genNumbers();
}
id = adjectives.pop()
+ '-' + animals.pop()
+ '-' + numbers.pop()
;
console.log(id);