Skip to content

Commit 2515e9d

Browse files
committed
Adding tests for "3×N tiling".
1 parent cf86d61 commit 2515e9d

25 files changed

+358
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Tests for "Simplified Monopoly™ turns prediction".
2525
- Tests for "Regular polygons".
2626
- Tests for "Horse-hyperracing hyperduals".
27+
- Tests for "3×N tiling".
2728

2829
## [3.13.0] - 2022-09-30
2930
### Added
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\ThreeByNTiling;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "3×N tiling" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/3n-tiling
12+
*/
13+
class ThreeByNTiling implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $T);
18+
for ($i = 0; $i < $T; $i++)
19+
{
20+
fscanf($stdin, "%d %d", $K, $N);
21+
}
22+
for ($i = 0; $i < $T; $i++)
23+
{
24+
25+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
26+
27+
echo("W\n");
28+
}
29+
}
30+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\ThreeByNTiling;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\ThreeByNTiling\ThreeByNTiling;
9+
10+
/**
11+
* Tests for the "3×N tiling" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\ThreeByNTiling\ThreeByNTiling
14+
* @group threeByNTiling
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new ThreeByNTiling();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "1×N possible".
26+
*
27+
* @group threeByNTiling_1ByNPossible
28+
*/
29+
public function testCanExecute1ByNPossible(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - 1×N possible.txt',
33+
file_get_contents(__DIR__ . '/output/01 - 1×N possible.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "1×N impossible".
39+
*
40+
* @group threeByNTiling_1ByNImpossible
41+
*/
42+
public function testCanExecute1ByNImpossible(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - 1×N impossible.txt',
46+
file_get_contents(__DIR__ . '/output/02 - 1×N impossible.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "1×N mixed".
52+
*
53+
* @group threeByNTiling_1ByNMixed
54+
*/
55+
public function testCanExecute1ByNMixed(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - 1×N mixed.txt',
59+
file_get_contents(__DIR__ . '/output/03 - 1×N mixed.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "2×N simple".
65+
*
66+
* @group threeByNTiling_2ByNSimple
67+
*/
68+
public function testCanExecute2ByNSimple(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - 2×N simple.txt',
72+
file_get_contents(__DIR__ . '/output/04 - 2×N simple.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "2×N intermediate".
78+
*
79+
* @group threeByNTiling_2ByNIntermediate
80+
*/
81+
public function testCanExecute2ByNIntermediate(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - 2×N intermediate.txt',
85+
file_get_contents(__DIR__ . '/output/05 - 2×N intermediate.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "2×N advanced".
91+
*
92+
* @group threeByNTiling_2ByNAdvanced
93+
*/
94+
public function testCanExecute2ByNAdvanced(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - 2×N advanced.txt',
98+
file_get_contents(__DIR__ . '/output/06 - 2×N advanced.txt')
99+
);
100+
}
101+
102+
/**
103+
* Test that the code can be executed for "3×N simple".
104+
*
105+
* @group threeByNTiling_3ByNSimple
106+
*/
107+
public function testCanExecute3ByNSimple(): void
108+
{
109+
$this->expectExecuteOutputAnswer(
110+
__DIR__ . '/input/07 - 3×N simple.txt',
111+
file_get_contents(__DIR__ . '/output/07 - 3×N simple.txt')
112+
);
113+
}
114+
115+
/**
116+
* Test that the code can be executed for "3×N intermediate".
117+
*
118+
* @group threeByNTiling_3ByNIntermediate
119+
*/
120+
public function testCanExecute3ByNIntermediate(): void
121+
{
122+
$this->expectExecuteOutputAnswer(
123+
__DIR__ . '/input/08 - 3×N intermediate.txt',
124+
file_get_contents(__DIR__ . '/output/08 - 3×N intermediate.txt')
125+
);
126+
}
127+
128+
/**
129+
* Test that the code can be executed for "3×N advanced".
130+
*
131+
* @group threeByNTiling_3ByNAdvanced
132+
*/
133+
public function testCanExecute3ByNAdvanced(): void
134+
{
135+
$this->expectExecuteOutputAnswer(
136+
__DIR__ . '/input/09 - 3×N advanced.txt',
137+
file_get_contents(__DIR__ . '/output/09 - 3×N advanced.txt')
138+
);
139+
}
140+
141+
/**
142+
* Test that the code can be executed for "Mixed".
143+
*
144+
* @group threeByNTiling_mixed
145+
*/
146+
public function testCanExecuteMixed(): void
147+
{
148+
$this->expectExecuteOutputAnswer(
149+
__DIR__ . '/input/10 - mixed.txt',
150+
file_get_contents(__DIR__ . '/output/10 - mixed.txt')
151+
);
152+
}
153+
154+
/**
155+
* Test that the code can be executed for "You might want to check these".
156+
*
157+
* @group threeByNTiling_youMightWantToCheckThese
158+
*/
159+
public function testCanExecuteYouMightWantToCheckThese(): void
160+
{
161+
$this->expectExecuteOutputAnswer(
162+
__DIR__ . '/input/11 - you might want to check these.txt',
163+
file_get_contents(__DIR__ . '/output/11 - you might want to check these.txt')
164+
);
165+
}
166+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
1 6
3+
1 9
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
1 5
3+
1 10
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
1 6
3+
1 19
4+
1 23
5+
1 33
6+
1 69
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
2 1
3+
2 2
4+
2 3
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
2 1
3+
2 12
4+
2 32
5+
2 14
6+
2 35
7+
2 64
8+
2 17
9+
2 84
10+
2 94
11+
2 10
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
10
2+
2 999891
3+
2 929992
4+
2 999993
5+
2 999994
6+
2 999995
7+
2 999996
8+
2 999997
9+
2 999998
10+
2 999999
11+
2 1000000
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
3 1
3+
3 2
4+
3 3

0 commit comments

Comments
 (0)