Skip to content

Commit d134a94

Browse files
committed
Adding tests for "The lost child.Episode-1".
1 parent 706306d commit d134a94

File tree

8 files changed

+165
-0
lines changed

8 files changed

+165
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Fun with set theory".
3232
- Tests for "Huffman code".
3333
- Tests for "Number of paths between 2 points".
34+
- Tests for "The lost child.Episode-1".
3435

3536
## [3.12.0] - 2022-09-01
3637
### Added
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\Community\Training\Medium\TheLostChildEpisode1;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "The lost child.Episode-1" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/the-lost-child-episode-1
12+
*/
13+
class TheLostChildEpisode1 implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
for ($i = 0; $i < 10; $i++)
18+
{
19+
$row = stream_get_line($stdin, 10 + 1, "\n");
20+
}
21+
22+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
23+
24+
echo("shortest distance in km\n");
25+
}
26+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\TheLostChildEpisode1;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\TheLostChildEpisode1\TheLostChildEpisode1;
9+
10+
/**
11+
* Tests for the "The lost child.Episode-1" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\TheLostChildEpisode1\TheLostChildEpisode1
14+
* @group theLostChildEpisode1
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new TheLostChildEpisode1();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Lost in playground".
26+
*
27+
* @group theLostChildEpisode1_lostInPlayground
28+
*/
29+
public function testCanExecuteLostInPlayground(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - lost in playground.txt',
33+
"50km" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Lost in paris".
39+
*
40+
* @group theLostChildEpisode1_lostInParis
41+
*/
42+
public function testCanExecuteLostInParis(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - lost in paris.txt',
46+
"120km" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Lost in jungle".
52+
*
53+
* @group theLostChildEpisode1_lostInJungle
54+
*/
55+
public function testCanExecuteLostInJungle(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - lost in jungle.txt',
59+
"160km" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Lost in maze runner".
65+
*
66+
* @group theLostChildEpisode1_lostInMazeRunner
67+
*/
68+
public function testCanExecuteLostInMazeRunner(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - lost in maze runner.txt',
72+
"200km" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Lost in space".
78+
*
79+
* @group theLostChildEpisode1_lostInSpace
80+
*/
81+
public function testCanExecuteLostInSpace(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - lost in space.txt',
85+
"170km" . PHP_EOL
86+
);
87+
}
88+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
..........
2+
M....C....
3+
..........
4+
..........
5+
..........
6+
..........
7+
..........
8+
..........
9+
..........
10+
..........
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
..........
2+
M#........
3+
#C##......
4+
..........
5+
..........
6+
..........
7+
..........
8+
..........
9+
..........
10+
..........
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
##########
2+
#...#C...#
3+
#...##...#
4+
###.#..###
5+
#.##M#...#
6+
#.....#..#
7+
#.....#..#
8+
#.....#..#
9+
#........#
10+
##########
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
##########
2+
#..M#C...#
3+
#...##...#
4+
###..#.###
5+
#.##.#...#
6+
#.....#..#
7+
#.....#..#
8+
#.....#..#
9+
#........#
10+
##########
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
##########
2+
#...#....#
3+
#.C.#.#..#
4+
###.#..###
5+
#M#......#
6+
#.###.#..#
7+
#.#....#.#
8+
#..#.##..#
9+
#........#
10+
##########

0 commit comments

Comments
 (0)