Skip to content

Commit fe5eeb9

Browse files
committed
Adding tests for "Shikaku solver".
1 parent d45483f commit fe5eeb9

File tree

13 files changed

+330
-0
lines changed

13 files changed

+330
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Tests for "In stereo".
3535
- Tests for "Hooch clash".
3636
- Tests for "Lunar lockout".
37+
- Tests for "Shikaku solver".
3738

3839
### Changed
3940
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\ShikakuSolver;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Shikaku solver" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/shikaku-solver
12+
*/
13+
class ShikakuSolver implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $W, $H);
18+
for ($i = 0; $i < $H; $i++)
19+
{
20+
$inputs = explode(" ", fgets($stdin));
21+
for ($j = 0; $j < $W; $j++)
22+
{
23+
$v = intval($inputs[$j]);
24+
}
25+
}
26+
27+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
28+
29+
echo("answer\n");
30+
}
31+
}
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\Medium\ShikakuSolver;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\ShikakuSolver\ShikakuSolver;
9+
10+
/**
11+
* Tests for the "Shikaku solver" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\ShikakuSolver\ShikakuSolver
14+
* @group shikakuSolver
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new ShikakuSolver();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "10x10, one solution".
26+
*
27+
* @group shikakuSolver_10By10OneSolution
28+
*/
29+
public function testCanExecute10By10OneSolution(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - 10x10, one solution.txt',
33+
file_get_contents(__DIR__ . '/output/01 - 10x10, one solution.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "15x20, more solutions".
39+
*
40+
* @group shikakuSolver_15By20MoreSolutions
41+
*/
42+
public function testCanExecute15By20MoreSolutions(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - 15x20, more solutions.txt',
46+
file_get_contents(__DIR__ . '/output/02 - 15x20, more solutions.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "20x20".
52+
*
53+
* @group shikakuSolver_20By20
54+
*/
55+
public function testCanExecute20By20(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 20x20.txt',
59+
file_get_contents(__DIR__ . '/output/03 - 20x20.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "25x20".
65+
*
66+
* @group shikakuSolver_25By20
67+
*/
68+
public function testCanExecute25By20(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - 25x20.txt',
72+
file_get_contents(__DIR__ . '/output/04 - 25x20.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "30x30".
78+
*
79+
* @group shikakuSolver_30By30
80+
*/
81+
public function testCanExecute30By30(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - 30x30.txt',
85+
file_get_contents(__DIR__ . '/output/05 - 30x30.txt')
86+
);
87+
}
88+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10 10
2+
0 0 0 0 0 0 0 0 9 0
3+
0 0 0 0 0 0 9 0 0 0
4+
0 0 0 0 0 0 0 0 0 0
5+
0 20 0 0 8 0 0 0 6 0
6+
0 0 0 0 0 0 0 0 0 0
7+
0 0 0 6 0 0 6 0 0 0
8+
10 0 0 0 0 0 0 0 0 0
9+
0 0 0 0 0 0 0 0 0 0
10+
0 0 6 0 6 0 0 0 8 0
11+
0 0 0 0 0 0 6 0 0 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
15 20
2+
0 0 0 0 0 0 0 0 0 9 0 0 0 0 0
3+
0 8 0 0 0 6 0 0 6 0 0 0 0 0 0
4+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5+
0 0 0 10 0 0 0 0 6 0 6 0 0 0 0
6+
0 10 0 0 0 0 0 0 0 0 0 0 15 0 0
7+
0 0 0 14 0 0 9 0 0 0 6 0 0 0 0
8+
0 0 0 0 0 12 0 0 0 0 0 0 0 0 0
9+
0 0 0 0 0 0 0 0 6 0 0 0 12 0 0
10+
0 0 0 0 0 0 0 0 0 0 0 0 8 0 0
11+
0 0 0 0 0 9 0 0 0 0 0 0 0 0 0
12+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
13+
0 14 0 0 0 0 0 0 8 0 0 0 0 0 24
14+
0 0 0 0 0 0 0 0 0 6 0 0 6 0 0
15+
0 0 0 9 0 0 6 0 0 28 0 0 0 0 0
16+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17+
0 0 0 0 0 0 0 8 0 0 0 0 0 0 0
18+
0 0 0 10 0 0 0 0 0 0 0 0 0 0 0
19+
0 0 0 0 0 0 15 0 6 0 0 0 0 0 0
20+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
21+
8 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
20 20
2+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0
4+
0 0 0 0 0 0 0 0 0 0 0 0 65 0 0 0 0 0 0 0
5+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0
6+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0
7+
18 0 0 0 0 0 0 0 0 9 0 0 0 6 0 0 0 0 0 6
8+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0
9+
0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 6 8 0 0 0
10+
10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11+
0 0 0 0 0 8 0 6 0 0 8 0 0 6 0 0 0 0 0 0
12+
8 0 0 0 0 0 0 0 0 0 0 6 0 0 0 6 0 0 0 8
13+
0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0
14+
0 0 0 0 0 0 0 6 0 0 6 0 0 0 6 0 0 0 12 0
15+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16+
0 0 0 16 0 0 10 0 0 0 0 0 6 0 0 0 0 0 0 0
17+
9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
18+
0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 8 0 0 0 0
19+
0 0 0 0 0 9 0 9 0 0 0 0 0 6 0 0 8 0 8 0
20+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0
21+
0 0 0 0 0 0 26 0 0 0 0 0 0 8 0 0 0 0 0 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
25 20
2+
0 0 15 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 6 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AAAADDDDEE
7+
FFGGGHHHEE
8+
FFGGGHHHII
9+
FFJJKKLLII
10+
FFJJKKLLII
11+
FFJJKKLLII
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
20
2+
AABBCCDDDDDDDDD
3+
AABBCCEEEEEEFFF
4+
AABBCCGGGHHHFFF
5+
AABBIIGGGHHHFFF
6+
JJBBIIKKKLLLFFF
7+
JJMMIIKKKLLLFFF
8+
JJMMIIKKKNNNNNN
9+
JJMMIIOOONNNNNN
10+
JJMMIIOOOPPPPQQ
11+
RRMMSSSTTPPPPQQ
12+
RRMMSSSTTUUVVQQ
13+
RRMMSSSTTUUVVQQ
14+
RRWWWXXTTUUVVQQ
15+
RRWWWXXYYZZZZQQ
16+
RRWWWXXYYZZZZQQ
17+
RRaaaaaYYZZZZQQ
18+
bbaaaaaYYZZZZQQ
19+
bbcccccddZZZZQQ
20+
bbcccccddZZZZQQ
21+
bbcccccddZZZZQQ

0 commit comments

Comments
 (0)