Skip to content

Commit c1e98f0

Browse files
committed
Adding tests for "Hexagonal maze - part2".
1 parent 4d614e5 commit c1e98f0

14 files changed

+300
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Tests for "Regular polygons".
2626
- Tests for "Horse-hyperracing hyperduals".
2727
- Tests for "3×N tiling".
28+
- Tests for "Hexagonal maze - part2".
2829

2930
## [1.13.0] - 2022-09-30
3031
### Added
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The "Hexagonal maze - part2" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/hexagonal-maze---part2}
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+
13+
// Write an answer using console.log()
14+
// To debug: console.error('Debug messages...');
15+
16+
console.log('answer');
17+
}
18+
19+
export { execute };
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/medium/hexagonalMazePart2/hexagonalMazePart2.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Hexagonal maze - part2", 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("Example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"R R DR R"
28+
);
29+
});
30+
31+
test("Need the key", function() {
32+
let inputFile = new File(__dirname + 'input/02 - need the key.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"R DR DR DL DL DL UR UR R DR DR DR DR R R"
39+
);
40+
});
41+
42+
test("Choose shortest", function() {
43+
let inputFile = new File(__dirname + 'input/03 - choose shortest.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"R DR DR DL DL DL UR UR R DR DR DR DR R R"
50+
);
51+
});
52+
53+
test("Shortest with sliding", function() {
54+
let inputFile = new File(__dirname + 'input/04 - shortest with sliding.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"DL DR R UR UL"
61+
);
62+
});
63+
64+
test("Sliding junction", function() {
65+
let inputFile = new File(__dirname + 'input/05 - sliding junction.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"R DR DR DR R R UR UL L L L DL DL DR R R"
72+
);
73+
});
74+
75+
test("Sliding until wall", function() {
76+
let inputFile = new File(__dirname + 'input/06 - sliding until wall.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"DR DR R UR UL L L L DL DR DR R R"
83+
);
84+
});
85+
86+
test("Sliding or not sliding, that is the junction", function() {
87+
let inputFile = new File(__dirname + 'input/07 - sliding or not sliding, that is the junction.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"DR R L L"
94+
);
95+
});
96+
97+
test("Crazy doors", function() {
98+
let inputFile = new File(__dirname + 'input/08 - crazy doors.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"DR R L L L"
105+
);
106+
});
107+
108+
test("Visited or not ?", function() {
109+
let inputFile = new File(__dirname + 'input/09 - visited or not ?.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"DR R UR UL L UR"
116+
);
117+
});
118+
119+
test("Skating rink", function() {
120+
let inputFile = new File(__dirname + 'input/10 - skating rink.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
"DR L UL R UR UL DL"
127+
);
128+
});
129+
130+
test("Skating rink with keys", function() {
131+
let inputFile = new File(__dirname + 'input/11 - skating rink with keys.txt');
132+
133+
execute(inputFile.readline.bind(inputFile));
134+
135+
assert.strictEqual(
136+
console.log.getCall(0).args[0],
137+
"UL R L DR UR UL UL UR DR L DL DL UR R DR DL"
138+
);
139+
});
140+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
10 4
2+
##########
3+
#S.___.###
4+
#######.E#
5+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
#S.#######
4+
###.######
5+
###.######
6+
###..#####
7+
##.#.#####
8+
##a##A####
9+
##.##.####
10+
###..B..E#
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
#S......##
4+
###.####.#
5+
###.####b#
6+
###..###.#
7+
##.#....##
8+
##a##A####
9+
##.##.####
10+
###..B..E#
11+
##########
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
15 5
2+
###############
3+
##S.........E##
4+
##.##########.#
5+
##._________.##
6+
###############
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
#S.#######
4+
###.######
5+
###.######
6+
####_#####
7+
##..__..##
8+
##.##_##.#
9+
#.###...##
10+
##..E#####
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
#S########
4+
##.#######
5+
##_#######
6+
##__...###
7+
#_#_##_###
8+
#_##___###
9+
#.########
10+
##..___E##
11+
##########
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
10 6
2+
##########
3+
###S######
4+
####_#####
5+
####_#####
6+
#EA____a##
7+
##########

0 commit comments

Comments
 (0)