-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_generator.py
45 lines (41 loc) · 1.27 KB
/
random_generator.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
from random import randint
import sys
LEVEL_MAX = 20
LEVEL_MIN = 20
CLIENT_MAX = 10
CLIENT_MIN = 10
CAP_MAX = 20
COOR_MAX = 1000
COOR_MIN = 0
def generate(file):
sys.stdout = open(file, 'w')
I = randint(CLIENT_MIN, CLIENT_MAX)
I1 = I
print(I)
clSum = 0
for i in range(I):
c = randint(1, CAP_MAX)
clSum += c
print(randint(COOR_MIN, COOR_MAX), randint(COOR_MIN, COOR_MAX), c)
I = randint(LEVEL_MIN, LEVEL_MAX)
p = randint(LEVEL_MIN, LEVEL_MAX)
print(I, p)
cs = []
for i in range(I-1):
c = randint(1, CAP_MAX)
cs.append(c)
print(randint(COOR_MIN, COOR_MAX), randint(COOR_MIN, COOR_MAX), c)
lSum = sum(sorted(cs, reverse=True)[:p-1])
print(randint(COOR_MIN, COOR_MAX), randint(COOR_MIN, COOR_MAX), max(randint(1, CAP_MAX), clSum-lSum))
I = randint(LEVEL_MIN, LEVEL_MAX)
p = randint(LEVEL_MIN, LEVEL_MAX)
print(I, p)
cs = []
for i in range(I-1):
c = randint(1, CAP_MAX)
cs.append(c)
print(randint(COOR_MIN, COOR_MAX), randint(COOR_MIN, COOR_MAX), c)
lSum = sum(sorted(cs, reverse=True)[:p-1])
print(randint(COOR_MIN, COOR_MAX), randint(COOR_MIN, COOR_MAX), max(randint(1, CAP_MAX), clSum-lSum))
sys.stdout.close()
sys.stdout = sys.__stdout__