Skip to content

Commit 3126864

Browse files
committed
Adding tests for "Blunder - episode 2".
1 parent 4e73dc4 commit 3126864

File tree

12 files changed

+16911
-0
lines changed

12 files changed

+16911
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ 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]
8+
### Added
9+
- Tests for "Blunder - episode 2".
10+
711
## [2.3.0] - 2022-02-11
812
### Added
913
- Tests for "War".
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Training\Hard\BlunderEpisode2;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Blunder - episode 2" puzzle.
11+
*/
12+
class BlunderEpisode2 implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d", $N);
17+
for ($i = 0; $i < $N; $i++)
18+
{
19+
$room = stream_get_line($stdin, 256 + 1, "\n");
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("answer\n");
25+
}
26+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Training\Hard\BlunderEpisode2;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Training\Hard\BlunderEpisode2\BlunderEpisode2;
9+
10+
/**
11+
* Tests for the "Blunder - episode 2" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Training\Hard\BlunderEpisode2\BlunderEpisode2
14+
* @group blunderEpisode2
15+
*/
16+
final class BlunderEpisode2Test extends PuzzleTest
17+
{
18+
public function setUp(): void
19+
{
20+
$this->puzzle = new BlunderEpisode2();
21+
}
22+
23+
/**
24+
* Test that the code can be executed for "One room".
25+
*
26+
* @group blunderEpisode2_oneRoom
27+
*/
28+
public function testCanExecuteOneRoom(): void
29+
{
30+
$this->expectExecuteOutputAnswer(
31+
__DIR__ . '/input/01 - one room.txt',
32+
200 . PHP_EOL
33+
);
34+
}
35+
36+
/**
37+
* Test that the code can be executed for "3 rooms".
38+
*
39+
* @group blunderEpisode2_3Rooms
40+
*/
41+
public function testCanExecute3Rooms(): void
42+
{
43+
$this->expectExecuteOutputAnswer(
44+
__DIR__ . '/input/02 - 3 rooms.txt',
45+
40 . PHP_EOL
46+
);
47+
}
48+
49+
/**
50+
* Test that the code can be executed for "15 rooms, small range".
51+
*
52+
* @group blunderEpisode2_15RoomsSmallRange
53+
*/
54+
public function testCanExecute15RoomsSmallRange(): void
55+
{
56+
$this->expectExecuteOutputAnswer(
57+
__DIR__ . '/input/03 - 15 rooms small range.txt',
58+
88 . PHP_EOL
59+
);
60+
}
61+
62+
/**
63+
* Test that the code can be executed for "55 rooms".
64+
*
65+
* @group blunderEpisode2_55Rooms
66+
*/
67+
public function testCanExecute55Rooms(): void
68+
{
69+
$this->expectExecuteOutputAnswer(
70+
__DIR__ . '/input/04 - 55 rooms.txt',
71+
358 . PHP_EOL
72+
);
73+
}
74+
75+
/**
76+
* Test that the code can be executed for "1275 rooms".
77+
*
78+
* @group blunderEpisode2_1275Rooms
79+
*/
80+
public function testCanExecute1275Rooms(): void
81+
{
82+
$this->expectExecuteOutputAnswer(
83+
__DIR__ . '/input/05 - 1275 rooms.txt',
84+
1928 . PHP_EOL
85+
);
86+
}
87+
88+
/**
89+
* Test that the code can be executed for "5050 rooms".
90+
*
91+
* @group blunderEpisode2_5050Rooms
92+
*/
93+
public function testCanExecute5050Rooms(): void
94+
{
95+
$this->expectExecuteOutputAnswer(
96+
__DIR__ . '/input/06 - 5050 rooms.txt',
97+
75413 . PHP_EOL
98+
);
99+
}
100+
101+
/**
102+
* Test that the code can be executed for "9870 rooms".
103+
*
104+
* @group blunderEpisode2_9870Rooms
105+
*/
106+
public function testCanExecute9870Rooms(): void
107+
{
108+
$this->expectExecuteOutputAnswer(
109+
__DIR__ . '/input/07 - 9870 rooms.txt',
110+
103558 . PHP_EOL
111+
);
112+
}
113+
114+
/**
115+
* Test that the code can be executed for "Square building".
116+
*
117+
* @group blunderEpisode2_squareBuilding
118+
*/
119+
public function testCanExecuteSquareBuilding(): void
120+
{
121+
$this->expectExecuteOutputAnswer(
122+
__DIR__ . '/input/08 - square building.txt',
123+
400 . PHP_EOL
124+
);
125+
}
126+
127+
/**
128+
* Test that the code can be executed for "Multiple entries".
129+
*
130+
* @group blunderEpisode2_multipleEntries
131+
*/
132+
public function testCanExecuteMultipleEntries(): void
133+
{
134+
$this->expectExecuteOutputAnswer(
135+
__DIR__ . '/input/09 - multiple entries.txt',
136+
358 . PHP_EOL
137+
);
138+
}
139+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
0 200 E E
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
0 20 1 2
3+
1 17 E E
4+
2 20 E E
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
15
2+
0 17 1 2
3+
1 15 3 4
4+
2 15 4 5
5+
3 20 6 7
6+
4 12 7 8
7+
5 11 8 9
8+
6 18 10 11
9+
7 19 11 12
10+
8 12 12 13
11+
9 11 13 14
12+
10 13 E E
13+
11 14 E E
14+
12 17 E E
15+
13 19 E E
16+
14 15 E E
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
55
2+
0 46 1 2
3+
1 29 3 4
4+
2 26 4 5
5+
3 34 6 7
6+
4 36 7 8
7+
5 10 8 9
8+
6 21 10 11
9+
7 21 11 12
10+
8 12 12 13
11+
9 16 13 14
12+
10 21 15 16
13+
11 22 16 17
14+
12 38 17 18
15+
13 34 18 19
16+
14 49 19 20
17+
15 21 21 22
18+
16 37 22 23
19+
17 38 23 24
20+
18 31 24 25
21+
19 42 25 26
22+
20 21 26 27
23+
21 48 28 29
24+
22 24 29 30
25+
23 14 30 31
26+
24 23 31 32
27+
25 40 32 33
28+
26 11 33 34
29+
27 22 34 35
30+
28 25 36 37
31+
29 11 37 38
32+
30 13 38 39
33+
31 16 39 40
34+
32 43 40 41
35+
33 24 41 42
36+
34 47 42 43
37+
35 46 43 44
38+
36 15 45 46
39+
37 36 46 47
40+
38 36 47 48
41+
39 31 48 49
42+
40 17 49 50
43+
41 27 50 51
44+
42 22 51 52
45+
43 46 52 53
46+
44 19 53 54
47+
45 34 E E
48+
46 21 E E
49+
47 14 E E
50+
48 16 E E
51+
49 25 E E
52+
50 47 E E
53+
51 37 E E
54+
52 39 E E
55+
53 38 E E
56+
54 32 E E

0 commit comments

Comments
 (0)