Skip to content

Commit fdc93c7

Browse files
committed
Adding tests for "Constrained latin squares".
1 parent 0e743a4 commit fdc93c7

File tree

11 files changed

+210
-0
lines changed

11 files changed

+210
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- Tests for "Join the dots".
3030
- Tests for "Circular automation, the period of chaos".
3131
- Tests for "Minimax exercise".
32+
- Tests for "Constrained latin squares".
3233

3334
## [3.11.0] - 2022-07-31
3435
### 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\ConstrainedLatinSquares;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Constrained latin squares" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/constrained-latin-squares
12+
*/
13+
class ConstrainedLatinSquares implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $n);
18+
for ($i = 0; $i < $n; $i++)
19+
{
20+
$row = stream_get_line($stdin, 10 + 1, "\n");
21+
}
22+
23+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
24+
25+
echo("0\n");
26+
}
27+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\ConstrainedLatinSquares;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\ConstrainedLatinSquares\ConstrainedLatinSquares;
9+
10+
/**
11+
* Tests for the "Constrained latin squares" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\ConstrainedLatinSquares\ConstrainedLatinSquares
14+
* @group constrainedLatinSquares
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new ConstrainedLatinSquares();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "3x3 easy".
26+
*
27+
* @group depotOrganization_3x3Easy
28+
*/
29+
public function testCanExecute3x3Easy(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - 3x3 easy.txt',
33+
1 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "4x4 unconstrained".
39+
*
40+
* @group depotOrganization_4x4Unconstrained
41+
*/
42+
public function testCanExecute4x4Unconstrained(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - 4x4 unconstrained.txt',
46+
576 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "5x5 wrong grid".
52+
*
53+
* @group depotOrganization_5x5WrongGrid
54+
*/
55+
public function testCanExecute5x5WrongGrid(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 5x5 wrong grid.txt',
59+
0 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "5x5 fundamental".
65+
*
66+
* @group depotOrganization_5x5Fundamental
67+
*/
68+
public function testCanExecute5x5Fundamental(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - 5x5 fundamental.txt',
72+
56 . PHP_EOL
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "6x6".
78+
*
79+
* @group depotOrganization_6x6
80+
*/
81+
public function testCanExecute6x6(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - 6x6.txt',
85+
10752 . PHP_EOL
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "7x7".
91+
*
92+
* @group depotOrganization_7x7
93+
*/
94+
public function testCanExecute7x7(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - 7x7.txt',
98+
14388 . PHP_EOL
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "8x8".
104+
*
105+
* @group depotOrganization_8x8
106+
*/
107+
public function testCanExecute8x8(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - 8x8.txt',
111+
1 . PHP_EOL
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "9x9".
117+
*
118+
* @group depotOrganization_9x9
119+
*/
120+
public function testCanExecute9x9(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - 9x9.txt',
124+
8896 . PHP_EOL
125+
);
126+
}
127+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
123
3+
200
4+
300
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
0000
3+
0000
4+
0000
5+
0000
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
10001
3+
00000
4+
00000
5+
00000
6+
00000
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
12345
3+
20000
4+
30000
5+
40000
6+
50000
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6
2+
100000
3+
020000
4+
003000
5+
000400
6+
000050
7+
000006
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7
2+
2000007
3+
0403000
4+
0030000
5+
0006004
6+
1500000
7+
0000020
8+
0100070
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
8
2+
12345600
3+
23456000
4+
34560000
5+
45600000
6+
56000000
7+
60000000
8+
00000000
9+
00000008

0 commit comments

Comments
 (0)