Skip to content

Commit 151a093

Browse files
committed
Adding tests for "Ghost legs".
1 parent 8586a51 commit 151a093

File tree

15 files changed

+282
-0
lines changed

15 files changed

+282
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Tests for "ISBN check digit".
1212
- Tests for "Equivalent resistance, circuit building".
1313
- Tests for "1D spreadsheet".
14+
- Tests for "Ghost legs".
1415

1516
### Changed
1617
- "STDIN" to "$stdin" in the "Rock paper scissors lizard spock" default code.
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\Easy\GhostLegs;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Ghost legs" puzzle.
11+
*/
12+
class GhostLegs implements Puzzle
13+
{
14+
public function execute($stdin): void
15+
{
16+
fscanf($stdin, "%d %d", $W, $H);
17+
for ($i = 0; $i < $H; $i++)
18+
{
19+
$line = stream_get_line($stdin, 1024 + 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: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Easy\GhostLegs;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\GhostLegs\GhostLegs;
9+
10+
/**
11+
* Tests for the "Ghost legs" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\GhostLegs\GhostLegs
14+
* @group ghostLegs
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new GhostLegs();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Simple sample".
26+
*
27+
* @group ghostLegs_simpleSample
28+
*/
29+
public function testCanExecuteSimpleSample(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - simple sample.txt',
33+
file_get_contents(__DIR__ . '/output/01 - simple sample.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Small sample".
39+
*
40+
* @group ghostLegs_smallSample
41+
*/
42+
public function testCanExecuteSmallSample(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - small sample.txt',
46+
file_get_contents(__DIR__ . '/output/02 - small sample.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "6 Lanes".
52+
*
53+
* @group ghostLegs_6Lanes
54+
*/
55+
public function testCanExecute6Lanes(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 6 lanes.txt',
59+
file_get_contents(__DIR__ . '/output/03 - 6 lanes.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "8 Lanes".
65+
*
66+
* @group ghostLegs_8Lanes
67+
*/
68+
public function testCanExecute8Lanes(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - 8 lanes.txt',
72+
file_get_contents(__DIR__ . '/output/04 - 8 lanes.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "10 Lanes".
78+
*
79+
* @group ghostLegs_10Lanes
80+
*/
81+
public function testCanExecute10Lanes(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - 10 lanes.txt',
85+
file_get_contents(__DIR__ . '/output/05 - 10 lanes.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Wide and wild".
91+
*
92+
* @group ghostLegs_wideAndWild
93+
*/
94+
public function testCanExecuteWideAndWild(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - wide and wild.txt',
98+
file_get_contents(__DIR__ . '/output/06 - wide and wild.txt')
99+
);
100+
}
101+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7 7
2+
A B C
3+
| | |
4+
|--| |
5+
| |--|
6+
| |--|
7+
| | |
8+
1 2 3
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
13 8
2+
A B C D E
3+
| | | | |
4+
| |--| | |
5+
|--| | | |
6+
| | |--| |
7+
| |--| |--|
8+
| | | | |
9+
1 2 3 4 5
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
16 14
2+
F E D C B A
3+
| |--| | | |
4+
|--| |--| |--|
5+
| |--| |--| |
6+
| | | | |--|
7+
| |--| |--| |
8+
| | |--| | |
9+
| | |--| |--|
10+
|--| | |--| |
11+
| | |--| | |
12+
|--| | | |--|
13+
| |--| | | |
14+
| | |--| | |
15+
0 1 2 3 4 5
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
22 18
2+
P Q R S T U V W
3+
| | | | |--| | |
4+
| | |--| | | |--|
5+
| |--| |--| | | |
6+
|--| |--| | | |--|
7+
|--| | | | |--| |
8+
| |--| | |--| |--|
9+
| | | |--| |--| |
10+
|--| | | |--| | |
11+
| | |--| | | | |
12+
| | | |--| | |--|
13+
| | | | |--| | |
14+
|--| | | | | | |
15+
|--| |--| | | |--|
16+
| |--| | |--| | |
17+
| | |--| | | |--|
18+
|--| |--| | |--| |
19+
1 2 3 4 5 6 7 8
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
28 20
2+
A B C D E F G H I J
3+
|--| |--| |--| |--| |--|
4+
| |--| |--| |--| |--| |
5+
|--| |--| |--| |--| |--|
6+
|--| |--| |--| |--| |--|
7+
| |--| |--| |--| |--| |
8+
| |--| |--| |--| |--| |
9+
|--| |--| |--| |--| |--|
10+
|--| |--| |--| |--| |--|
11+
| |--| |--| |--| |--| |
12+
|--| |--| |--| |--| |--|
13+
| |--| |--| |--| |--| |
14+
|--| |--| |--| |--| |--|
15+
|--| |--| |--| |--| |--|
16+
|--| |--| |--| |--| |--|
17+
| |--| |--| |--| |--| |
18+
|--| |--| |--| |--| |--|
19+
|--| |--| |--| |--| |--|
20+
| |--| |--| |--| |--| |
21+
0 1 2 3 4 5 6 7 8 9
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
76 23
2+
~ ! @ # $ % ^ & * ( ) + ` 1 2 3 4 5 6 7 8 9 0 = \ /
3+
| |--| | |--| | |--| |--| | |--| | | |--| |--| | |--| | |--|
4+
|--| |--| | | |--| |--| |--| | | |--| | |--| |--| | | |--| |
5+
| |--| |--| | | | | |--| |--| | | | |--| |--| |--| |--| |--|
6+
|--| |--| | | |--| |--| |--| | | |--| |--| |--| | | |--| |--|
7+
|--| | | | |--| | |--| | | | |--| |--| |--| |--| |--| |--| |
8+
| |--| | |--| |--| | |--| | |--| |--| | | |--| | |--| |--| |
9+
| | | |--| |--| |--| | | |--| |--| | |--| |--| |--| |--| |--|
10+
|--| | | |--| |--| |--| | | |--| |--| |--| | |--| | |--| |--|
11+
| | |--| | | | |--| | |--| | | | | | |--| | | |--| |--| |
12+
| | | |--| | |--| | | | |--| | |--| |--| |--| |--| |--| |--|
13+
| |--| |--| | | | | |--| |--| | | | |--| |--| |--| |--| |--|
14+
|--| |--| | | |--| |--| |--| | | |--| |--| |--| | | |--| |--|
15+
|--| | | | |--| | |--| | | | |--| |--| |--| |--| |--| |--| |
16+
|--| |--| | | |--| |--| |--| | | |--| | |--| | | |--| | |--|
17+
| |--| | |--| |--| | |--| | |--| |--| | | |--| | |--| |--| |
18+
| |--| | |--| | | | |--| | |--| | |--| |--| |--| |--| |--| |
19+
|--| | |--| | | | |--| | |--| |--| | |--| |--| |--| |--| |--|
20+
|--| |--| | | |--| |--| |--| | | |--| | |--| | | |--| | |--|
21+
| |--| | |--| | |--| |--| | | |--| |--| | |--| |--| |--| |--|
22+
| | | |--| | |--| | | | |--| | |--| | |--| |--| |--| |--| |
23+
|--| |--| |--| |--| |--| |--| |--| |--| |--| |--| | | | | |--|
24+
a A b B c C d D e E f F g G h H i I j J k K l L m M
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A2
2+
B1
3+
C3

0 commit comments

Comments
 (0)