Skip to content

Commit 53acece

Browse files
committed
Adding tests for "Cosmic love".
1 parent 78b0b39 commit 53acece

File tree

8 files changed

+194
-0
lines changed

8 files changed

+194
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
- Tests for "Sweet spot".
3737
- Tests for "Linear Bézier curves".
3838
- Tests for "Disordered first contact".
39+
- Tests for "Cosmic love".
3940

4041
## [3.8.0] - 2022-04-30
4142
### 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\Easy\CosmicLove;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Cosmic love" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/cosmic-love
12+
*/
13+
class CosmicLove 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 %s %s %s", $name, $r, $m, $c);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("answer\n");
26+
}
27+
}
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\CosmicLove;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\CosmicLove\CosmicLove;
9+
10+
/**
11+
* Tests for the "Cosmic love" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\CosmicLove\CosmicLove
14+
* @group cosmicLove
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new CosmicLove();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "One haven".
26+
*
27+
* @group cosmicLove_oneHaven
28+
*/
29+
public function testCanExecuteOneHaven(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - one haven.txt',
33+
"G7_24a" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Happy Alice".
39+
*
40+
* @group cosmicLove_happyAlice
41+
*/
42+
public function testCanExecuteHappyAlice(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - happy Alice.txt',
46+
"Millers_Planet" . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Hungry Alice".
52+
*
53+
* @group cosmicLove_hungryAlice
54+
*/
55+
public function testCanExecuteHungryAlice(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - hungry Alice.txt',
59+
"CodinPlanet" . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "So many options".
65+
*
66+
* @group cosmicLove_soManyOptions
67+
*/
68+
public function testCanExecuteSoManyOptions(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - so many options.txt',
72+
"Gh2" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "The event horizon".
78+
*
79+
* @group cosmicLove_theEventHorizon
80+
*/
81+
public function testCanExecuteTheEventHorizon(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - the event horizon.txt',
85+
"Supergiant_H59" . PHP_EOL
86+
);
87+
}
88+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
Alice 4.70e11 4.70e42 0
3+
BLARGHHH 6.30e09 1.30e31 5.14e11
4+
G7_24a 4.49e08 2.50e30 5.51e13
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6
2+
New_York_Planet 3.90e04 3.20e20 4.31e13
3+
Kepler_1337 4.49e08 2.50e30 5.07e13
4+
Mar_Sara 3.90e07 7.00e25 2.21e14
5+
The_Sun 6.96e08 1.99e30 1.33e14
6+
Alice 7.33e11 5.72e44 0
7+
Millers_Planet 4.40e07 2.00e29 9.20e12
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
Sector_XII 6.30e07 1.30e24 6.21e11
3+
Planet_of_the_Apendectomies 4.49e08 2.50e30 6.21e11
4+
Earth 6.38e06 5.97e23 2.89e12
5+
VX819 3.62e08 1.67e31 5.33e11
6+
CodinPlanet 7.49e03 9.23e14 7.62e13
7+
SSxss2 4.16e11 1.35e39 6.23e11
8+
Alice 4.70e11 4.70e44 0
9+
Cybertron 2.60e10 6.29e31 3.96e12
10+
C44 7.81e08 4.88e30 7.12e11
11+
Nowhere_Planet 4.39e04 3.95e14 5.25e11
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
24
2+
C33 3.18e06 3.52e17 6.98e13
3+
C32 7.87e06 2.76e25 3.04e14
4+
C31 5.50e04 3.00e16 1.36e13
5+
Alice 9.20e12 7.72e48 0
6+
Gh1 9.71e05 3.67e24 1.62e16
7+
Gh2 6.36e08 2.52e32 6.95e14
8+
Gh3 3.63e07 3.57e26 9.63e12
9+
Gh4 8.46e07 1.54e30 7.09e17
10+
Gh5 9.28e05 4.17e25 7.68e16
11+
OMG 2.05e08 5.08e27 3.15e13
12+
North_Par 9.03e05 8.22e22 7.30e13
13+
South_Par 1.09e08 7.89e28 2.43e14
14+
Gi3x5 2.27e05 4.90e16 9.63e13
15+
Hx9y3 7.70e06 2.68e28 4.28e13
16+
Mw4e7 4.85e08 1.30e16 6.77e15
17+
Aa2b9 8.10e08 7.88e30 2.27e13
18+
Moorf 6.80e06 1.67e27 9.34e17
19+
Moorg 7.01e06 2.04e26 3.14e13
20+
Moord 5.43e07 5.13e30 7.62e15
21+
Moorb 3.40e07 6.71e29 2.73e16
22+
Moorp 1.09e07 4.28e24 9.76e17
23+
Moork 7.32e05 9.19e22 1.67e16
24+
Moo 9.00e06 2.55e27 9.92e12
25+
Bob 2.88e04 2.64e16 7.62e16
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
30
2+
Virgx3 7.14e06 1.26e27 4.72e13
3+
Gusty_Garden_Galaxy 1.39e07 3.69e29 9.25e12
4+
Swsn_42g 3.07e05 8.28e23 8.60e12
5+
California 4.90e05 8.82e23 2.84e14
6+
Kepples_x2a_1 8.23e05 1.96e21 8.12e15
7+
Gz3_an1_5b 9.04e05 3.88e25 8.88e13
8+
Twin_Planets 3.57e07 6.06e26 8.61e14
9+
Earht 9.80e07 4.06e31 1.91e13
10+
Vaelfor 9.25e05 4.69e24 2.91e14
11+
Ns_2335_b 8.29e06 1.75e29 1.21e14
12+
Soliferous 1.51e07 1.17e24 2.46e15
13+
Qua_sar 9.09e08 6.29e29 8.64e16
14+
GRB_34 1.84e08 6.54e32 7.21e12
15+
Gernob 7.77e04 2.27e20 6.51e14
16+
Rad 1.72e05 8.59e22 5.15e13
17+
Alice 3.92e10 5.36e48 0
18+
Gernob_2 6.69e07 6.06e27 7.54e14
19+
Alpha_Parsec_35_y 3.07e08 3.84e30 6.87e14
20+
Beyond 1.05e07 5.34e28 9.76e13
21+
Tylenal 5.22e04 9.51e20 4.39e14
22+
Magen_4s 5.68e05 7.43e23 4.35e14
23+
Spacescraper 4.43e07 8.01e28 5.79e13
24+
Schrodingers_Plant 8.62e05 6.62e25 8.23e14
25+
Tailor_Swift 1.37e07 6.28e27 9.73e15
26+
Donald_Dunk 8.80e03 4.47e17 4.68e16
27+
Fireflee 2.32e03 5.96e13 2.15e15
28+
Supergiant_H59 2.99e08 6.48e33 4.37e13
29+
GRB_34 6.54e06 9.75e23 6.70e15
30+
Blue3 3.57e05 5.09e22 4.06e14
31+
New_New_Zealand 2.16e05 9.65e20 6.62e14

0 commit comments

Comments
 (0)