-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomizer.py
32 lines (28 loc) · 936 Bytes
/
randomizer.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
import xlrd, random, sys, math
workbook = xlrd.open_workbook("namakelompok.xlsx")
worksheet = workbook.sheet_by_name(sys.argv[1])
jumlahanggota = sys.argv[2]
acessed = []
counterkelompok = 1
anggotakelompok = 0
def randomize():
pick = random.randint(0, worksheet.nrows-1)
if pick in acessed :
randomize()
else:
acessed.append(pick)
for i in range(worksheet.nrows):
randomize()
if counterkelompok == 1 and anggotakelompok <1:
print "KELOMPOK", counterkelompok
print worksheet.cell(acessed[i], 0).value
if(anggotakelompok < int(jumlahanggota)-1):
anggotakelompok = anggotakelompok+1
else:
print "\n"
anggotakelompok = 0
counterkelompok = counterkelompok+1
if counterkelompok == math.ceil(float(worksheet.nrows)/float(jumlahanggota))+1:
break
else:
print "KELOMPOK", counterkelompok