Skip to content

Instantly share code, notes, and snippets.

@caseyfw
Created August 31, 2018 01:28
Show Gist options
  • Save caseyfw/80b87d2a5110da1072f839a116b283c9 to your computer and use it in GitHub Desktop.
Save caseyfw/80b87d2a5110da1072f839a116b283c9 to your computer and use it in GitHub Desktop.
Conspiracy santa generator
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