Skip to content

Commit 706306d

Browse files
committed
Adding tests for "Number of paths between 2
points".
1 parent a93f9cf commit 706306d

File tree

7 files changed

+136
-0
lines changed

7 files changed

+136
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Tests for "Chained matrix products".
3131
- Tests for "Fun with set theory".
3232
- Tests for "Huffman code".
33+
- Tests for "Number of paths between 2 points".
3334

3435
## [3.12.0] - 2022-09-01
3536
### 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\NumberOfPathsBetween2Points;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Number of paths between 2 points" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/number-of-paths-between-2-points
12+
*/
13+
class NumberOfPathsBetween2Points implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d", $M);
18+
fscanf($stdin, "%d", $N);
19+
for ($i = 0; $i < $M; $i++)
20+
{
21+
$ROW = stream_get_line($stdin, 100 + 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\NumberOfPathsBetween2Points;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\NumberOfPathsBetween2Points\NumberOfPathsBetween2Points;
9+
10+
/**
11+
* Tests for the "Number of paths between 2 points" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\NumberOfPathsBetween2Points\NumberOfPathsBetween2Points
14+
* @group numberOfPathsBetween2Points
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new NumberOfPathsBetween2Points();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Test 1".
26+
*
27+
* @group numberOfPathsBetween2Points_test1
28+
*/
29+
public function testCanExecuteTest1(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - test 1.txt',
33+
2 . PHP_EOL
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Test 2".
39+
*
40+
* @group numberOfPathsBetween2Points_test2
41+
*/
42+
public function testCanExecuteTest2(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - test 2.txt',
46+
1 . PHP_EOL
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Test 3".
52+
*
53+
* @group numberOfPathsBetween3Points_test3
54+
*/
55+
public function testCanExecuteTest3(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - test 3.txt',
59+
2716 . PHP_EOL
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Test 4".
65+
*
66+
* @group numberOfPathsBetween4Points_test4
67+
*/
68+
public function testCanExecuteTest4(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - test 4.txt',
72+
0 . PHP_EOL
73+
);
74+
}
75+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
2
3+
00
4+
00
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2
2+
2
3+
00
4+
10
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
10
3+
0000001000
4+
0000000000
5+
0000000000
6+
0010001000
7+
0000000000
8+
0000100000
9+
0000100010
10+
0000000000
11+
0000000100
12+
0000000010
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
10
2+
10
3+
0010001000
4+
0010000000
5+
0010000000
6+
1110001000
7+
0000000000
8+
0000100000
9+
0000100010
10+
0000000000
11+
0000000101
12+
0000000010

0 commit comments

Comments
 (0)