Skip to content

Commit 6552c34

Browse files
committed
Adding tests for "Target firing".
1 parent de48a29 commit 6552c34

File tree

11 files changed

+256
-0
lines changed

11 files changed

+256
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Tests for "Elementary cellular automaton".
2727
- Tests for "Ways to make change".
2828
- Tests for "Brackets, extended edition".
29+
- Tests for "Target firing".
2930

3031
## [3.12.0] - 2022-09-01
3132
### Added
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\TargetFiring;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Target firing" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/target-firing
12+
*/
13+
class TargetFiring implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
for ($i = 0; $i < $N; $i++)
19+
{
20+
fscanf($stdin, "%s %d %d %d", $SHIP, $HP, $ARMOR, $DAMAGE);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("PEWPEW\n");
26+
}
27+
}
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\Medium\TargetFiring;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\TargetFiring\TargetFiring;
9+
10+
/**
11+
* Tests for the "Target firing" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\TargetFiring\TargetFiring
14+
* @group targetFiring
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new TargetFiring();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Strongest first".
26+
*
27+
* @group targetFiring_strongestFirst
28+
*/
29+
public function testCanExecuteStrongestFirst(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - strongest first.txt',
33+
3200 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Tankiest last".
39+
*
40+
* @group targetFiring_tankiestLast
41+
*/
42+
public function testCanExecuteTankiestLast(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - tankiest last.txt',
46+
1700 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Strongest AND Tankiest?".
52+
*
53+
* @group targetFiring_strongestANDTankiest
54+
*/
55+
public function testCanExecuteStrongestANDTankiest(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - strongest and tankiest?.txt',
59+
2880 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Boss and mooks".
65+
*
66+
* @group targetFiring_bossAndMooks
67+
*/
68+
public function testCanExecuteBossAndMooks(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - boss and mooks.txt',
72+
3430 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "The swarm".
78+
*
79+
* @group targetFiring_theSwarm
80+
*/
81+
public function testCanExecuteTheSwarm(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - the swarm.txt',
85+
212 . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Not the shiny paint!".
91+
*
92+
* @group targetFiring_notTheShinyPaint
93+
*/
94+
public function testCanExecuteNotTheShinyPaint(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - not the shiny paint!.txt',
98+
"FLEE" . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Close call".
104+
*
105+
* @group targetFiring_closeCall
106+
*/
107+
public function testCanExecuteCloseCall(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - close call.txt',
111+
0 . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Tickle wars".
117+
*
118+
* @group targetFiring_tickleWars
119+
*/
120+
public function testCanExecuteTickleWars(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - tickle wars.txt',
124+
4950 . PHP_EOL
125+
);
126+
}
127+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
FIGHTER 10 0 500
3+
FIGHTER 10 0 800
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
CRUISER 50 5 150
3+
CRUISER 60 0 150
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
FIGHTER 36 2 60
3+
CRUISER 50 3 200
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
CRUISER 170 7 20
3+
FIGHTER 15 2 35
4+
FIGHTER 15 2 35
5+
FIGHTER 15 2 35
6+
FIGHTER 15 2 35
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
50
2+
FIGHTER 26 6 1
3+
CRUISER 14 3 3
4+
CRUISER 25 6 4
5+
CRUISER 13 5 4
6+
CRUISER 19 7 3
7+
FIGHTER 12 7 2
8+
FIGHTER 21 0 2
9+
FIGHTER 15 3 3
10+
FIGHTER 26 1 1
11+
CRUISER 21 4 3
12+
FIGHTER 18 5 3
13+
FIGHTER 30 0 2
14+
CRUISER 20 8 3
15+
FIGHTER 22 3 4
16+
FIGHTER 6 6 3
17+
CRUISER 13 5 2
18+
CRUISER 11 2 3
19+
CRUISER 14 1 4
20+
FIGHTER 9 6 3
21+
CRUISER 14 2 4
22+
CRUISER 5 2 1
23+
FIGHTER 9 3 2
24+
FIGHTER 6 0 3
25+
FIGHTER 13 0 1
26+
CRUISER 19 1 1
27+
FIGHTER 15 3 4
28+
FIGHTER 8 1 4
29+
CRUISER 9 7 1
30+
CRUISER 14 5 2
31+
FIGHTER 19 4 3
32+
FIGHTER 15 0 1
33+
FIGHTER 8 7 3
34+
FIGHTER 26 0 4
35+
FIGHTER 21 3 1
36+
CRUISER 10 2 3
37+
FIGHTER 20 6 2
38+
FIGHTER 28 1 1
39+
CRUISER 19 8 4
40+
FIGHTER 14 8 3
41+
CRUISER 24 1 4
42+
CRUISER 17 4 2
43+
FIGHTER 20 1 1
44+
FIGHTER 23 4 3
45+
FIGHTER 18 3 2
46+
FIGHTER 17 3 4
47+
CRUISER 5 3 4
48+
CRUISER 18 2 2
49+
FIGHTER 11 0 1
50+
CRUISER 27 1 2
51+
FIGHTER 19 0 3
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
FIGHTER 40 2 25
3+
FIGHTER 40 2 25
4+
FIGHTER 20 2 15
5+
CRUISER 60 4 10
6+
FIGHTER 25 0 20
7+
FIGHTER 5 5 30
8+
CRUISER 40 5 30
9+
CRUISER 70 8 60
10+
FIGHTER 25 6 10
11+
FIGHTER 25 6 10
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
20
2+
FIGHTER 35 10 10
3+
FIGHTER 35 5 8
4+
FIGHTER 25 5 10
5+
CRUISER 10 5 6
6+
CRUISER 45 5 8
7+
CRUISER 75 0 6
8+
CRUISER 60 5 8
9+
FIGHTER 75 10 2
10+
FIGHTER 60 0 4
11+
FIGHTER 40 10 10
12+
FIGHTER 80 0 12
13+
FIGHTER 25 0 10
14+
CRUISER 35 0 4
15+
CRUISER 50 0 8
16+
CRUISER 105 5 8
17+
CRUISER 70 5 4
18+
FIGHTER 45 5 6
19+
CRUISER 30 0 4
20+
FIGHTER 60 10 4
21+
CRUISER 30 5 6

0 commit comments

Comments
 (0)