-
Notifications
You must be signed in to change notification settings - Fork 0
/
random-round-robin.py
56 lines (45 loc) · 1.45 KB
/
random-round-robin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from random import randint
from datetime import datetime, date, time
#Competitors
competitors = ["Player1", "Player2", "Player3", "Player4", "Player5", "Player6", "Player7", "Player8"]
length = len(competitors)
#print ", ".join(competitors)
print "The number of the competitors: " + str(length)
print " "
def comp(comp):
for i in range(0, len(comp)):
print str(i+1) + ") " + comp[i]
comp(competitors)
#Number of competitors within one group
group_size = 4
#Create a random list of competitors
def rounding(competitors):
length = len(competitors)
rand_list = []
for i in range(0, length):
ind = randint(0, length-1)
rand_comp = competitors[ind]
rand_list.append(rand_comp)
competitors.remove(rand_comp)
length -= 1
return rand_list
randomlist = rounding(competitors)
print " "
#Group the competitors into couples
def couples(list, group):
couples = []
for n in range(0, len(list) / 2):
couples.append(list[n] + " vs. " + list[len(list)/2 + n ])
return couples
def chunker(seq, size):
return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
def grouping():
i=0
for group in chunker(randomlist, group_size):
print " "
print "Group: " + str(i+1)
i += 1
for n in group:
print n
print grouping()
print "Random grouping was run at: " + datetime.now().strftime("%Y-%m-%d %H:%M")