Skip to content

Commit 18123de

Browse files
committed
Adding tests for "Shikaku solver".
1 parent 62be623 commit 18123de

File tree

13 files changed

+293
-0
lines changed

13 files changed

+293
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "In stereo".
3535
- Tests for "Hooch clash".
3636
- Tests for "Lunar lockout".
37+
- Tests for "Shikaku solver".
3738

3839
### Changed
3940
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* The "Shikaku solver" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/shikaku-solver}
4+
*/
5+
function execute(readline) {
6+
var inputs = readline().split(' ');
7+
const W = parseInt(inputs[0]);
8+
const H = parseInt(inputs[1]);
9+
for (let i = 0; i < H; i++) {
10+
var inputs = readline().split(' ');
11+
for (let j = 0; j < W; j++) {
12+
const v = parseInt(inputs[j]);
13+
}
14+
}
15+
16+
// Write an answer using console.log()
17+
// To debug: console.error('Debug messages...');
18+
19+
console.log('answer');
20+
}
21+
22+
export { execute };
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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/shikakuSolver/shikakuSolver.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Shikaku solver", 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("10x10, one solution", function() {
22+
let inputFile = new File(__dirname + 'input/01 - 10x10, one solution.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - 10x10, one solution.txt');
27+
});
28+
29+
test("15x20, more solutions", function() {
30+
let inputFile = new File(__dirname + 'input/02 - 15x20, more solutions.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - 15x20, more solutions.txt');
35+
});
36+
37+
test("20x20", function() {
38+
let inputFile = new File(__dirname + 'input/03 - 20x20.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - 20x20.txt');
43+
});
44+
45+
test("25x20", function() {
46+
let inputFile = new File(__dirname + 'input/04 - 25x20.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - 25x20.txt');
51+
});
52+
53+
test("30x30", function() {
54+
let inputFile = new File(__dirname + 'input/05 - 30x30.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - 30x30.txt');
59+
});
60+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
0 0 0 0 0 0 0 0 9 0
3+
0 0 0 0 0 0 9 0 0 0
4+
0 0 0 0 0 0 0 0 0 0
5+
0 20 0 0 8 0 0 0 6 0
6+
0 0 0 0 0 0 0 0 0 0
7+
0 0 0 6 0 0 6 0 0 0
8+
10 0 0 0 0 0 0 0 0 0
9+
0 0 0 0 0 0 0 0 0 0
10+
0 0 6 0 6 0 0 0 8 0
11+
0 0 0 0 0 0 6 0 0 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
15 20
2+
0 0 0 0 0 0 0 0 0 9 0 0 0 0 0
3+
0 8 0 0 0 6 0 0 6 0 0 0 0 0 0
4+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5+
0 0 0 10 0 0 0 0 6 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 15 0 0 0 0
26+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
29+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0
30+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1
2+
AAAABBBCCC
3+
AAAABBBCCC
4+
AAAABBBCCC
5+
AAAADDDDEE
6+
AAAADDDDEE
7+
FFGGGHHHEE
8+
FFGGGHHHII
9+
FFJJKKLLII
10+
FFJJKKLLII
11+
FFJJKKLLII
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
20
2+
AABBCCDDDDDDDDD
3+
AABBCCEEEEEEFFF
4+
AABBCCGGGHHHFFF
5+
AABBIIGGGHHHFFF
6+
JJBBIIKKKLLLFFF
7+
JJMMIIKKKLLLFFF
8+
JJMMIIKKKNNNNNN
9+
JJMMIIOOONNNNNN
10+
JJMMIIOOOPPPPQQ
11+
RRMMSSSTTPPPPQQ
12+
RRMMSSSTTUUVVQQ
13+
RRMMSSSTTUUVVQQ
14+
RRWWWXXTTUUVVQQ
15+
RRWWWXXYYZZZZQQ
16+
RRWWWXXYYZZZZQQ
17+
RRaaaaaYYZZZZQQ
18+
bbaaaaaYYZZZZQQ
19+
bbcccccddZZZZQQ
20+
bbcccccddZZZZQQ
21+
bbcccccddZZZZQQ

0 commit comments

Comments
 (0)