Skip to content

Instantly share code, notes, and snippets.

@eXcuvator
Created September 6, 2015 09:31
Show Gist options
  • Save eXcuvator/2dbf83ffeb73c909b99d to your computer and use it in GitHub Desktop.
Save eXcuvator/2dbf83ffeb73c909b99d to your computer and use it in GitHub Desktop.
Creates Room Draws. To do: Why don't floors matter?
import numpy as np
import numpy.random as random
## param
maxPerTeam = np.float64(4)
names = {0:{0:{0:'Richard', 1:'Saman'}, 1:{0:'Jonna', 1:'Magnus'}, 2:{0:'Erik', 1:'NJ', 2:'Hannes'}},
1:{0:{0:'Karin', 1:'SomeoneElse'} }
}
numberOfPeople = 0
# we so dirty, inefficient counting
for floor in names.iterkeys():
for room in names[floor].iterkeys():
for people in names[floor][room]:
numberOfPeople += 1
minTeams = int(np.ceil(numberOfPeople/maxPerTeam))
teams = {}
availableTeams = np.arange(0, minTeams)
for i in availableTeams:
teams[i] = []
for floor in names.iterkeys():
for room in names[floor].iterkeys():
nPeople = len(names[floor][room])
rooms = random.choice(availableTeams, replace=False, size=nPeople)
for econSlave in names[floor][room]:
teams[rooms[econSlave]].append(names[floor][room][econSlave])
print teams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment