Skip to content

Commit 5106819

Browse files
committed
Adding tests for "Magic stones".
1 parent 969b775 commit 5106819

File tree

10 files changed

+157
-1
lines changed

10 files changed

+157
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Tests for "Hexagonal maze - part2".
2929
- Tests for "Byte pair encoding".
3030
- Tests for "Find the missing plus signs in addition".
31-
- Tests for "Rod cutting problem".
31+
- Tests for "Magic stones".
3232

3333
## [3.13.0] - 2022-09-30
3434
### Added
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\MagicStones;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Magic stones" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/magic-stones
12+
*/
13+
class MagicStones implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $N);
18+
$inputs = explode(" ", fgets($stdin));
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
$level = intval($inputs[$i]);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("1\n");
27+
}
28+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\MagicStones;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\MagicStones\MagicStones;
9+
10+
/**
11+
* Tests for the "Magic stones" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\MagicStones\MagicStones
14+
* @group magicStones
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new MagicStones();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Axiom".
26+
*
27+
* @group magicStones_axiom
28+
*/
29+
public function testCanExecuteAxiom(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - axiom.txt',
33+
1 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Add me up".
39+
*
40+
* @group magicStones_addMeUp
41+
*/
42+
public function testCanExecuteAddMeUp(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - add me up.txt',
46+
1 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Too far".
52+
*
53+
* @group magicStones_tooFar
54+
*/
55+
public function testCanExecuteTooFar(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - too far.txt',
59+
2 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Odd".
65+
*
66+
* @group magicStones_odd
67+
*/
68+
public function testCanExecuteOdd(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - odd.txt',
72+
5 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "Powerless".
78+
*
79+
* @group magicStones_powerless
80+
*/
81+
public function testCanExecutePowerless(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - powerless.txt',
85+
4 . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "Complex".
91+
*
92+
* @group magicStones_complex
93+
*/
94+
public function testCanExecuteComplex(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - complex.txt',
98+
2 . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "Huge".
104+
*
105+
* @group magicStones_huge
106+
*/
107+
public function testCanExecuteHuge(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - huge.txt',
111+
12 . PHP_EOL
112+
);
113+
}
114+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
1 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 2 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
1 1 5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
9
2+
1 1 1 2 2 3 3 4 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4
2+
1 2 3 4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
16
2+
1 1 2 3 3 3 5 6 6 6 6 6 6 6 6 9
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1000
2+
1 8 7 3 18 7 15 14 6 13 4 12 7 4 10 5 19 10 13 11 14 13 13 6 9 11 5 17 12 4 17 13 1 11 13 20 11 9 14 16 14 11 5 9 9 2 12 3 15 8 10 11 19 10 13 15 5 7 2 20 16 19 8 14 2 14 20 12 3 19 15 1 11 4 6 9 10 7 17 13 3 19 1 16 10 2 20 7 15 3 10 12 19 8 5 4 2 15 13 10 16 19 11 15 13 9 5 12 8 11 10 1 4 14 5 11 15 4 6 12 12 2 16 17 15 6 3 17 4 8 2 2 18 18 14 11 8 15 16 2 3 7 6 12 9 7 12 19 17 3 10 3 4 19 16 18 2 9 7 3 3 6 16 3 16 20 2 11 3 4 4 7 13 12 14 19 6 5 20 6 4 20 4 11 6 20 8 7 9 5 5 11 16 19 9 4 15 12 12 16 20 20 4 18 17 12 3 18 5 15 18 6 15 11 20 19 9 17 2 2 17 10 19 10 14 13 10 15 9 4 2 16 15 12 14 11 18 10 16 9 16 4 14 10 1 15 14 2 5 8 2 18 18 8 14 8 12 12 18 8 12 5 2 14 20 7 3 4 18 6 15 1 2 18 12 18 5 3 11 19 7 7 13 6 13 18 4 16 2 2 8 15 2 6 11 12 19 6 18 5 15 18 2 12 15 8 10 15 15 16 16 7 5 7 3 10 14 17 3 18 20 14 6 19 16 5 9 17 12 16 19 6 19 18 12 6 14 9 8 9 12 20 20 14 11 19 10 10 14 4 5 14 14 6 7 13 17 10 3 14 19 19 14 12 4 7 19 4 2 5 8 14 20 17 4 20 12 7 10 9 11 9 17 3 4 2 9 11 8 7 6 10 8 10 6 9 6 7 15 19 17 20 9 6 19 2 8 18 14 16 1 18 4 13 18 10 17 14 19 5 16 3 4 14 19 15 14 15 19 7 20 16 7 9 18 7 7 14 15 6 13 2 6 18 16 19 19 10 5 5 13 6 3 16 7 4 16 8 1 11 10 4 18 3 5 5 5 6 3 10 3 20 15 2 14 8 10 5 16 15 7 19 2 7 9 18 13 12 7 14 8 7 9 13 2 11 7 15 19 3 17 6 7 12 4 12 11 14 19 2 11 8 3 15 8 14 8 13 16 13 4 4 11 4 12 12 12 19 3 3 19 11 18 5 18 16 18 18 1 13 18 19 8 8 7 6 7 14 7 2 16 17 2 12 2 15 6 13 11 17 13 7 2 13 10 14 13 14 14 11 4 6 20 17 11 14 3 11 16 17 10 10 13 8 5 9 16 17 15 14 8 2 7 5 10 16 3 7 13 7 11 11 10 11 17 19 11 15 16 7 14 1 2 16 11 3 2 15 10 16 17 8 16 19 14 3 4 9 4 3 8 16 16 15 13 3 1 9 19 16 17 9 7 6 16 6 15 13 3 18 15 18 12 4 9 7 6 15 6 9 13 4 10 7 4 20 10 11 18 14 2 13 13 10 3 5 14 6 15 7 15 7 7 16 12 12 6 20 4 1 4 6 3 12 9 18 13 4 9 10 2 15 13 9 14 9 2 16 20 9 6 4 13 17 18 20 5 9 7 8 1 5 3 8 3 15 11 1 15 1 13 14 19 17 9 4 4 14 6 12 14 9 5 8 6 16 4 13 4 3 13 14 18 18 8 1 15 2 6 4 2 5 14 14 15 19 3 14 14 5 2 16 2 14 11 1 16 12 17 8 18 4 16 3 15 13 17 19 4 14 8 1 7 15 17 15 5 11 5 13 9 10 14 11 15 11 17 8 11 18 3 1 12 12 14 17 16 7 15 11 15 1 3 10 2 18 5 16 9 2 7 19 3 19 15 5 6 12 4 6 4 13 15 16 13 9 11 16 3 20 5 9 3 15 2 15 8 19 20 6 13 4 4 10 16 6 7 6 10 6 7 4 8 11 13 9 16 18 20 14 18 8 11 7 11 11 9 2 10 9 12 20 7 14 8 13 9 6 10 16 18 13 16 8 10 10 18 18 5 11 9 1 2 6 10 19 6 4 3 8 20 2 20 17 1 6 15 14 17 3 7 12 16 2 12 5 5 16 15 16 15 6 11 14 3 7 12 19 13 15 11 7 6 12 18 12 5 4 8 19 8 9 18 19 4 14 3 8 13 8 10 2 16 9 14 11 17 16 14 18 9 6 15 5 13 16 9 18 18 5 6 10 5 14 3 9 20 9 6 14

0 commit comments

Comments
 (0)