Skip to content

Commit 577e0e1

Browse files
committed
Adding tests for "A mountain of a mole hill".
1 parent 43110b5 commit 577e0e1

File tree

11 files changed

+281
-0
lines changed

11 files changed

+281
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "Rotating arrows".
3333
- Tests for "10 pin bowling scores".
3434
- Tests for "Is the king in check? (part 1)".
35+
- Tests for "A mountain of a mole hill".
3536

3637
## [3.7.0] - 2022-03-31
3738
### Added
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\AMountainOfAMoleHill;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "A mountain of a mole hill" puzzle.
11+
*/
12+
class AMountainOfAMoleHill implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
for ($i = 0; $i < 16; $i++)
17+
{
18+
$line = stream_get_line($stdin, 16 + 1, "\n");
19+
}
20+
21+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
22+
23+
echo("answer\n");
24+
}
25+
}
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\Easy\AMountainOfAMoleHill;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\AMountainOfAMoleHill\AMountainOfAMoleHill;
9+
10+
/**
11+
* Tests for the "A mountain of a mole hill" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\AMountainOfAMoleHill\AMountainOfAMoleHill
14+
* @group aMountainOfAMoleHill
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new AMountainOfAMoleHill();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "A simple garden".
26+
*
27+
* @group aMountainOfAMoleHill_aSimpleGarden
28+
*/
29+
public function testCanExecuteASimpleGarden(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - a simple garden.txt',
33+
2 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "From another angle".
39+
*
40+
* @group aMountainOfAMoleHill_fromAnotherAngle
41+
*/
42+
public function testCanExecuteFromAnotherAngle(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - from another angle.txt',
46+
3 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Getting crowded".
52+
*
53+
* @group aMountainOfAMoleHill_gettingCrowded
54+
*/
55+
public function testCanExecuteGettingCrowded(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - getting crowded.txt',
59+
10 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Divide and conquer".
65+
*
66+
* @group aMountainOfAMoleHill_divideAndConquer
67+
*/
68+
public function testCanExecuteDivideAndConquer(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - divide and conquer.txt',
72+
9 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Bag of snakes".
78+
*
79+
* @group aMountainOfAMoleHill_bagOfSnakes
80+
*/
81+
public function testCanExecuteBagOfSnakes(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - bag of snakes.txt',
85+
13 . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Zzzzz...".
91+
*
92+
* @group aMountainOfAMoleHill_zzzzz
93+
*/
94+
public function testCanExecuteZzzzz(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - zzzzz....txt',
98+
5 . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Include and infiltrate".
104+
*
105+
* @group aMountainOfAMoleHill_includeAndInfiltrate
106+
*/
107+
public function testCanExecuteIncludeAndInfiltrate(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - Include and infiltrate.txt',
111+
20 . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "How did THAT happen?".
117+
*
118+
* @group aMountainOfAMoleHill_howDidTHATHappen
119+
*/
120+
public function testCanExecuteHowDidTHATHappen(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - how did THAT happen.txt',
124+
74 . PHP_EOL
125+
);
126+
}
127+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
..+----------+..
4+
..| |..
5+
..| o |..
6+
..| o |..
7+
..| |..
8+
..+----------+..
9+
................
10+
............o...
11+
.....o..........
12+
................
13+
.........o......
14+
................
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
...+-------+.o..
4+
.o.| o o |..o.
5+
...| |....
6+
...| o +--+.oo.
7+
...| |.......
8+
...+----+.......
9+
................
10+
........oo......
11+
................
12+
...o............
13+
................
14+
...........o....
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
................
2+
................
3+
.oo.+------+oooo
4+
.oo.| o |.oo.
5+
oooo|oooooo|....
6+
....+--+ o |.oo.
7+
.......| o |....
8+
....oo.|o ++.oo.
9+
....oo.+--+o.oo.
10+
................
11+
......ooo.......
12+
................
13+
................
14+
................
15+
................
16+
................
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--+....o..o....
2+
| o|............
3+
| |......o.....
4+
|o +---+........
5+
| |....+--+
6+
| o |....|oo|
7+
| |....|oo|
8+
+------+..o.+--+
9+
................
10+
.....oo.........
11+
................
12+
+--------------+
13+
| o |
14+
| o |
15+
| |
16+
+--------------+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.....o..........
2+
.+-------+..o.o.
3+
.| |.oo...
4+
.| o |ooooo.
5+
.| |oo....
6+
.|oo+-+oo+--+oo.
7+
.| |.| |o..
8+
.| |.| +-+.
9+
.|oo|o| |.
10+
.| |.| |.
11+
.| |.|ooo o|.
12+
.| |.| |.
13+
.| |.| oo |.
14+
.| |.| |.
15+
.+--+o+-------+.
16+
...............o
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--------------+
2+
| o o |
3+
+----------+ ++
4+
..........++ ++.
5+
....o....++ ++..
6+
........++ ++...
7+
.......++ ++....
8+
.oo...++o++...o.
9+
.....++ ++......
10+
....++ ++.......
11+
...++ ++....oo..
12+
..++ ++....o....
13+
.++ ++..........
14+
++o +----------+
15+
| o |
16+
+--------------+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+--------------+
2+
| o oo |
3+
| +----------+o|
4+
| |..........| |
5+
| |.+------+o|o|
6+
| |.| |.| |
7+
| |o| +--+o|.| |
8+
| |.| |oo|o|.| |
9+
| |.| +--+ |.| |
10+
| |.| oo |.| |
11+
| |.|oooooo|.| |
12+
| |.+------+o|o|
13+
|o|..........| |
14+
|o+----------+ |
15+
| o o |
16+
+--------------+

0 commit comments

Comments
 (0)