Skip to content

Commit 54b190e

Browse files
committed
Adding tests for "Hexagonal maze".
1 parent 18123de commit 54b190e

19 files changed

+250
-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 "Hooch clash".
3636
- Tests for "Lunar lockout".
3737
- Tests for "Shikaku solver".
38+
- Tests for "Hexagonal maze".
3839

3940
### Changed
4041
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* The "Hexagonal maze" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/hexagonal-maze}
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+
const row = readline();
11+
}
12+
for (let i = 0; i < h; i++) {
13+
14+
// Write an answer using console.log()
15+
// To debug: console.error('Debug messages...');
16+
17+
console.log('answer');
18+
}
19+
}
20+
21+
export { execute };
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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/hexagonalMaze/hexagonalMaze.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Hexagonal maze", 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("Easy", function() {
22+
let inputFile = new File(__dirname + 'input/01 - easy.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - easy.txt');
27+
});
28+
29+
test("Loop", function() {
30+
let inputFile = new File(__dirname + 'input/02 - loop.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - loop.txt');
35+
});
36+
37+
test("Through borders", function() {
38+
let inputFile = new File(__dirname + 'input/03 - through borders.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - through borders.txt');
43+
});
44+
45+
test("Corner ...", function() {
46+
let inputFile = new File(__dirname + 'input/04 - corner.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - corner.txt');
51+
});
52+
53+
test("... or not", function() {
54+
let inputFile = new File(__dirname + 'input/05 - or not.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - or not.txt');
59+
});
60+
61+
test("Everything", function() {
62+
let inputFile = new File(__dirname + 'input/06 - everything.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - everything.txt');
67+
});
68+
69+
test("Real hexagon", function() {
70+
let inputFile = new File(__dirname + 'input/07 - real hexagon.txt');
71+
72+
execute(inputFile.readline.bind(inputFile));
73+
74+
assertOutputAnswer(__dirname + 'output/07 - real hexagon.txt');
75+
});
76+
77+
test("Nothing to change", function() {
78+
let inputFile = new File(__dirname + 'input/08 - nothing to change.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assertOutputAnswer(__dirname + 'output/08 - nothing to change.txt');
83+
});
84+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
5 6
2+
#####
3+
#S#E#
4+
#_#_#
5+
#_#_#
6+
#___#
7+
#####
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
#E_____#
3+
##_###_#
4+
##_____#
5+
#_#_####
6+
##_____#
7+
####_#_#
8+
#S_____#
9+
########
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6 6
2+
#___##
3+
_#__#_
4+
#__##_
5+
###E#_
6+
__S#_#
7+
###_##
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
5 6
2+
E_###
3+
#_###
4+
##_##
5+
##_##
6+
###S#
7+
###__
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
5 6
2+
####_
3+
#__E#
4+
#_###
5+
#_###
6+
#S###
7+
_####
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
15 12
2+
_##_#####_###_#
3+
#__######_##_#_
4+
##S#_____#_#_#_
5+
###_####__#_#_#
6+
###_#####_#___#
7+
#__#####_#_#_##
8+
#_######_#_#_##
9+
________#_#__##
10+
_###_####_#_#_#
11+
#___#####__#_#_
12+
######E__###_#_
13+
___#####_####_#
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
21 20
2+
#####################
3+
#####_#________######
4+
#####_#_#######_#####
5+
####_#_#______#_#####
6+
####_#_#_#####_#_####
7+
###_#_#_#____#_#_####
8+
###_#_##__###_#_#_###
9+
##_#_#_##___#_#_#_###
10+
##_#_#_#__##_#_#_#_##
11+
#_#_#_#_##_#_#_#_#_##
12+
#S#_#_#_#_E__##_#_#_#
13+
#_#_#_#_#__#_#_#_#_##
14+
##_#_#_#_###_#_#_#_##
15+
##_#_#_#____#_#_#_###
16+
###_#_#_#######_#_###
17+
###_#_#_______#__####
18+
####___#######_#_####
19+
####_#________#_#####
20+
#####_#####_###_#####
21+
#####___#______######

0 commit comments

Comments
 (0)