Skip to content

Commit 7fea6d7

Browse files
committed
Adding tests for "Battle tower".
1 parent 519d55e commit 7fea6d7

File tree

13 files changed

+2141
-0
lines changed

13 files changed

+2141
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Tests for "The stonemason".
3030
- Tests for "Continued fractions".
3131
- Tests for "All operations are equal!".
32+
- Tests for "Battle tower".
3233

3334
## [1.14.0] - 2022-10-31
3435
### Added
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* The "Battle tower" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/battle-tower}
4+
*/
5+
function execute(readline) {
6+
const N = parseInt(readline());
7+
for (let i = 0; i < N; i++) {
8+
const line = readline();
9+
}
10+
11+
// Write an answer using console.log()
12+
// To debug: console.error('Debug messages...');
13+
14+
console.log('answer');
15+
}
16+
17+
export { execute };
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/battleTower/battleTower.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Battle tower", 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("Simple", function() {
21+
let inputFile = new File(__dirname + 'input/01 - simple.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("Mini", function() {
32+
let inputFile = new File(__dirname + 'input/02 - mini.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
1
39+
);
40+
});
41+
42+
test("Line", function() {
43+
let inputFile = new File(__dirname + 'input/03 - line.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
5
50+
);
51+
});
52+
53+
test("Star", function() {
54+
let inputFile = new File(__dirname + 'input/04 - star.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
1
61+
);
62+
});
63+
64+
test("Medium 1", function() {
65+
let inputFile = new File(__dirname + 'input/05 - medium 1.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
11
72+
);
73+
});
74+
75+
test("Medium 2", function() {
76+
let inputFile = new File(__dirname + 'input/06 - medium 2.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
50
83+
);
84+
});
85+
86+
test("Medium 3", function() {
87+
let inputFile = new File(__dirname + 'input/07 - medium 3.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
96
94+
);
95+
});
96+
97+
test("Dense 1", function() {
98+
let inputFile = new File(__dirname + 'input/08 - dense 1.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
146
105+
);
106+
});
107+
108+
test("Dense 2", function() {
109+
let inputFile = new File(__dirname + 'input/09 - dense 2.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
143
116+
);
117+
});
118+
119+
test("Dense 3", function() {
120+
let inputFile = new File(__dirname + 'input/10 - dense 3.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
189
127+
);
128+
});
129+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
1 1 2
3+
2 3 1 3 4
4+
3 1 2
5+
4 1 2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
1 0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
1 1 2
3+
2 2 1 3
4+
3 2 2 4
5+
4 2 3 5
6+
5 2 4 6
7+
6 2 5 7
8+
7 2 6 8
9+
8 2 7 9
10+
9 2 8 10
11+
10 1 9
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
1 1 7
3+
2 1 7
4+
3 1 7
5+
4 1 7
6+
5 1 7
7+
6 1 7
8+
7 7 1 2 3 4 5 6 8
9+
8 1 7
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
48
2+
1 1 44
3+
2 7 3 15 21 23 31 33 42
4+
3 1 2
5+
4 1 7
6+
5 1 32
7+
6 4 12 19 29 43
8+
7 5 4 11 13 33 37
9+
8 1 13
10+
9 1 38
11+
10 1 13
12+
11 3 7 14 27
13+
12 1 6
14+
13 6 7 8 10 16 35 36
15+
14 1 11
16+
15 1 2
17+
16 1 13
18+
17 1 26
19+
18 1 38
20+
19 6 6 26 32 33 38 44
21+
20 1 26
22+
21 1 2
23+
22 1 32
24+
23 1 2
25+
24 1 44
26+
25 1 38
27+
26 5 17 19 20 30 48
28+
27 1 11
29+
28 1 32
30+
29 1 6
31+
30 1 26
32+
31 1 2
33+
32 6 5 19 22 28 40 47
34+
33 3 2 7 19
35+
34 1 38
36+
35 1 13
37+
36 1 13
38+
37 1 7
39+
38 6 9 18 19 25 34 45
40+
39 1 42
41+
40 1 32
42+
41 1 44
43+
42 3 2 39 46
44+
43 1 6
45+
44 4 1 19 24 41
46+
45 1 38
47+
46 1 42
48+
47 1 32
49+
48 1 26

0 commit comments

Comments
 (0)