Skip to content

Commit 69dcfad

Browse files
committed
Adding tests for "Hexagonal maze".
1 parent fe5eeb9 commit 69dcfad

19 files changed

+301
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMaze;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Hexagonal maze" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/hexagonal-maze
12+
*/
13+
class HexagonalMaze implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $w, $h);
18+
for ($i = 0; $i < $h; $i++)
19+
{
20+
$row = stream_get_line($stdin, 31 + 1, "\n");
21+
}
22+
for ($i = 0; $i < $h; $i++)
23+
{
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("answer\n");
27+
}
28+
}
29+
}
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\HexagonalMaze;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMaze\HexagonalMaze;
9+
10+
/**
11+
* Tests for the "Hexagonal maze" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMaze\HexagonalMaze
14+
* @group hexagonalMaze
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new HexagonalMaze();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Easy".
26+
*
27+
* @group hexagonalMaze_easy
28+
*/
29+
public function testCanExecuteEasy(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - easy.txt',
33+
file_get_contents(__DIR__ . '/output/01 - easy.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Loop".
39+
*
40+
* @group hexagonalMaze_loop
41+
*/
42+
public function testCanExecuteLoop(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - loop.txt',
46+
file_get_contents(__DIR__ . '/output/02 - loop.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Through borders".
52+
*
53+
* @group hexagonalMaze_throughBorders
54+
*/
55+
public function testCanExecuteThroughBorders(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - through borders.txt',
59+
file_get_contents(__DIR__ . '/output/03 - through borders.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Corner ...".
65+
*
66+
* @group hexagonalMaze_corner
67+
*/
68+
public function testCanExecuteCorner(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - corner.txt',
72+
file_get_contents(__DIR__ . '/output/04 - corner.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "... or not".
78+
*
79+
* @group hexagonalMaze_orNot
80+
*/
81+
public function testCanExecuteOrNot(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - or not.txt',
85+
file_get_contents(__DIR__ . '/output/05 - or not.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Everything".
91+
*
92+
* @group hexagonalMaze_everything
93+
*/
94+
public function testCanExecuteEverything(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - everything.txt',
98+
file_get_contents(__DIR__ . '/output/06 - everything.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Real hexagon".
104+
*
105+
* @group hexagonalMaze_realHexagon
106+
*/
107+
public function testCanExecuteRealHexagon(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - real hexagon.txt',
111+
file_get_contents(__DIR__ . '/output/07 - real hexagon.txt')
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Nothing to change".
117+
*
118+
* @group hexagonalMaze_nothingToChange
119+
*/
120+
public function testCanExecuteNothingToChange(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - nothing to change.txt',
124+
file_get_contents(__DIR__ . '/output/08 - nothing to change.txt')
125+
);
126+
}
127+
}
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)