Skip to content

Commit 85c8256

Browse files
committed
Adding tests for "Divine!".
1 parent 57be06e commit 85c8256

File tree

11 files changed

+204
-0
lines changed

11 files changed

+204
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- Tests for "English length units conversion".
3636
- Tests for "Sandpile addition".
3737
- Tests for "Blood types".
38+
- Tests for "Divine!".
3839

3940
## [1.14.0] - 2022-10-31
4041
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Divine!" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/divine}
4+
*/
5+
function execute(readline) {
6+
for (let i = 0; i < 9; i++) {
7+
const l = readline();
8+
}
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('answer');
14+
}
15+
16+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5+
import { execute } from '../../../../../lib/community/training/medium/divine/divine.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Divine!", 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("Test 1", function() {
22+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - test 1.txt');
27+
});
28+
29+
test("Test 2", function() {
30+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - test 2.txt');
35+
});
36+
37+
test("Test 3", function() {
38+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - test 3.txt');
43+
});
44+
45+
test("Test 4", function() {
46+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - test 4.txt');
51+
});
52+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
4 4 1 5 1 2 5 5 1
2+
1 4 2 1 1 2 2 4 5
3+
1 1 5 4 5 4 4 5 1
4+
3 2 1 3 1 3 3 1 2
5+
1 5 3 3 5 5 2 5 2
6+
1 1 5 5 3 5 2 3 1
7+
2 2 5 5 4 4 3 1 3
8+
1 4 4 3 4 1 5 5 4
9+
3 4 1 5 5 4 1 2 5
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2 3 3 2 3 2 4 4 5
2+
3 1 1 2 1 5 1 3 2
3+
4 4 5 4 1 1 5 1 2
4+
4 2 2 3 5 1 4 5 5
5+
1 1 3 5 4 3 2 1 2
6+
3 4 3 4 3 2 3 4 4
7+
2 5 5 1 2 2 3 5 1
8+
2 1 2 1 5 3 2 5 3
9+
3 2 5 4 5 3 4 4 5
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3 3 1 5 3 4 2 5 2
2+
2 5 5 2 2 5 5 4 2
3+
5 3 3 2 2 1 4 3 3
4+
3 1 2 4 1 2 4 2 4
5+
3 2 2 5 1 4 3 4 2
6+
1 1 4 4 2 1 4 5 5
7+
1 5 4 5 3 2 1 5 5
8+
3 2 1 2 4 1 1 4 1
9+
5 1 1 2 4 1 5 2 3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1 1 5 1 5 1 5 4 1
2+
1 5 4 5 2 1 5 2 4
3+
2 2 5 3 2 2 3 3 4
4+
5 1 2 2 1 4 4 5 3
5+
2 3 2 1 5 5 3 1 1
6+
3 4 3 4 1 4 2 4 4
7+
5 2 1 5 2 4 1 4 5
8+
3 1 1 2 1 2 5 5 1
9+
3 5 3 5 1 2 1 5 2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
26
2+
0 2 1 2
3+
0 3 1 3
4+
0 8 1 8
5+
1 7 1 8
6+
1 7 2 7
7+
2 0 3 0
8+
2 2 3 2
9+
2 3 2 4
10+
2 4 3 4
11+
3 0 4 0
12+
3 3 3 4
13+
4 1 4 2
14+
4 1 5 1
15+
4 3 4 4
16+
4 3 5 3
17+
4 4 5 4
18+
4 6 4 7
19+
5 3 5 4
20+
5 4 5 5
21+
5 7 6 7
22+
6 0 7 0
23+
7 3 7 4
24+
7 3 8 3
25+
7 4 7 5
26+
7 8 8 8
27+
8 4 8 5
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
21
2+
0 0 1 0
3+
0 3 0 4
4+
1 3 1 4
5+
1 4 1 5
6+
1 5 1 6
7+
1 5 2 5
8+
1 6 2 6
9+
2 2 2 3
10+
2 6 2 7
11+
2 6 3 6
12+
3 2 3 3
13+
3 4 3 5
14+
3 8 4 8
15+
4 5 4 6
16+
4 5 5 5
17+
6 5 6 6
18+
6 6 7 6
19+
7 1 8 1
20+
7 5 7 6
21+
8 0 8 1
22+
8 7 8 8
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
23
2+
0 3 1 3
3+
0 7 1 7
4+
1 0 2 0
5+
1 6 1 7
6+
2 0 2 1
7+
2 0 3 0
8+
2 2 2 3
9+
2 2 3 2
10+
2 4 2 5
11+
2 5 3 5
12+
3 2 3 3
13+
3 4 3 5
14+
3 6 4 6
15+
3 7 4 7
16+
4 5 4 6
17+
4 6 4 7
18+
4 6 5 6
19+
5 4 5 5
20+
5 5 5 6
21+
5 5 6 5
22+
6 5 6 6
23+
7 7 7 8
24+
8 5 8 6

0 commit comments

Comments
 (0)