Skip to content

Commit a1c7c1e

Browse files
committed
Adding tests for "In stereo".
1 parent 9d81fe2 commit a1c7c1e

File tree

11 files changed

+233
-0
lines changed

11 files changed

+233
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Tests for "Buzzle".
3232
- Tests for "How time flies".
3333
- Tests for "Minesweeper level generator".
34+
- Tests for "In stereo".
3435

3536
### Changed
3637
- Renaming "Linear Bézier curves" to "Cubic Bézier curves".
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Easy\InStereo;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "In stereo" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/in-stereo
12+
*/
13+
class InStereo implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $P);
18+
$pattern = stream_get_line($stdin, $P + 1, "\n");
19+
fscanf($stdin, "%d", $S);
20+
$stock = stream_get_line($stdin, $S + 1, "\n");
21+
fscanf($stdin, "%d %d", $H, $W);
22+
for ($i = 0; $i < $H; $i++)
23+
{
24+
$depthmap = stream_get_line($stdin, $W + 1, "\n");
25+
}
26+
for ($i = 0; $i < $H; $i++)
27+
{
28+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
29+
30+
echo("answer\n");
31+
}
32+
}
33+
}
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\Easy\InStereo;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Easy\InStereo\InStereo;
9+
10+
/**
11+
* Tests for the "In stereo" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Easy\InStereo\InStereo
14+
* @group inStereo
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new InStereo();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Example".
26+
*
27+
* @group inStereo_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 "Lattice".
39+
*
40+
* @group inStereo_lattice
41+
*/
42+
public function testCanExecuteLattice(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - lattice.txt',
46+
file_get_contents(__DIR__ . '/output/02 - lattice.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Diamond".
52+
*
53+
* @group inStereo_diamond
54+
*/
55+
public function testCanExecuteDiamond(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - diamond.txt',
59+
file_get_contents(__DIR__ . '/output/03 - diamond.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "ViewFullscreen".
65+
*
66+
* @group inStereo_viewFullscreen
67+
*/
68+
public function testCanExecuteViewFullscreen(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - viewFullscreen.txt',
72+
file_get_contents(__DIR__ . '/output/04 - viewFullscreen.txt')
73+
);
74+
}
75+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
4
2+
ABCD
3+
3
4+
UVW
5+
4 10
6+
0000000000
7+
0001111000
8+
0200000001
9+
1232000222
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
8
2+
|-+_!=\/
3+
8
4+
-/|!+_\=
5+
9 33
6+
000110001100011000110001100011000
7+
000110001100011000110001100011000
8+
111111111111111111111111111111111
9+
000110001100011000110001100011000
10+
000110001100011000110001100011000
11+
111111111111111111111111111111111
12+
000110001100011000110001100011000
13+
000110001100011000110001100011000
14+
111111111111111111111111111111111
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
10
2+
8 8 88
3+
10
4+
8 8 88 8
5+
21 40
6+
0000000000000000000000000000000000000000
7+
0000000000000000010000000000002220000000
8+
0000000000000000111000000000222222200000
9+
0000000000000001121100000002222222220000
10+
0000000000000011222110000002222222220000
11+
0000000000000112232211000000222222200000
12+
0000000000001122333221100000002220000000
13+
0000000000011223343322110000000000000000
14+
0000000000112233444332211000000000000000
15+
0000000001122334444433221100000000000000
16+
0000000011223344444443322110000000000000
17+
0000000001122334444433221100000000000000
18+
0000000000112233444332211000000000000000
19+
0000000000011223343322110000001110000000
20+
0000000000001122333221100000022222000000
21+
0000000000000112232211000000333333300000
22+
0000000000000011222110000004444444440000
23+
0000000000000001121100000000000000000000
24+
0000000000000000111000000000000000000000
25+
0000000000000000010000000000000000000000
26+
0000000000000000000000000000000000000000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
12
2+
`'"'`*"`"`*"
3+
13
4+
"`*".*"""'*'.
5+
18 53
6+
00000000000000000000000000000000000000000000000000000
7+
00000000000000011111111111110000000011111111111110000
8+
00000000000011111111111111110000011111111111111110000
9+
00000000001111111111111111110001111111111111111110000
10+
00000000011111111111111111110011111111111111111110000
11+
00000000111111100000001111110111111100000001111110000
12+
00000001111111000000000000001111111000000000000000000
13+
00000001111111000000000000001111111000000000000000000
14+
00000001111111000000000000001111111000011111111110000
15+
00000001111111000000000000001111111000011111111110000
16+
00000001111111000000000000001111111000011111111110000
17+
00000001111111000000000000001111111000000001111110000
18+
00000000111111100000001111110111111100000001111110000
19+
00000000011111111111111111110011111111111111111110000
20+
00000000001111111111111111110001111111111111111110000
21+
00000000000011111111111111110000011111111111111110000
22+
00000000000000011111111111110000000011111100011110000
23+
00000000000000000000000000000000000000000000000000000
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ABCDABCDAB
2+
ABCABCAUBC
3+
ADUVADUVAU
4+
BDDUVWDWDW
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
2+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
3+
-+_!=\/-+_!=\/-+_!=\/-+_!=\/-+_!=
4+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
5+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
6+
-+_!=\/-+_!=\/-+_!=\/-+_!=\/-+_!=
7+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
8+
|-+!=-\/-+/!=\/|-+!=!\/-++!=\/_-+
9+
-+_!=\/-+_!=\/-+_!=\/-+_!=\/-+_!=
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
8 8 88 8 8 88 8 8 88 8 8 88
2+
8 8 88 8 8 8 8 8 8 8 8 8
3+
8 8 88 8 8 88 8 8 888 8 88 88
4+
8 8 88 8 8 8 88 8 888 8 88 88
5+
8 8 88 8 8 8 8 88 8 88 8 8 8
6+
8 8 88 8 8 888 88 88888 888 888
7+
8 8 88 8 8 8 8 8 8 8 8 8
8+
8 8 88 88 8 8 8 88 8 8 88 8
9+
8 8 88 8 88 8 88 88 8 88 88 8
10+
8 8 888 88 888 8 888 8
11+
8 8 8 88 88 888 8 888 8
12+
8 8 888 88 888 8 888 8
13+
8 8 88 8 88 8 88 88 8 88 88 8
14+
8 8 88 88 8 8 8 88 8 88 8
15+
8 8 88 8 8 8 8 8 8 8 88 8 8
16+
8 8 88 8 8 888 88 8888 8888 8
17+
8 8 88 8 8 8 8 88 888 888 8
18+
8 8 88 8 8 8 88 8 8 88 8 8 8
19+
8 8 88 8 8 88 8 8 88 8 8 88
20+
8 8 88 8 8 8 8 8 8 8 8 8
21+
8 8 88 8 8 88 8 8 88 8 8 88

0 commit comments

Comments
 (0)