Skip to content

Commit bb66616

Browse files
committed
Adding tests for "Maze for the champions".
1 parent 9923123 commit bb66616

19 files changed

+343
-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 "The polish dictionary".
3535
- Tests for "1010(1)".
3636
- Tests for "Vote counting".
37+
- Tests for "Maze for the champions".
3738

3839
## [1.16.0] - 2022-12-31
3940
### Added
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* The "Maze for the champions" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/maze-for-the-champions}
4+
*/
5+
function execute(readline) {
6+
const W = parseInt(readline());
7+
const H = parseInt(readline());
8+
for (let i = 0; i < H; i++) {
9+
const EXT = readline();
10+
}
11+
12+
// Write an answer using console.log()
13+
// To debug: console.error('Debug messages...');
14+
15+
console.log('answer');
16+
}
17+
18+
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/mazeForTheChampions/mazeForTheChampions.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite("Maze for the champions", 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("1: easy for warrior", function() {
22+
let inputFile = new File(__dirname + 'input/01 - easy for warrior.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - easy for warrior.txt');
27+
});
28+
29+
test("2: easy for elf", function() {
30+
let inputFile = new File(__dirname + 'input/02 - easy for elf.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - easy for elf.txt');
35+
});
36+
37+
test("3: easy for mage", function() {
38+
let inputFile = new File(__dirname + 'input/03 - easy for mage.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - easy for mage.txt');
43+
});
44+
45+
test("4: easy for dwarf", function() {
46+
let inputFile = new File(__dirname + 'input/04 - easy for dwarf.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - easy for dwarf.txt');
51+
});
52+
53+
test("5: complex for warrior", function() {
54+
let inputFile = new File(__dirname + 'input/05 - complex for warrior.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assertOutputAnswer(__dirname + 'output/05 - complex for warrior.txt');
59+
});
60+
61+
test("6: complex for elf", function() {
62+
let inputFile = new File(__dirname + 'input/06 - complex for elf.txt');
63+
64+
execute(inputFile.readline.bind(inputFile));
65+
66+
assertOutputAnswer(__dirname + 'output/06 - complex for elf.txt');
67+
});
68+
69+
test("7: complex for mage", function() {
70+
let inputFile = new File(__dirname + 'input/07 - complex for mage.txt');
71+
72+
execute(inputFile.readline.bind(inputFile));
73+
74+
assertOutputAnswer(__dirname + 'output/07 - complex for mage.txt');
75+
});
76+
77+
test("8: complex for dwarf", function() {
78+
let inputFile = new File(__dirname + 'input/08 - complex for dwarf.txt');
79+
80+
execute(inputFile.readline.bind(inputFile));
81+
82+
assertOutputAnswer(__dirname + 'output/08 - complex for dwarf.txt');
83+
});
84+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
8
2+
8
3+
########
4+
#......#
5+
#.####.>
6+
#.######
7+
#.######
8+
#.####.#
9+
>......#
10+
########
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
8
2+
8
3+
########
4+
#......#
5+
#.##.#.>
6+
#.#.#.##
7+
#....###
8+
###.#.##
9+
>....###
10+
########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
9
2+
9
3+
#########
4+
>.....###
5+
##.###.##
6+
##.####.#
7+
##.##.#.#
8+
##.####.>
9+
##.####.#
10+
#.......#
11+
#########
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
11
2+
13
3+
###########
4+
#....#....#
5+
#...#.#...#
6+
#..#####..#
7+
#..#####..#
8+
#.###.###.#
9+
>.###.###.>
10+
#...#.#...#
11+
#...###...#
12+
#..#...#..#
13+
#..#...#..#
14+
#....#....#
15+
###########
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
17
2+
19
3+
#################
4+
#....#...#...####
5+
#.##...#...#...##
6+
#..###########..#
7+
#.#.###.###.###.#
8+
#.....###....##.#
9+
#####.######.#..#
10+
<.....###....#.##
11+
############.#.##
12+
#.#########..#..#
13+
##....##....###.#
14+
##.##....##.....#
15+
##.##############
16+
#..############.#
17+
#.##......##.#.##
18+
#.##.#.##.##..#.#
19+
#.##.#.##.##.#.##
20+
#....#.##.....#.#
21+
######^##########
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
17
2+
11
3+
#################
4+
#......#....###.#
5+
#..#.#.#.##..##.>
6+
#.####.#.#.#.##.#
7+
#.#.##.#..###...#
8+
>..###.#.##...#.#
9+
#.#.##...#..#####
10+
#.##.#.#.##..#..#
11+
#..##..#..##.##.#
12+
#.####.##.......#
13+
#################
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
22
2+
20
3+
######################
4+
#....#...#...####....#
5+
#.##...#...#...##.##.#
6+
#..###########....##.#
7+
#.#.###.###.###.####.#
8+
#.....###....##.#....#
9+
#####.######.##.#.####
10+
<.....###....#.##.####
11+
############.#.##....#
12+
#.#########..#..####.#
13+
##....##....###.####.#
14+
##.##....##........#.#
15+
##.#############.#.#.#
16+
#..##############..#.#
17+
#.##......##.#.###.#.#
18+
#.##.#.##.##..#.##...#
19+
#.##.#.##.##.#.#.#####
20+
#.##.#.##.##.#.#######
21+
#....#.##............<
22+
######################

0 commit comments

Comments
 (0)