Skip to content

Commit e2f5477

Browse files
committed
Adding tests for "Blunder - episode 1".
1 parent 3787061 commit e2f5477

27 files changed

+698
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [2.3.0] - 2022-02-11
88
### Added
99
- Tests for "War".
1010
- Tests for "Dwarfs standing on the shoulders of giants".
1111
- Tests for "Network cabling".
12+
- Tests for "Blunder - episode 1".
1213

1314
## [2.2.0] - 2022-02-10
1415
### 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\Training\Medium\BlunderEpisode1;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Blunder - episode 1" puzzle.
11+
*/
12+
class BlunderEpisode1 implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d %d", $L, $C);
17+
for ($i = 0; $i < $L; $i++)
18+
{
19+
$row = stream_get_line($stdin, 101 + 1, "\n");
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
// To debug: error_log(var_export($var, true)); (equivalent to var_dump)
24+
25+
echo("answer\n");
26+
}
27+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Medium\BlunderEpisode1;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Medium\BlunderEpisode1\BlunderEpisode1;
9+
10+
/**
11+
* Tests for the "Blunder - episode 1" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Medium\BlunderEpisode1\BlunderEpisode1
14+
* @group blunderEpisode1
15+
*/
16+
final class BlunderEpisode1Test extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new BlunderEpisode1();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "Simple moves".
25+
*
26+
* @group blunderEpisode1_simpleMoves
27+
*/
28+
public function testCanExecuteSimpleMoves(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - simple moves.txt',
32+
file_get_contents(__DIR__ . '/output/01 - simple moves.txt')
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "Obstacles".
38+
*
39+
* @group blunderEpisode1_obstacles
40+
*/
41+
public function testCanExecuteObstacles(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - obstacles.txt',
45+
file_get_contents(__DIR__ . '/output/02 - obstacles.txt')
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "Priorities".
51+
*
52+
* @group blunderEpisode1_priorities
53+
*/
54+
public function testCanExecutePriorities(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - priorities.txt',
58+
file_get_contents(__DIR__ . '/output/03 - priorities.txt')
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "Straight line".
64+
*
65+
* @group blunderEpisode1_straightLine
66+
*/
67+
public function testCanExecuteStraightLine(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - straight line.txt',
71+
file_get_contents(__DIR__ . '/output/04 - straight line.txt')
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "Path modifier".
77+
*
78+
* @group blunderEpisode1_pathModifier
79+
*/
80+
public function testCanExecutePathModifier(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - path modifier.txt',
84+
file_get_contents(__DIR__ . '/output/05 - path modifier.txt')
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "Breaker mode".
90+
*
91+
* @group blunderEpisode1_breakerMode
92+
*/
93+
public function testCanExecuteBreakerMode(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - breaker mode.txt',
97+
file_get_contents(__DIR__ . '/output/06 - breaker mode.txt')
98+
);
99+
}
100+
101+
/**
102+
* Test that the code can be executed for "Inverter".
103+
*
104+
* @group blunderEpisode1_inverter
105+
*/
106+
public function testCanExecuteInverter(): void
107+
{
108+
$this->expectExecuteOutputAnswer(
109+
__DIR__ . '/input/07 - inverter.txt',
110+
file_get_contents(__DIR__ . '/output/07 - inverter.txt')
111+
);
112+
}
113+
114+
/**
115+
* Test that the code can be executed for "Teleport".
116+
*
117+
* @group blunderEpisode1_teleport
118+
*/
119+
public function testCanExecuteTeleport(): void
120+
{
121+
$this->expectExecuteOutputAnswer(
122+
__DIR__ . '/input/08 - teleport.txt',
123+
file_get_contents(__DIR__ . '/output/08 - teleport.txt')
124+
);
125+
}
126+
127+
/**
128+
* Test that the code can be executed for "Broken wall?".
129+
*
130+
* @group blunderEpisode1_brokenWall
131+
*/
132+
public function testCanExecuteBrokenWall(): void
133+
{
134+
$this->expectExecuteOutputAnswer(
135+
__DIR__ . '/input/09 - broken wall.txt',
136+
file_get_contents(__DIR__ . '/output/09 - broken wall.txt')
137+
);
138+
}
139+
140+
/**
141+
* Test that the code can be executed for "All together".
142+
*
143+
* @group blunderEpisode1_allTogether
144+
*/
145+
public function testCanExecuteAllTogether(): void
146+
{
147+
$this->expectExecuteOutputAnswer(
148+
__DIR__ . '/input/10 - all together.txt',
149+
file_get_contents(__DIR__ . '/output/10 - all together.txt')
150+
);
151+
}
152+
153+
/**
154+
* Test that the code can be executed for "LOOP".
155+
*
156+
* @group blunderEpisode1_LOOP
157+
*/
158+
public function testCanExecuteLOOP(): void
159+
{
160+
$this->expectExecuteOutputAnswer(
161+
__DIR__ . '/input/11 - LOOP.txt',
162+
file_get_contents(__DIR__ . '/output/11 - LOOP.txt')
163+
);
164+
}
165+
166+
/**
167+
* Test that the code can be executed for "Multiple loops".
168+
*
169+
* @group blunderEpisode1_multipleLoops
170+
*/
171+
public function testCanExecuteMultipleLoops(): void
172+
{
173+
$this->expectExecuteOutputAnswer(
174+
__DIR__ . '/input/12 - multiple loops.txt',
175+
file_get_contents(__DIR__ . '/output/12 - multiple loops.txt')
176+
);
177+
}
178+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5 5
2+
#####
3+
#@ #
4+
# #
5+
# $#
6+
#####
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
########
3+
# @ #
4+
# X#
5+
# XXX #
6+
# XX #
7+
# XX #
8+
# $#
9+
########
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
########
3+
# $#
4+
# #
5+
# #
6+
# @ #
7+
# #
8+
# #
9+
########
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8 8
2+
########
3+
# #
4+
# @ #
5+
# XX #
6+
# XX #
7+
# XX #
8+
# $#
9+
########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
# #
4+
# S W #
5+
# #
6+
# $ #
7+
# #
8+
#@ #
9+
# #
10+
#E N #
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
# @ #
4+
# B #
5+
#XXX #
6+
# B #
7+
# BXX$#
8+
#XXXXXXXX#
9+
# #
10+
# #
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
# I #
4+
# #
5+
# $#
6+
# @#
7+
# #
8+
# I#
9+
# #
10+
# #
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
# T #
4+
# #
5+
# #
6+
# #
7+
#@ #
8+
# #
9+
# #
10+
# T $#
11+
##########
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
##########
3+
# #
4+
# @ #
5+
# B #
6+
# S W #
7+
# XXX #
8+
# B N #
9+
# XXXXXXX#
10+
# $#
11+
##########
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15 15
2+
###############
3+
# IXXXXX #
4+
# @ #
5+
# #
6+
# #
7+
# I #
8+
# B #
9+
# B S W#
10+
# B T #
11+
# #
12+
# T #
13+
# B #
14+
# $#
15+
# XXXX #
16+
###############
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15 15
2+
###############
3+
# IXXXXX #
4+
# @ #
5+
#E S #
6+
# #
7+
# I #
8+
# B #
9+
# B S W#
10+
# B T #
11+
# #
12+
# T #
13+
# B #
14+
#N W$#
15+
# XXXX #
16+
###############
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
30 15
2+
###############
3+
# #@#I T$# #
4+
# # IB # #
5+
# # W # #
6+
# # ## #
7+
# #B XBN# # #
8+
# ## # #
9+
# # # #
10+
# # W # #
11+
# # ## #
12+
# #B XBN# # #
13+
# ## # #
14+
# # # #
15+
# # W # #
16+
# # ## #
17+
# #B XBN# # #
18+
# ## # #
19+
# # # #
20+
# # # #
21+
# # ## #
22+
# # XBIT # #
23+
# ######### #
24+
# #
25+
# ##### ##### #
26+
# # # #
27+
# # # ## #
28+
# # # # #
29+
# ##### ##### #
30+
# #
31+
###############
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SOUTH
2+
SOUTH
3+
EAST
4+
EAST
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SOUTH
2+
EAST
3+
EAST
4+
EAST
5+
SOUTH
6+
EAST
7+
SOUTH
8+
SOUTH
9+
SOUTH

0 commit comments

Comments
 (0)