Skip to content

Commit 8cf1800

Browse files
committed
Adding tests for "1010(1)".
1 parent efb82ab commit 8cf1800

File tree

7 files changed

+134
-0
lines changed

7 files changed

+134
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Tests for "The urinal problem".
3333
- Tests for "2×2×2 rubik’s cube movements".
3434
- Tests for "The polish dictionary".
35+
- Tests for "1010(1)".
3536

3637
## [3.16.0] - 2022-12-31
3738
### Added
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\One0One0One;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "1010(1)" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/10101
12+
*/
13+
class One0One0One implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $W);
18+
fscanf($stdin, "%d", $H);
19+
for ($i = 0; $i < $H; $i++)
20+
{
21+
$ROW = stream_get_line($stdin, $W + 1, "\n");
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\One0One0One;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\One0One0One\One0One0One;
9+
10+
/**
11+
* Tests for the "1010(1)" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\One0One0One\One0One0One
14+
* @group one0One0One
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new One0One0One();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Tiny".
26+
*
27+
* @group one0One0One_tiny
28+
*/
29+
public function testCanExecuteTiny(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - tiny.txt',
33+
4 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Stretch".
39+
*
40+
* @group one0One0One_stretch
41+
*/
42+
public function testCanExecuteStretch(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - stretch.txt',
46+
2 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "You lose".
52+
*
53+
* @group one0One0One_youLose
54+
*/
55+
public function testCanExecuteYouLose(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - you lose.txt',
59+
0 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Big".
65+
*
66+
* @group one0One0One_big
67+
*/
68+
public function testCanExecuteBig(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - big.txt',
72+
3 . PHP_EOL
73+
);
74+
}
75+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
3
2+
3
3+
..#
4+
..#
5+
##.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
5
2+
3
3+
###..
4+
###..
5+
.....
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
6
2+
6
3+
.#.#.#
4+
#.#.#.
5+
.#.#.#
6+
#.#.#.
7+
.#.#.#
8+
#.#.#.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
10
3+
#########.
4+
########..
5+
#######..#
6+
.#........
7+
#######.##
8+
########..
9+
########..
10+
#..#######
11+
#..#######
12+
.#..#..#..

0 commit comments

Comments
 (0)