-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapGener.py
30 lines (28 loc) · 896 Bytes
/
mapGener.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
"""
generate the three input files as 25.in...
"""
import random
nums = [25, 50, 100]
def genDis():
a, b, c = generLen(), generLen(), generLen()
while a + b <= c or b + c <= a or a + c <= b:
c = generLen()
return a, b, c
def generLen():
a = round(random.random() * 100, 3)
return a if a else generLen()
for num in nums:
random.seed()
with open( str(num) + ".in", "w") as file:
i, k = 0, 0
file.write(str(num) + '\n')
while i < num/3:
dis = genDis()
for j in range(3):
if k < num:
file.write(str(k) + " ")
k = k + 1 if k % 3 != 2 else k - 2
file.write(str(k) + " " + str(dis[j]) + "\n")
if k + 2 < num:
file.write(str(k + 2) + " " + str(k + 3) + " " + str(generLen()) + "\n")
k, i = k + 3, i + 1