-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-generator.js
More file actions
55 lines (44 loc) · 1.23 KB
/
Copy patharray-generator.js
File metadata and controls
55 lines (44 loc) · 1.23 KB
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
const fs = require('fs');
for(let i=0;i<=15;i++)
{
const index = "00" +i;
const fileIndex= index.substring(index.length-2);
// constraints
let valueHigh,valueLow,nLow,nHigh;
if(i<=5)
{
nHigh=10;
nLow=1;
valueHigh = 10;
valueLow = 1;
}
else
{
nHigh=10000;
nLow=1;
valueHigh = 1000;
valueLow = 1;
}
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1) + min); // The maximum is inclusive and the minimum is inclusive
}
function getRandomValue() {
return getRandomIntInclusive(nLow, nHigh);
}
let n=getRandomValue();
let test_case = [];
for(let j=0;j<n;j++)
{
let temp=getRandomIntInclusive(valueLow,valueHigh);
test_case.push(temp);
}
let tests = [n];
test_case=test_case.join(" ");
let final = [tests,test_case];
// let b=getRandomIntInclusive(1, valueHigh);
// let a=getRandomIntInclusive(b/2, b);
// test_case = [test_case.length, ...test_case];
fs.writeFileSync(`./input/input${fileIndex}.txt`,final.join("\n"));
}