Skip to content

Commit cd9f562

Browse files
committed
Adding tests for "DDCG mapper".
1 parent 62d741e commit cd9f562

File tree

11 files changed

+240
-0
lines changed

11 files changed

+240
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Tests for "Porcupine fever".
3434
- Tests for "Bijective numeration".
3535
- Tests for "Plight of the fellowship of the ring".
36+
- Tests for "DDCG mapper".
3637

3738
### Fixed
3839
- Tests groups for "CGFunge interpreter".
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\DDCGMapper;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "DDCG mapper" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/ddcg-mapper
12+
*/
13+
class DDCGMapper implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $L);
18+
fscanf($stdin, "%d", $N);
19+
for ($i = 0; $i < $N; $i++)
20+
{
21+
fscanf($stdin, "%s %d", $pattern, $tempo);
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("answer\n");
27+
}
28+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\DDCGMapper;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\DDCGMapper\DDCGMapper;
9+
10+
/**
11+
* Tests for the "DDCG mapper" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\DDCGMapper\DDCGMapper
14+
* @group DDCGMapper
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new DDCGMapper();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Example".
26+
*
27+
* @group DDCGMapper_example
28+
*/
29+
public function testCanExecuteExample(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - example.txt',
33+
file_get_contents(__DIR__ . '/output/01 - example.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "1".
39+
*
40+
* @group DDCGMapper_1
41+
*/
42+
public function testCanExecute1(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - 1.txt',
46+
file_get_contents(__DIR__ . '/output/02 - 1.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "2".
52+
*
53+
* @group DDCGMapper_2
54+
*/
55+
public function testCanExecute2(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 2.txt',
59+
file_get_contents(__DIR__ . '/output/03 - 2.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "3".
65+
*
66+
* @group DDCGMapper_3
67+
*/
68+
public function testCanExecute3(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - 3.txt',
72+
file_get_contents(__DIR__ . '/output/04 - 3.txt')
73+
);
74+
}
75+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
7
2+
2
3+
X000 2
4+
00XX 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
1
3+
X0X0 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
12
2+
3
3+
X0X0 2
4+
0X0X 3
5+
0XX0 5
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
90
2+
9
3+
X000 2
4+
0X00 3
5+
00X0 5
6+
000X 4
7+
0XX0 11
8+
0X00 7
9+
XXXX 42
10+
00XX 16
11+
XX00 22
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
0000
2+
X0XX
3+
0000
4+
X000
5+
00XX
6+
X000
7+
0000
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
X0X0
2+
0000
3+
X0X0
4+
0000
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
XXXX
2+
0000
3+
XXX0
4+
0X0X
5+
X0X0
6+
0000
7+
XXXX
8+
0XX0
9+
X0X0
10+
0X0X
11+
X0X0
12+
0000

0 commit comments

Comments
 (0)