Created
January 31, 2018 18:39
-
-
Save raglan-road/ef9a427edf201d4f71bbd21d00e91043 to your computer and use it in GitHub Desktop.
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
var used = []; | |
var people = { | |
tony: [], | |
dan: [], | |
adam: [], | |
jamal: [], | |
kevin: [], | |
dave: [] | |
} | |
var toassign = ['tony', 'dan', 'adam', 'jamal', 'kevin', 'dave']; | |
var max = 5; | |
for(var i = 1; i < 31; i++){ | |
var cur = Math.round(Math.random() * 30) + 1; | |
while(used.includes(cur)){ | |
cur = Math.round(Math.random() * 30) + 1; | |
} | |
console.log(`picked ${cur}`); | |
used.push(cur); | |
var assigned = toassign[Math.round(Math.random() * 5)]; | |
while(people[assigned].length == max){ | |
assigned = toassign[Math.round(Math.random() * 5)]; | |
} | |
people[assigned].push(cur); | |
console.log(`${assigned} got ${cur}`) | |
} | |
console.log(used); | |
console.log(people); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment