Skip to content

Commit fbe2772

Browse files
committed
Adding tests for "Maze for the champions".
1 parent 74b3d13 commit fbe2772

19 files changed

+396
-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
## [3.16.0] - 2022-12-31
3940
### Added
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\MazeForTheChampions;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Maze for the champions" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/maze-for-the-champions
12+
*/
13+
class MazeForTheChampions implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $W);
18+
fscanf($stdin, "%d", $H);
19+
for ($i = 0; $i < $H; $i++)
20+
{
21+
fscanf($stdin, "%s", $EXT);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("answer\n");
27+
}
28+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\MazeForTheChampions;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\MazeForTheChampions\MazeForTheChampions;
9+
10+
/**
11+
* Tests for the "Maze for the champions" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\MazeForTheChampions\MazeForTheChampions
14+
* @group mazeForTheChampions
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MazeForTheChampions();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "1: easy for warrior".
26+
*
27+
* @group mazeForTheChampions_easyForWarrior
28+
*/
29+
public function testCanExecuteEasyForWarrior(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - easy for warrior.txt',
33+
file_get_contents(__DIR__ . '/output/01 - easy for warrior.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "2: easy for elf".
39+
*
40+
* @group mazeForTheChampions_easyForElf
41+
*/
42+
public function testCanExecuteEasyForElf(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - easy for elf.txt',
46+
file_get_contents(__DIR__ . '/output/02 - easy for elf.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "3: easy for mage".
52+
*
53+
* @group mazeForTheChampions_easyForMage
54+
*/
55+
public function testCanExecuteEasyForMage(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - easy for mage.txt',
59+
file_get_contents(__DIR__ . '/output/03 - easy for mage.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "4: easy for dwarf".
65+
*
66+
* @group mazeForTheChampions_easyForDwarf
67+
*/
68+
public function testCanExecuteEasyForDwarf(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - easy for dwarf.txt',
72+
file_get_contents(__DIR__ . '/output/04 - easy for dwarf.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "5: complex for warrior".
78+
*
79+
* @group mazeForTheChampions_complexForWarrior
80+
*/
81+
public function testCanExecuteComplexForWarrior(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - complex for warrior.txt',
85+
file_get_contents(__DIR__ . '/output/05 - complex for warrior.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "6: complex for elf".
91+
*
92+
* @group mazeForTheChampions_complexForElf
93+
*/
94+
public function testCanExecuteComplexForElf(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - complex for elf.txt',
98+
file_get_contents(__DIR__ . '/output/06 - complex for elf.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "7: complex for mage".
104+
*
105+
* @group mazeForTheChampions_complexForMage
106+
*/
107+
public function testCanExecuteComplexForMage(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - complex for mage.txt',
111+
file_get_contents(__DIR__ . '/output/07 - complex for mage.txt')
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "8: complex for dwarf".
117+
*
118+
* @group mazeForTheChampions_complexForDwarf
119+
*/
120+
public function testCanExecuteComplexForDwarf(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - complex for dwarf.txt',
124+
file_get_contents(__DIR__ . '/output/08 - complex for dwarf.txt')
125+
);
126+
}
127+
}
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)