Skip to content

Commit a18f511

Browse files
committed
Adding tests for "Hexagonal maze - part2".
1 parent 2515e9d commit a18f511

14 files changed

+334
-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
## [3.13.0] - 2022-09-30
3031
### Added
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMazePart2;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Hexagonal maze - part2" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/hexagonal-maze---part2
12+
*/
13+
class HexagonalMazePart2 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, 41 + 1, "\n");
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("answer\n");
26+
}
27+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\HexagonalMazePart2;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMazePart2\HexagonalMazePart2;
9+
10+
/**
11+
* Tests for the "Hexagonal maze - part2" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\HexagonalMazePart2\HexagonalMazePart2
14+
* @group hexagonalMazePart2
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new HexagonalMazePart2();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Example".
26+
*
27+
* @group hexagonalMazePart2_example
28+
*/
29+
public function testCanExecuteExample(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - example.txt',
33+
"R R DR R" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Need the key".
39+
*
40+
* @group hexagonalMazePart2_needTheKey
41+
*/
42+
public function testCanExecuteNeedTheKey(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - need the key.txt',
46+
"R DR DR DL DL DL UR UR R DR DR DR DR R R" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Choose shortest".
52+
*
53+
* @group hexagonalMazePart2_chooseShortest
54+
*/
55+
public function testCanExecuteChooseShortest(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - choose shortest.txt',
59+
"R DR DR DL DL DL UR UR R DR DR DR DR R R" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Shortest with sliding".
65+
*
66+
* @group hexagonalMazePart2_shortestWithSliding
67+
*/
68+
public function testCanExecuteShortestWithSliding(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - shortest with sliding.txt',
72+
"DL DR R UR UL" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Sliding junction".
78+
*
79+
* @group hexagonalMazePart2_slidingJunction
80+
*/
81+
public function testCanExecuteSlidingJunction(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - sliding junction.txt',
85+
"R DR DR DR R R UR UL L L L DL DL DR R R" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Sliding until wall".
91+
*
92+
* @group hexagonalMazePart2_slidingUntilWall
93+
*/
94+
public function testCanExecuteSlidingUntilWall(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - sliding until wall.txt',
98+
"DR DR R UR UL L L L DL DR DR R R" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Sliding or not sliding, that is the junction".
104+
*
105+
* @group hexagonalMazePart2_slidingOrNotSlidingThatIsTheJunction
106+
*/
107+
public function testCanExecuteSlidingOrNotSlidingThatIsTheJunction(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - sliding or not sliding, that is the junction.txt',
111+
"DR R L L" . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Crazy doors".
117+
*
118+
* @group hexagonalMazePart2_crazyDoors
119+
*/
120+
public function testCanExecuteCrazyDoors(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - crazy doors.txt',
124+
"DR R L L L" . PHP_EOL
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Visited or not ?".
130+
*
131+
* @group hexagonalMazePart2_visitedOrNot
132+
*/
133+
public function testCanExecuteVisitedOrNot(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - visited or not ?.txt',
137+
"DR R UR UL L UR" . PHP_EOL
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Skating rink".
143+
*
144+
* @group hexagonalMazePart2_skatingRink
145+
*/
146+
public function testCanExecuteSkatingRink(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - skating rink.txt',
150+
"DR L UL R UR UL DL" . PHP_EOL
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "Skating rink with keys".
156+
*
157+
* @group hexagonalMazePart2_skatingRinkWithKeys
158+
*/
159+
public function testCanExecuteSkatingRinkWithKeys(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - skating rink with keys.txt',
163+
"UL R L DR UR UL UL UR DR L DL DL UR R DR DL" . PHP_EOL
164+
);
165+
}
166+
}
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)