CSE505/Assignment2/B/randomgen.py
2024-03-09 16:25:30 -05:00

15 lines
387 B
Python

import random
import sys
if len(sys.argv) == 2: x = int(sys.argv[1])
else: x = 10
file1 = open("data" + str(x) + ".lp", "w")
file2 = open("data" + str(x) + ".py", "w")
file2.write('[')
for i in range(x):
j = random.randint(1,x)
file1.write("task({}, {}).\n".format(i, j))
file2.write(str(j))
if i != x - 1: file2.write(", ")
file2.write(']')
file1.close()
file2.close()