Created
August 31, 2018 01:28
-
-
Save caseyfw/80b87d2a5110da1072f839a116b283c9 to your computer and use it in GitHub Desktop.
Conspiracy santa generator
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
const names = require("./names.json"); | |
const numberOfConspirators = 4; | |
// Randomise names - comment out for repeatable results. | |
names.sort(function() { | |
return 0.5 - Math.random(); | |
}); | |
console.log( | |
JSON.stringify( | |
names.map((mark, index) => { | |
var conspirators = []; | |
for (var i = 0; i < numberOfConspirators; i++) { | |
conspirators.push( | |
names[(index + 1 + (i / 2) * (i + 1)) % names.length] | |
); | |
} | |
return { mark, conspirators }; | |
}) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment