Skip to content

Commit c6cc1ce

Browse files
committed
Adding tests for "Gravity tumbler".
1 parent d134a94 commit c6cc1ce

File tree

15 files changed

+275
-0
lines changed

15 files changed

+275
-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 "Huffman code".
3333
- Tests for "Number of paths between 2 points".
3434
- Tests for "The lost child.Episode-1".
35+
- Tests for "Gravity tumbler".
3536

3637
## [3.12.0] - 2022-09-01
3738
### Added
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Community\Training\Medium\GravityTumbler;
6+
7+
use CyrilVerloop\Codingame\Puzzle;
8+
9+
/**
10+
* The "Gravity tumbler" puzzle.
11+
* @link https://www.codingame.com/ide/puzzle/gravity-tumbler
12+
*/
13+
class GravityTumbler implements Puzzle
14+
{
15+
public function execute($stdin): void
16+
{
17+
fscanf($stdin, "%d %d", $width, $height);
18+
fscanf($stdin, "%d", $count);
19+
for ($i = 0; $i < $height; $i++)
20+
{
21+
$raster = stream_get_line($stdin, $width + 1, "\n");
22+
}
23+
24+
// Write an answer using echo(). DON'T FORGET THE TRAILING \n
25+
26+
echo("...\n");
27+
echo("write ###\n");
28+
}
29+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CyrilVerloop\Codingame\Tests\Community\Training\Medium\GravityTumbler;
6+
7+
use CyrilVerloop\Codingame\Tests\PuzzleTest;
8+
use CyrilVerloop\Codingame\Community\Training\Medium\GravityTumbler\GravityTumbler;
9+
10+
/**
11+
* Tests for the "Gravity tumbler" puzzle.
12+
*
13+
* @covers \CyrilVerloop\Codingame\Community\Training\Medium\GravityTumbler\GravityTumbler
14+
* @group gravityTumbler
15+
* @medium
16+
*/
17+
final class CGTest extends PuzzleTest
18+
{
19+
public function setUp(): void
20+
{
21+
$this->puzzle = new GravityTumbler();
22+
}
23+
24+
/**
25+
* Test that the code can be executed for "Tumble".
26+
*
27+
* @group gravityTumbler_tumble
28+
*/
29+
public function testCanExecuteTumble(): void
30+
{
31+
$this->expectExecuteOutputAnswer(
32+
__DIR__ . '/input/01 - tumble.txt',
33+
file_get_contents(__DIR__ . '/output/01 - tumble.txt')
34+
);
35+
}
36+
37+
/**
38+
* Test that the code can be executed for "Double".
39+
*
40+
* @group gravityTumbler_double
41+
*/
42+
public function testCanExecuteDouble(): void
43+
{
44+
$this->expectExecuteOutputAnswer(
45+
__DIR__ . '/input/02 - double.txt',
46+
file_get_contents(__DIR__ . '/output/02 - double.txt')
47+
);
48+
}
49+
50+
/**
51+
* Test that the code can be executed for "Triple".
52+
*
53+
* @group gravityTumbler_triple
54+
*/
55+
public function testCanExecuteTriple(): void
56+
{
57+
$this->expectExecuteOutputAnswer(
58+
__DIR__ . '/input/03 - triple.txt',
59+
file_get_contents(__DIR__ . '/output/03 - triple.txt')
60+
);
61+
}
62+
63+
/**
64+
* Test that the code can be executed for "Whee!".
65+
*
66+
* @group gravityTumbler_whee
67+
*/
68+
public function testCanExecuteWhee(): void
69+
{
70+
$this->expectExecuteOutputAnswer(
71+
__DIR__ . '/input/04 - whee!.txt',
72+
file_get_contents(__DIR__ . '/output/04 - whee!.txt')
73+
);
74+
}
75+
76+
/**
77+
* Test that the code can be executed for "CodinGame 1".
78+
*
79+
* @group gravityTumbler_codinGame1
80+
*/
81+
public function testCanExecuteCodinGame1(): void
82+
{
83+
$this->expectExecuteOutputAnswer(
84+
__DIR__ . '/input/05 - CodinGame 1.txt',
85+
file_get_contents(__DIR__ . '/output/05 - CodinGame 1.txt')
86+
);
87+
}
88+
89+
/**
90+
* Test that the code can be executed for "CodinGame 2".
91+
*
92+
* @group gravityTumbler_codinGame2
93+
*/
94+
public function testCanExecuteCodinGame2(): void
95+
{
96+
$this->expectExecuteOutputAnswer(
97+
__DIR__ . '/input/06 - CodinGame 2.txt',
98+
file_get_contents(__DIR__ . '/output/06 - CodinGame 2.txt')
99+
);
100+
}
101+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
1
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
2
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
3
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
17 5
2+
4
3+
.................
4+
.................
5+
...##...###..#...
6+
.####..#####.###.
7+
#################
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
38
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
53 5
2+
27
3+
#.....#...#.#.......#...#...#.#.....#...#.#...#.#....
4+
#.....#...#.#.......#...#...#.#..#..#...#.#...#.#....
5+
#.....#...#.#...#...#...#...#.#.##..#...#.#...#.###..
6+
#####.#####.#####.#####.#...#.#####.#####.#...#.#####
7+
#####.#####.#####.#####.#####.#####.#####.#####.#####
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
....#
2+
....#
3+
....#
4+
....#
5+
....#
6+
...##
7+
...##
8+
...##
9+
...##
10+
...##
11+
...##
12+
..###
13+
..###
14+
..###
15+
..###
16+
..###
17+
..###

0 commit comments

Comments
 (0)