Skip to content

Commit 0cb14d4

Browse files
committed
Adding tests for "Mitosis mayhem".
1 parent 5a12cf6 commit 0cb14d4

26 files changed

+297
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
- Tests for "A coin guessing game".
3838
- Tests for "Folding a note".
3939
- Tests for "River crossing".
40+
- Tests for "Mitosis mayhem".
4041

4142
## [3.11.0] - 2022-07-31
4243
### 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\MitosisMayhem;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Mitosis mayhem" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/mitosis-mayhem
12+
*/
13+
class MitosisMayhem implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $max, $cycles);
18+
for ($i = 0; $i < $cycles; $i++)
19+
{
20+
fscanf($stdin, "%s %d %d", $name, $initialCount, $power);
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("The Answer: 42\n");
26+
}
27+
}
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\MitosisMayhem;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\MitosisMayhem\MitosisMayhem;
9+
10+
/**
11+
* Tests for the "Mitosis mayhem" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\MitosisMayhem\MitosisMayhem
14+
* @group mitosisMayhem
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MitosisMayhem();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "All full".
26+
*
27+
* @group mitosisMayhem_allFull
28+
*/
29+
public function testCanExecuteAllFull(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - all full.txt',
33+
"Red: 10" . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Missing a few".
39+
*
40+
* @group photoBoothTransformation_missingAFew
41+
*/
42+
public function testCanExecuteMissingAFew(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - missing a few.txt',
46+
file_get_contents(__DIR__ . '/output/02 - missing a few.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Multiple".
52+
*
53+
* @group photoBoothTransformation_multiple
54+
*/
55+
public function testCanExecuteMultiple(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - multiple.txt',
59+
file_get_contents(__DIR__ . '/output/03 - multiple.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Overflow!".
65+
*
66+
* @group mitosisMayhem_overflow
67+
*/
68+
public function testCanExecuteOverflow(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - overflow!.txt',
72+
"OVERFLOW!" . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Overflow! 2".
78+
*
79+
* @group mitosisMayhem_overflow2
80+
*/
81+
public function testCanExecuteOverflow2(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - overflow! 2.txt',
85+
"OVERFLOW!" . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Stop!".
91+
*
92+
* @group photoBoothTransformation_stop
93+
*/
94+
public function testCanExecuteStop(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - stop!.txt',
98+
file_get_contents(__DIR__ . '/output/06 - stop!.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Conflict!".
104+
*
105+
* @group photoBoothTransformation_conflict
106+
*/
107+
public function testCanExecuteConflict(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - conflict!.txt',
111+
file_get_contents(__DIR__ . '/output/07 - conflict!.txt')
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "Overpowered".
117+
*
118+
* @group photoBoothTransformation_overpowered
119+
*/
120+
public function testCanExecuteOverpowered(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - overpowered.txt',
124+
file_get_contents(__DIR__ . '/output/08 - overpowered.txt')
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "Uneven conflict".
130+
*
131+
* @group photoBoothTransformation_unevenConflict
132+
*/
133+
public function testCanExecuteUnevenConflict(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - uneven conflict.txt',
137+
file_get_contents(__DIR__ . '/output/09 - uneven conflict.txt')
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Consumption".
143+
*
144+
* @group photoBoothTransformation_consumption
145+
*/
146+
public function testCanExecuteUnevenConsumption(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - consumption.txt',
150+
file_get_contents(__DIR__ . '/output/10 - consumption.txt')
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "Bigger fish".
156+
*
157+
* @group photoBoothTransformation_biggerFish
158+
*/
159+
public function testCanExecuteUnevenBiggerFish(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - bigger fish.txt',
163+
file_get_contents(__DIR__ . '/output/11 - bigger fish.txt')
164+
);
165+
}
166+
167+
/**
168+
* Test that the code can be executed for "Skip the little ones".
169+
*
170+
* @group photoBoothTransformation_skipTheLittleOnes
171+
*/
172+
public function testCanExecuteSkipTheLittleOnes(): void
173+
{
174+
$this->expectExecuteOutputAnswer(
175+
__DIR__ . '/input/12 - skip the little ones.txt',
176+
file_get_contents(__DIR__ . '/output/12 - skip the little ones.txt')
177+
);
178+
}
179+
180+
/**
181+
* Test that the code can be executed for "Imperfect conflict".
182+
*
183+
* @group photoBoothTransformation_imperfectConflict
184+
*/
185+
public function testCanExecuteImperfectConflict(): void
186+
{
187+
$this->expectExecuteOutputAnswer(
188+
__DIR__ . '/input/13 - imperfect conflict.txt',
189+
file_get_contents(__DIR__ . '/output/13 - imperfect conflict.txt')
190+
);
191+
}
192+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
10 1
2+
Red 10 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
30 1
2+
Red 10 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
50 2
2+
Red 20 0
3+
Blue 5 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
80 2
2+
Blue 40 0
3+
Green 5 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
50 4
2+
Purple 10 0
3+
Blue 30 0
4+
Green 20 0
5+
Yellow 10 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
50 3
2+
Blue 20 0
3+
STOP! 0 0
4+
Green 10 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
80 3
2+
Red 10 0
3+
Blue 20 0
4+
Nothing 0 0

0 commit comments

Comments
 (0)