Skip to content

Commit 1023f22

Browse files
committed
Adding tests for "Porcupine fever".
1 parent 58605f2 commit 1023f22

File tree

12 files changed

+737
-0
lines changed

12 files changed

+737
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Texas holdem".
3131
- Tests for "Solid integer".
3232
- Tests for "Bit count to limit".
33+
- Tests for "Porcupine fever".
3334

3435
### Fixed
3536
- Tests groups for "CGFunge interpreter".
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\PorcupineFever;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Porcupine fever" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/porcupine-fever
12+
*/
13+
class PorcupineFever implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
fscanf($stdin, "%d", $Y);
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
fscanf($stdin, "%d %d %d", $S, $H, $A);
22+
}
23+
for ($i = 0; $i < $Y; $i++)
24+
{
25+
26+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
27+
28+
echo("answer\n");
29+
}
30+
}
31+
}
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\PorcupineFever;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\PorcupineFever\PorcupineFever;
9+
10+
/**
11+
* Tests for the "Porcupine fever" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\PorcupineFever\PorcupineFever
14+
* @group porcupineFever
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new PorcupineFever();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "One sick cage".
26+
*
27+
* @group porcupineFever_oneSickCage
28+
*/
29+
public function testCanExecuteOneSickCage(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - one sick cage.txt',
33+
file_get_contents(__DIR__ . '/output/01 - one sick cage.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "No porcupines".
39+
*
40+
* @group porcupineFever_noPorcupines
41+
*/
42+
public function testCanExecuteNoPorcupines(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - no porcupines.txt',
46+
0 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "One cage goes extinct".
52+
*
53+
* @group porcupineFever_oneCageGoesExtinct
54+
*/
55+
public function testCanExecuteOneCageGoesExtinct(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - one cage goes extinct.txt',
59+
file_get_contents(__DIR__ . '/output/03 - one cage goes extinct.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Dead farm".
65+
*
66+
* @group porcupineFever_deadFarm
67+
*/
68+
public function testCanExecuteDeadFarm(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - dead farm.txt',
72+
file_get_contents(__DIR__ . '/output/04 - dead farm.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Bigger farm".
78+
*
79+
* @group porcupineFever_biggerFarm
80+
*/
81+
public function testCanExecuteBiggerFarm(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - bigger farm.txt',
85+
file_get_contents(__DIR__ . '/output/05 - bigger farm.txt')
86+
);
87+
}
88+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
3
3+
2 118 120
4+
0 50 50
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0
2+
1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3
2+
3
3+
2 16 18
4+
6 8 14
5+
0 50 50
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
62
2+
26
3+
11 1 12
4+
7 1249 1256
5+
1 91 92
6+
57 1 58
7+
99 3621 3720
8+
85 1542 1627
9+
164 56 220
10+
30 1 31
11+
2 939 941
12+
36 1069 1105
13+
8 1199 1207
14+
174 13 187
15+
84 24 108
16+
2 8 10
17+
56 133 189
18+
57 218 275
19+
291 2125 2416
20+
11 5911 5922
21+
15 16 31
22+
5 8 13
23+
115 41 156
24+
25 11 36
25+
391 47 438
26+
11 15 26
27+
4 10 14
28+
195 820 1015
29+
37 7 44
30+
134 104 238
31+
47 1729 1776
32+
89 26 115
33+
1 3 4
34+
4 17 21
35+
6 3 9
36+
1 2210 2211
37+
3 4378 4381
38+
1 93 94
39+
78 18746 18824
40+
7 307 314
41+
4 1 5
42+
11 428 439
43+
8 2 10
44+
47 27 74
45+
5 99 104
46+
43 99 142
47+
1 125 126
48+
2 5870 5872
49+
2 87 89
50+
5 1 6
51+
45 26 71
52+
195 14 209
53+
5 19 24
54+
1 1 2
55+
5 9 14
56+
61 302 363
57+
1 159 160
58+
304 61 365
59+
4 48 52
60+
72 9624 9696
61+
14 43 57
62+
4 33 37
63+
6 46 52
64+
3 2 5

0 commit comments

Comments
 (0)