Skip to content

Commit a8d5391

Browse files
committed
Adding tests for "Park pilot".
1 parent 201e300 commit a8d5391

File tree

13 files changed

+649
-0
lines changed

13 files changed

+649
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- Tests for "Nicholas Breakspeare and Hugh of Evesham".
2828
- Tests for "Nature of triangles".
2929
- Tests for "Artificial emotional intelligence".
30+
- Tests for "Park pilot".
3031

3132
### Changed
3233
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\ParkPilot;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Park pilot" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/park-pilot
12+
*/
13+
class ParkPilot implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
// $N: Road length
18+
fscanf($stdin, "%d", $N);
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
$sensorData = stream_get_line($stdin, 4 + 1, "\n");// Datas from four sensor with values 1 or 0 (e.g 1001)
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
// To debug: error_log(var_export($var, true)); (equivalent to var_dump)
26+
27+
28+
// Length of vehicle
29+
// Available park space
30+
echo("0\n");
31+
for ($i = 0; $i < $N; $i++)
32+
{
33+
34+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
35+
36+
37+
// Length of vehicle
38+
// Available park space
39+
echo("0L\n");
40+
}
41+
}
42+
}
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\Easy\ParkPilot;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\ParkPilot\ParkPilot;
9+
10+
/**
11+
* Tests for the "Park pilot" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\ParkPilot\ParkPilot
14+
* @group parkPilot
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new ParkPilot();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Test 1".
26+
*
27+
* @group parkPilot_test1
28+
*/
29+
public function testCanExecuteTest1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - test 1.txt',
33+
file_get_contents(__DIR__ . '/output/01 - test 1.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Test 2".
39+
*
40+
* @group parkPilot_test2
41+
*/
42+
public function testCanExecuteTest2(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - test 2.txt',
46+
file_get_contents(__DIR__ . '/output/02 - test 2.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Test 3".
52+
*
53+
* @group parkPilot_test3
54+
*/
55+
public function testCanExecuteTest3(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - test 3.txt',
59+
file_get_contents(__DIR__ . '/output/03 - test 3.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Test 4".
65+
*
66+
* @group parkPilot_test4
67+
*/
68+
public function testCanExecuteTest4(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - test 4.txt',
72+
file_get_contents(__DIR__ . '/output/04 - test 4.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Test 5".
78+
*
79+
* @group parkPilot_test5
80+
*/
81+
public function testCanExecuteTest5(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - test 5.txt',
85+
file_get_contents(__DIR__ . '/output/05 - test 5.txt')
86+
);
87+
}
88+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
31
2+
1111
3+
1111
4+
1111
5+
1111
6+
1111
7+
1111
8+
0111
9+
1111
10+
1111
11+
1111
12+
1110
13+
1011
14+
0011
15+
0011
16+
0011
17+
0101
18+
0100
19+
1100
20+
1100
21+
1010
22+
1010
23+
1011
24+
0011
25+
0001
26+
0001
27+
0101
28+
1100
29+
1100
30+
1100
31+
1110
32+
1011
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
74
2+
1111
3+
1111
4+
1111
5+
1111
6+
0111
7+
1111
8+
1111
9+
1111
10+
1111
11+
1011
12+
0010
13+
0011
14+
0111
15+
0111
16+
1111
17+
1101
18+
1100
19+
1000
20+
1010
21+
0010
22+
0011
23+
0111
24+
0111
25+
0001
26+
0001
27+
1000
28+
1100
29+
1110
30+
1110
31+
1100
32+
0100
33+
0001
34+
0011
35+
0011
36+
0011
37+
0011
38+
1010
39+
1100
40+
1100
41+
1000
42+
1000
43+
0000
44+
0001
45+
1011
46+
1011
47+
0001
48+
0001
49+
0100
50+
0100
51+
0101
52+
1101
53+
1100
54+
1000
55+
1010
56+
1010
57+
0010
58+
0011
59+
0011
60+
0101
61+
0101
62+
0101
63+
0100
64+
1100
65+
1000
66+
1010
67+
1010
68+
1010
69+
0010
70+
0011
71+
0101
72+
0101
73+
0101
74+
0101
75+
0100
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
74
2+
1111
3+
1111
4+
1111
5+
1111
6+
0111
7+
1111
8+
1111
9+
1111
10+
1111
11+
1011
12+
0010
13+
0011
14+
0011
15+
0111
16+
0111
17+
1101
18+
1100
19+
1100
20+
1000
21+
1010
22+
0010
23+
0011
24+
0011
25+
0011
26+
0001
27+
0101
28+
1100
29+
1100
30+
1100
31+
1100
32+
1000
33+
0010
34+
0011
35+
0011
36+
0111
37+
0111
38+
0001
39+
0000
40+
0100
41+
1100
42+
1110
43+
1110
44+
1100
45+
1000
46+
0010
47+
0011
48+
0011
49+
1011
50+
1011
51+
0101
52+
1100
53+
1100
54+
1100
55+
1101
56+
1001
57+
0010
58+
0011
59+
0011
60+
0111
61+
1111
62+
1101
63+
0100
64+
0100
65+
0000
66+
0010
67+
0011
68+
0011
69+
0010
70+
1010
71+
1100
72+
1100
73+
1100
74+
1100
75+
0100

0 commit comments

Comments
 (0)