Skip to content

Commit f51437b

Browse files
committed
Adding tests for "Blunder - episode 3".
1 parent 9716805 commit f51437b

File tree

11 files changed

+1651
-0
lines changed

11 files changed

+1651
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Tests for "Blunder - episode 2".
10+
- Tests for "Blunder - episode 3".
1011

1112
## [1.3.0] - 2022-03-02
1213
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Blunder - episode 3" puzzle.
3+
*/
4+
function execute(readline) {
5+
const N = parseInt(readline());
6+
for (let i = 0; i < N; i++) {
7+
var inputs = readline().split(' ');
8+
const num = parseInt(inputs[0]);
9+
const t = parseInt(inputs[1]);
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
export { execute };
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../File.js';
4+
import { execute } from '../../../../lib/training/hard/blunderEpisode3/blunderEpisode3.js';
5+
6+
/**
7+
* Tests for the "Blunder - episode 3" puzzle.
8+
*/
9+
suite('Blunder - episode 3', function() {
10+
const sandbox = sinon.createSandbox();
11+
12+
setup(function () {
13+
sandbox.stub(console, "log");
14+
});
15+
16+
teardown(function () {
17+
sandbox.restore();
18+
});
19+
20+
21+
test('O(1)', function() {
22+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/01 - O(1).txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assert.strictEqual(
27+
console.log.getCall(0).args[0],
28+
'O(1)'
29+
);
30+
});
31+
32+
test('O(log n)', function() {
33+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/02 - O(log n).txt');
34+
35+
execute(inputFile.readline.bind(inputFile));
36+
37+
assert.strictEqual(
38+
console.log.getCall(0).args[0],
39+
'O(log n)'
40+
);
41+
});
42+
43+
test('O(n)', function() {
44+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/03 - O(n).txt');
45+
46+
execute(inputFile.readline.bind(inputFile));
47+
48+
assert.strictEqual(
49+
console.log.getCall(0).args[0],
50+
'O(n)'
51+
);
52+
});
53+
54+
test('O(n log n)', function() {
55+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/04 - O(n log n).txt');
56+
57+
execute(inputFile.readline.bind(inputFile));
58+
59+
assert.strictEqual(
60+
console.log.getCall(0).args[0],
61+
'O(n log n)'
62+
);
63+
});
64+
65+
test('O(n^2)', function() {
66+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/05 - O(n^2).txt');
67+
68+
execute(inputFile.readline.bind(inputFile));
69+
70+
assert.strictEqual(
71+
console.log.getCall(0).args[0],
72+
'O(n^2)'
73+
);
74+
});
75+
76+
test('O(n^2 log n)', function() {
77+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/06 - O(n^2 log n).txt');
78+
79+
execute(inputFile.readline.bind(inputFile));
80+
81+
assert.strictEqual(
82+
console.log.getCall(0).args[0],
83+
'O(n^2 log n)'
84+
);
85+
});
86+
87+
test('O(n^3)', function() {
88+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/07 - O(n^3).txt');
89+
90+
execute(inputFile.readline.bind(inputFile));
91+
92+
assert.strictEqual(
93+
console.log.getCall(0).args[0],
94+
'O(n^3)'
95+
);
96+
});
97+
98+
test('O(2^n)', function() {
99+
let inputFile = new File('./test/training/hard/blunderEpisode3/input/08 - O(2^n).txt');
100+
101+
execute(inputFile.readline.bind(inputFile));
102+
103+
assert.strictEqual(
104+
console.log.getCall(0).args[0],
105+
'O(2^n)'
106+
);
107+
});
108+
});
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
100
2+
10 200000
3+
110 180000
4+
210 190000
5+
310 180000
6+
410 190000
7+
510 180000
8+
610 190000
9+
710 190000
10+
810 180000
11+
910 190000
12+
1010 180000
13+
1110 190000
14+
1210 190000
15+
1310 180000
16+
1410 190000
17+
1510 190000
18+
1610 180000
19+
1710 190000
20+
1810 180000
21+
1910 190000
22+
2010 190000
23+
2110 180000
24+
2210 190000
25+
2310 190000
26+
2410 180000
27+
2510 190000
28+
2610 190000
29+
2710 180000
30+
2810 190000
31+
2910 180000
32+
3010 190000
33+
3110 180000
34+
3210 190000
35+
3310 190000
36+
3410 180000
37+
3510 190000
38+
3610 180000
39+
3710 180000
40+
3810 190000
41+
3910 180000
42+
4010 190000
43+
4110 190000
44+
4210 180000
45+
4310 180000
46+
4410 180000
47+
4510 190000
48+
4610 190000
49+
4710 180000
50+
4810 190000
51+
4910 190000
52+
5010 180000
53+
5110 190000
54+
5210 180000
55+
5310 190000
56+
5410 180000
57+
5510 190000
58+
5610 190000
59+
5710 180000
60+
5810 190000
61+
5910 190000
62+
6010 180000
63+
6110 190000
64+
6210 190000
65+
6310 180000
66+
6410 190000
67+
6510 180000
68+
6610 190000
69+
6710 190000
70+
6810 180000
71+
6910 180000
72+
7010 190000
73+
7110 190000
74+
7210 180000
75+
7310 190000
76+
7410 190000
77+
7510 180000
78+
7610 180000
79+
7710 180000
80+
7810 190000
81+
7910 190000
82+
8010 180000
83+
8110 190000
84+
8210 190000
85+
8310 190000
86+
8410 190000
87+
8510 180000
88+
8610 190000
89+
8710 190000
90+
8810 190000
91+
8910 190000
92+
9010 180000
93+
9110 180000
94+
9210 190000
95+
9310 190000
96+
9410 190000
97+
9510 180000
98+
9610 180000
99+
9710 180000
100+
9810 190000
101+
9910 190000

0 commit comments

Comments
 (0)