Skip to content

Commit f46a69d

Browse files
committed
Adding tests for "Plague, jr".
1 parent 11003b1 commit f46a69d

File tree

8 files changed

+3197
-0
lines changed

8 files changed

+3197
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "All operations are equal!".
3232
- Tests for "Battle tower".
3333
- Tests for "OneWay city".
34+
- Tests for "Plague, jr".
3435

3536
## [1.14.0] - 2022-10-31
3637
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Plague, jr" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/plague-jr}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
var inputs = readline().split(' ');
9+
const A = parseInt(inputs[0]);
10+
const B = parseInt(inputs[1]);
11+
}
12+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('42');
17+
}
18+
19+
export { execute };
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/plagueJr/plagueJr.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Plague, jr", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("The example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - the example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
1
28+
);
29+
});
30+
31+
test("Easy case", function() {
32+
let inputFile = new File(__dirname + 'input/02 - easy case.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
6
39+
);
40+
});
41+
42+
test("Advanced case", function() {
43+
let inputFile = new File(__dirname + 'input/03 - advanced case.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
13
50+
);
51+
});
52+
53+
test("Donut case", function() {
54+
let inputFile = new File(__dirname + 'input/04 - donut case.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
500
61+
);
62+
});
63+
64+
test("Spokey case", function() {
65+
let inputFile = new File(__dirname + 'input/05 - spokey case.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
1
72+
);
73+
});
74+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
0 1
3+
1 2
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
99
2+
0 1
3+
0 2
4+
1 3
5+
1 4
6+
2 5
7+
2 6
8+
3 7
9+
3 8
10+
4 9
11+
4 10
12+
5 11
13+
5 12
14+
6 13
15+
6 14
16+
7 15
17+
7 16
18+
8 17
19+
8 18
20+
9 19
21+
9 20
22+
10 21
23+
10 22
24+
11 23
25+
11 24
26+
12 25
27+
12 26
28+
13 27
29+
13 28
30+
14 29
31+
14 30
32+
15 31
33+
15 32
34+
16 33
35+
16 34
36+
17 35
37+
17 36
38+
18 37
39+
18 38
40+
19 39
41+
19 40
42+
20 41
43+
20 42
44+
21 43
45+
21 44
46+
22 45
47+
22 46
48+
23 47
49+
23 48
50+
24 49
51+
24 50
52+
25 51
53+
25 52
54+
26 53
55+
26 54
56+
27 55
57+
27 56
58+
28 57
59+
28 58
60+
29 59
61+
29 60
62+
30 61
63+
30 62
64+
31 63
65+
31 64
66+
32 65
67+
32 66
68+
33 67
69+
33 68
70+
34 69
71+
34 70
72+
35 71
73+
35 72
74+
36 73
75+
36 74
76+
37 75
77+
37 76
78+
38 77
79+
38 78
80+
39 79
81+
39 80
82+
40 81
83+
40 82
84+
41 83
85+
41 84
86+
42 85
87+
42 86
88+
43 87
89+
43 88
90+
44 89
91+
44 90
92+
45 91
93+
45 92
94+
46 93
95+
46 94
96+
47 95
97+
47 96
98+
48 97
99+
48 98
100+
49 99

0 commit comments

Comments
 (0)