-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcase_generator.py
66 lines (49 loc) · 1.56 KB
/
testcase_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import random
from typing import List
from tqdm import tqdm
from util import randint, randints
class Input:
def __init__(self, n: int, a: List[int]) -> None:
self.n = n
self.a = a
MultipleTestInput = List[Input]
class InputGenerator:
### IMPLEMENT GENERATORS BEGIN ###
def all_random(self) -> Input:
n = randint(1, 2 * 10**5)
a = randints(n, -(10**9), 10**9)
return Input(n, a)
def small_random(self) -> Input:
n = randint(1, 100)
a = randints(n, 0, 100)
return Input(n, a)
def n_max(self) -> Input:
n = 2 * 10**5
a = randints(n, -(10**9), 10**9)
return Input(n, a)
def all_different(self) -> Input:
n = 2 * 10**5
a = random.sample(range(-(10**9), 10**9 + 1), n)
return Input(n, a)
def all_same(self) -> Input:
n = 2 * 10**5
a = [randint(-(10**9), 10**9)] * n
return Input(n, a)
### IMPLEMENT GENERATORS END ###
def generate(self) -> List[Input]:
generators = []
for _ in range(5):
generators.append(self.all_random)
for _ in range(5):
generators.append(self.small_random)
for _ in range(5):
generators.append(self.n_max)
for _ in range(5):
generators.append(self.all_different)
for _ in range(5):
generators.append(self.all_same)
print("Generating inputs...")
inputs: List[Input] = []
for generate in tqdm(generators):
inputs.append(generate())
return inputs